diff options
author | Tor Lillqvist <tml@iki.fi> | 2003-12-08 21:31:58 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2003-12-08 21:31:58 +0000 |
commit | bcbb2cad9eee80f00ea25fd879347544f62a5a03 (patch) | |
tree | 980d9ab0977f40461acf299d2e6d18c1fff13927 /modules/basic | |
parent | f33287b277ad7ba82ba5c0a4a43024d9f7b78fbb (diff) | |
download | pango-bcbb2cad9eee80f00ea25fd879347544f62a5a03.tar.gz |
Simplify.
2003-12-08 Tor Lillqvist <tml@iki.fi>
* modules/basic/basic-win32.c (convert_log_clusters_to_byte_offsets):
Simplify.
(itemize_shape_and_place): Fix problem with RTL scripts: If
ScriptItemize() returns several items, must handle them in reverse
order. (#128812, reported by Shoshannah Forbes)
Diffstat (limited to 'modules/basic')
-rw-r--r-- | modules/basic/basic-win32.c | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c index 52e720ee..e858f71d 100644 --- a/modules/basic/basic-win32.c +++ b/modules/basic/basic-win32.c @@ -671,47 +671,31 @@ set_up_pango_log_clusters (gboolean rtl, static void convert_log_clusters_to_byte_offsets (const char *text, gint length, - PangoAnalysis *analysis, PangoGlyphString *glyphs) { const char *p; int charix, glyphix; + int n_chars = g_utf8_strlen (text, length); + int *byte_offset = g_new (int, n_chars); - /* Convert char indexes in the log_clusters array to byte offsets in - * the UTF-8 text. - */ p = text; charix = 0; - if (analysis->level % 2) + while (p < text + length) { - glyphix = glyphs->num_glyphs - 1; - while (p < text + length) - { - while (glyphix >= 0 && - glyphs->log_clusters[glyphix] == charix) - { - glyphs->log_clusters[glyphix] = p - text; - glyphix--; - } - charix++; - p = g_utf8_next_char (p); - } + byte_offset[charix] = p - text; + charix++; + p = g_utf8_next_char (p); } - else + + /* Convert char indexes in the log_clusters array to byte offsets. + */ + for (glyphix = 0; glyphix < glyphs->num_glyphs; glyphix++) { - glyphix = 0; - while (p < text + length) - { - while (glyphix < glyphs->num_glyphs && - glyphs->log_clusters[glyphix] == charix) - { - glyphs->log_clusters[glyphix] = p - text; - glyphix++; - } - charix++; - p = g_utf8_next_char (p); - } + g_assert (glyphs->log_clusters[glyphix] < n_chars); + glyphs->log_clusters[glyphix] = byte_offset[glyphs->log_clusters[glyphix]]; } + + g_free (byte_offset); } static gboolean @@ -723,9 +707,9 @@ itemize_shape_and_place (PangoFont *font, PangoGlyphString *glyphs, SCRIPT_CACHE *script_cache) { - int item, nitems; + int i; + int item, nitems, item_step; int itemlen, glyphix, nglyphs; - int nc; SCRIPT_CONTROL control; SCRIPT_STATE state; SCRIPT_ITEM items[100]; @@ -751,8 +735,18 @@ itemize_shape_and_place (PangoFont *font, printf (G_STRLOC ": ScriptItemize: %d items\n", nitems); #endif - nc = 0; - for (item = 0; item < nitems; item++) + if (analysis->level % 2) + { + item = nitems - 1; + item_step = -1; + } + else + { + item = 0; + item_step = 1; + } + + for (i = 0; i < nitems; i++, item += item_step) { WORD iglyphs[1000]; WORD log_clusters[1000]; @@ -809,7 +803,8 @@ itemize_shape_and_place (PangoFont *font, pango_glyph_string_set_size (glyphs, ng + nglyphs); set_up_pango_log_clusters (items[item].a.fRTL, itemlen, log_clusters, - nglyphs, glyphs->log_clusters + ng, nc); + nglyphs, glyphs->log_clusters + ng, + items[item].iCharPos); if ((*script_place) (hdc, &script_cache[script], iglyphs, nglyphs, visattrs, &items[item].a, @@ -847,13 +842,12 @@ itemize_shape_and_place (PangoFont *font, glyphs->glyphs[ng+glyphix].geometry.y_offset = 0; } } - nc += itemlen; } #ifdef BASIC_WIN32_DEBUGGING if (pango_win32_debug) { - printf (" Pango log_clusters, char index:"); + printf (" Pango log_clusters (%d), char index:", analysis->level); for (glyphix = 0; glyphix < glyphs->num_glyphs; glyphix++) printf ("%d ", glyphs->log_clusters[glyphix]); printf ("\n"); @@ -915,7 +909,7 @@ uniscribe_shape (PangoFont *font, if (retval) { - convert_log_clusters_to_byte_offsets (text, length, analysis, glyphs); + convert_log_clusters_to_byte_offsets (text, length, glyphs); #ifdef BASIC_WIN32_DEBUGGING if (pango_win32_debug) { |