After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 355550 - Miscalculation of logical attributes in pango_get_log_attrs()
Miscalculation of logical attributes in pango_get_log_attrs()
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.14.x
Other All
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2006-09-12 08:14 UTC by Theppitak Karoonboonyanan
Modified: 2006-09-13 22:06 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
Proposed patch (905 bytes, patch)
2006-09-12 08:17 UTC, Theppitak Karoonboonyanan
committed Details | Review

Description Theppitak Karoonboonyanan 2006-09-12 08:14:19 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/
Comment 1 Theppitak Karoonboonyanan 2006-09-12 08:17:22 UTC
Created attachment 72588 [details] [review]
Proposed patch

This patch fixes the loop sequence by assigning analysis.lang_engine _after_ pango_break() call.
Comment 2 Behdad Esfahbod 2006-09-12 17:44:15 UTC
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.
Comment 3 Behdad Esfahbod 2006-09-13 22:06:40 UTC
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().