diff options
author | Owen Taylor <otaylor@redhat.com> | 2004-02-27 14:48:54 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2004-02-27 14:48:54 +0000 |
commit | 58a45b6a10cf9ca55b3216e233f6b516c75755de (patch) | |
tree | e6820c29dec5b9b8051a378a47bf4629bbfcdd47 /pango/pango-utils.c | |
parent | f27610770305444fcab90ce651f48265e41dfee2 (diff) | |
download | pango-58a45b6a10cf9ca55b3216e233f6b516c75755de.tar.gz |
Add some new enum and values and utilities for supporting automatically
Fri Feb 27 09:30:10 2004 Owen Taylor <otaylor@redhat.com>
Add some new enum and values and utilities for supporting
automatically determined base direction. (#70451, based
on changes by Dov Grobgeld)
* pango/pango-types.h docs/tmpl/main.sgml: Add
PANGO_DIRECTION_WEAK_RTL/LTR, extend the docs for
PangoDirection.
* pango/pango-types.h pango/pango-utils.h: Move
pango_get_mirror_char() to pango-types.h.
* pango/mini-fribidi/fribidi.c (pango_log2vis_get_embedding_levels):
Handle new values of PangoDirection, handle
PANGO_DIRECTION_TTB_LTR/RTL as aliases for PANGO_DIRECTION_RTL/LTR.
* pango/mini-fribidi/fribidi.c pango/pango-types.h: Add
pango_unichar_direction().
* pango/pango-utils.c pango/pango-types.h: Add
pango_find_base_dir()
Diffstat (limited to 'pango/pango-utils.c')
-rw-r--r-- | pango/pango-utils.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pango/pango-utils.c b/pango/pango-utils.c index 05db2610..68267772 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -1493,3 +1493,39 @@ pango_lookup_aliases (const char *fontname, *n_families = 0; } } + +/** + * pango_find_base_dir: + * @text: the text to process + * @length: length of @text in bytes (may be -1 if @text is nul-terminated) + * + * Searches a string the first character that has a strong + * direction, according to the Unicode bidirectional algorithm. + * + * Return value: The direction corresponding to the first strong character. + * If no such character is found, then %PANGO_DIRECTION_NEUTRAL is returned. + */ +PangoDirection +pango_find_base_dir (const gchar *text, + gint length) +{ + PangoDirection dir = PANGO_DIRECTION_NEUTRAL; + const gchar *p; + + g_return_val_if_fail (text != NULL, PANGO_DIRECTION_NEUTRAL); + + p = text; + while ((length < 0 || p < text + length) && *p) + { + gunichar wc = g_utf8_get_char (p); + + dir = pango_unichar_direction (wc); + + if (dir != PANGO_DIRECTION_NEUTRAL) + break; + + p = g_utf8_next_char (p); + } + + return dir; +} |