summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-05-02 21:46:09 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-05-02 21:46:09 +0000
commit0a0e6dfabc1532f03d68c1f154956a501a3aa31d (patch)
treef40ddd1d5ec7b45976d61e1555442acb7e15a603
parente4916dc98bb89b57a6dd3b68d2b54168bb44e8fe (diff)
downloadpango-0a0e6dfabc1532f03d68c1f154956a501a3aa31d.tar.gz
Fix some incorrect edge cases for RTL text. (#102952, Padraig O'Briain)
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)
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.pre-1-106
-rw-r--r--ChangeLog.pre-1-46
-rw-r--r--ChangeLog.pre-1-66
-rw-r--r--ChangeLog.pre-1-86
-rw-r--r--pango/mapping.c58
6 files changed, 74 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index ebd35387..fde5826a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 ebd35387..fde5826a 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 ebd35387..fde5826a 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 ebd35387..fde5826a 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 ebd35387..fde5826a 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;
}
}