diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2008-04-21 23:56:37 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2008-04-21 23:56:37 +0000 |
commit | 03cab3cab0ca0a48dc712ffce290a259bc2b49c5 (patch) | |
tree | b6b669242caa218684b12ff69deec66b0de57f31 /pango/pango-bidi-type.c | |
parent | 30401e22f1a7417ad71045966a51c30e5f126cbb (diff) | |
download | pango-03cab3cab0ca0a48dc712ffce290a259bc2b49c5.tar.gz |
Bug 515432 – Add function to get bidirectional character type of a
2008-04-21 Behdad Esfahbod <behdad@gnome.org>
Bug 515432 – Add function to get bidirectional character type of a
unicode character
Patch from Jürg Billeter
* docs/pango-sections.txt:
* docs/tmpl/layout.sgml:
* docs/tmpl/main.sgml:
* docs/tmpl/pangocairo.sgml:
* pango/Makefile.am:
* pango/pango-bidi-type.c (pango_bidi_type_for_unichar):
* pango/pango-bidi-type.h:
* pango/pango-types.h:
* pango/pango-utils.c (pango_log2vis_get_embedding_levels),
(pango_unichar_direction):
* pango/pango.def:
* pango/pango.h:
New public API:
enum PangoBidiType;
pango_bidi_type_get_type()
pango_bidi_type_for_unichar()
svn path=/trunk/; revision=2607
Diffstat (limited to 'pango/pango-bidi-type.c')
-rw-r--r-- | pango/pango-bidi-type.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c new file mode 100644 index 00000000..45d1d936 --- /dev/null +++ b/pango/pango-bidi-type.c @@ -0,0 +1,75 @@ +/* Pango + * pango-bidi-type.c: Bidirectional Character Types + * + * Copyright (C) 2008 Jürg Billeter <j@bitron.ch> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <config.h> + +#include "pango-bidi-type.h" + +#include "mini-fribidi/fribidi.h" + + + +/** + * pango_bidi_type_for_unichar + * @ch: a Unicode character + * + * Determines the normative bidirectional character type of a + * character, as specified in the Unicode Character Database. + * + * A simplified version of this function is available as + * pango_unichar_get_direction(). + * + * Return value: the bidirectional character type, as used in the + * Unicode bidirectional algorithm. + * + * Since: 1.22 + */ +PangoBidiType +pango_bidi_type_for_unichar (gunichar ch) +{ + FriBidiCharType fribidi_ch_type = fribidi_get_type (ch); + + switch (fribidi_ch_type) + { + case FRIBIDI_TYPE_LTR: return PANGO_BIDI_TYPE_L; + case FRIBIDI_TYPE_LRE: return PANGO_BIDI_TYPE_LRE; + case FRIBIDI_TYPE_LRO: return PANGO_BIDI_TYPE_LRO; + case FRIBIDI_TYPE_RTL: return PANGO_BIDI_TYPE_R; + case FRIBIDI_TYPE_AL: return PANGO_BIDI_TYPE_AL; + case FRIBIDI_TYPE_RLE: return PANGO_BIDI_TYPE_RLE; + case FRIBIDI_TYPE_RLO: return PANGO_BIDI_TYPE_RLO; + case FRIBIDI_TYPE_PDF: return PANGO_BIDI_TYPE_PDF; + case FRIBIDI_TYPE_EN: return PANGO_BIDI_TYPE_EN; + case FRIBIDI_TYPE_ES: return PANGO_BIDI_TYPE_ES; + case FRIBIDI_TYPE_ET: return PANGO_BIDI_TYPE_ET; + case FRIBIDI_TYPE_AN: return PANGO_BIDI_TYPE_AN; + case FRIBIDI_TYPE_CS: return PANGO_BIDI_TYPE_CS; + case FRIBIDI_TYPE_NSM: return PANGO_BIDI_TYPE_NSM; + case FRIBIDI_TYPE_BN: return PANGO_BIDI_TYPE_BN; + case FRIBIDI_TYPE_BS: return PANGO_BIDI_TYPE_B; + case FRIBIDI_TYPE_SS: return PANGO_BIDI_TYPE_S; + case FRIBIDI_TYPE_WS: return PANGO_BIDI_TYPE_WS; + case FRIBIDI_TYPE_ON: return PANGO_BIDI_TYPE_ON; + default: + g_assert_not_reached (); + return PANGO_BIDI_TYPE_ON; + } +} |