diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 6 | ||||
-rw-r--r-- | pango/mapping.c | 58 |
6 files changed, 74 insertions, 14 deletions
@@ -1,3 +1,9 @@ +Fri May 2 17:20:23 2003 Owen Taylor <otaylor@redhat.com> + + * pango/mapping.c (pango_glyph_string_x_to_index): + Fix some incorrect edge cases for RTL text. + (#102952, Padraig O'Briain) + Fri May 2 14:21:20 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (update_run): Fix a harmless diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 7ac971cb..6bdfd7e0 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,9 @@ +Fri May 2 17:20:23 2003 Owen Taylor <otaylor@redhat.com> + + * pango/mapping.c (pango_glyph_string_x_to_index): + Fix some incorrect edge cases for RTL text. + (#102952, Padraig O'Briain) + Fri May 2 14:21:20 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (update_run): Fix a harmless diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 7ac971cb..6bdfd7e0 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,9 @@ +Fri May 2 17:20:23 2003 Owen Taylor <otaylor@redhat.com> + + * pango/mapping.c (pango_glyph_string_x_to_index): + Fix some incorrect edge cases for RTL text. + (#102952, Padraig O'Briain) + Fri May 2 14:21:20 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (update_run): Fix a harmless diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 7ac971cb..6bdfd7e0 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,9 @@ +Fri May 2 17:20:23 2003 Owen Taylor <otaylor@redhat.com> + + * pango/mapping.c (pango_glyph_string_x_to_index): + Fix some incorrect edge cases for RTL text. + (#102952, Padraig O'Briain) + Fri May 2 14:21:20 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (update_run): Fix a harmless diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 7ac971cb..6bdfd7e0 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,9 @@ +Fri May 2 17:20:23 2003 Owen Taylor <otaylor@redhat.com> + + * pango/mapping.c (pango_glyph_string_x_to_index): + Fix some incorrect edge cases for RTL text. + (#102952, Padraig O'Briain) + Fri May 2 14:21:20 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (update_run): Fix a harmless diff --git a/pango/mapping.c b/pango/mapping.c index f25dd9aa..c1672519 100644 --- a/pango/mapping.c +++ b/pango/mapping.c @@ -275,23 +275,53 @@ pango_glyph_string_x_to_index (PangoGlyphString *glyphs, } else { - double cp = ((double)(x_pos - start_xpos) * cluster_chars) / (end_xpos - start_xpos); - - if (index) + double cp = ((double)(x_pos - start_xpos) * cluster_chars) / (end_xpos - start_xpos); + + /* LTR and right-to-left have to be handled separately + * here because of the edge condition when we are exactly + * at a pixel boundary; end_xpos goes with the next + * character for LTR, with the previous character for RTL. + */ + if (start_xpos < end_xpos) /* Left-to-right */ { - char *p = text + start_index; - int i = 0; - - while (i + 1 <= cp) + if (index) { - p = g_utf8_next_char (p); - i++; + char *p = text + start_index; + int i = 0; + + while (i + 1 <= cp) + { + p = g_utf8_next_char (p); + i++; + } + + *index = (p - text); + } + + if (trailing) + *trailing = (cp - (int)cp >= 0.5) ? 1 : 0; + } + else /* Right-to-left */ + { + if (index) + { + char *p = text + start_index; + int i = 0; + + while (i + 1 < cp) + { + p = g_utf8_next_char (p); + i++; + } + + *index = (p - text); + } + + if (trailing) + { + double cp_flip = cluster_chars - cp; + *trailing = (cp_flip - (int)cp_flip >= 0.5) ? 0 : 1; } - - *index = (p - text); } - - if (trailing) - *trailing = (cp - (int)cp > 0.5) ? 1 : 0; } } |