GNOME Bugzilla – Bug 355550
Miscalculation of logical attributes in pango_get_log_attrs()
Last modified: 2006-09-13 22:06:40 UTC
Symptom: With pango-libthai engine [1] installed, and Bug #355435 fixed, GtkTextView now moves caret word-wise properly through Thai text, but only for the last chunk after the last space. For the text before that, it still moves as if the text were English (that is, words are delimited by spaces). Note that there is no such error in GtkEntry. Cause: GtkTextView relies on pango_get_log_attrs() when getting logical attributes. But a loop within the function just takes the engine from next range to calculate current range: > while (pos != end) > { > ... > script = pango_script_for_unichar (g_utf8_get_char (pos)); > analysis.lang_engine = > (PangoEngineLang*) pango_map_get_engine (lang_map, script); > > if (range_engine != analysis.lang_engine) > { > /* Engine has changed; do the breaking for the current range, > * then start a new range. > */ > pango_break (range_start, > pos - range_start, > &analysis, > log_attrs + chars_broken, > attrs_len - chars_broken); Here, analysis.lang_engine already holds the engine for the next range. So, it breaks previous range with a different engine. > ... > range_engine = analysis.lang_engine; > ... > } > ... > > pos = g_utf8_next_char (pos); > } [1] http://libthai.sourceforge.net/
Created attachment 72588 [details] [review] Proposed patch This patch fixes the loop sequence by assigning analysis.lang_engine _after_ pango_break() call.
Thanks Thep. This morning I was writing an Arabic language engine and that didn't work. I think I've been hitting the same bug :). Will look into it shortly.
2006-09-13 Behdad Esfahbod <behdad@gnome.org> Bug 355550 – Miscalculation of logical attributes in pango_get_log_attrs() Patch from Theppitak Karoonboonyanan * pango/break.c (pango_get_log_attrs): Pass the correct lang_engine to pango_break().