[pango/more-rtl-cluster-fixes] layout: Use pango_glyph_string_x_to_index_full



commit c9acf65558fddb05d32d29a535cb3ab2fd5f49c0
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 28 19:22:05 2021 -0400

    layout: Use pango_glyph_string_x_to_index_full

 pango/pango-layout.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index c82a24c4..32e94e13 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -4869,12 +4869,20 @@ pango_layout_line_x_to_index (PangoLayoutLine *line,
           int grapheme_end_offset;
           int pos;
           int char_index;
+          int attr_offset;
 
-          pango_glyph_string_x_to_index (run->glyphs,
-                                         layout->text + run->item->offset, run->item->length,
-                                         &run->item->analysis,
-                                         x_pos - start_pos,
-                                         &pos, &char_trailing);
+          /* Note: we simply assert here, since our items are all internally
+           * created. If that ever changes, we need to add a fallback here.
+           */
+          g_assert (run->item->analysis.flags & PANGO_ANALYSIS_FLAG_HAS_CHAR_OFFSET);
+          attr_offset = ((PangoItemPrivate *)run->item)->char_offset;
+
+          pango_glyph_string_x_to_index_full (run->glyphs,
+                                              layout->text + run->item->offset, run->item->length,
+                                              &run->item->analysis,
+                                              layout->log_attrs + attr_offset,
+                                              x_pos - start_pos,
+                                              &pos, &char_trailing);
 
           char_index = run->item->offset + pos;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]