From 0fe04e52998cc7328f8f981a3d366e6d6540f8fb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 28 Aug 2021 19:22:05 -0400 Subject: 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 d3d93e60..b2fd5f97 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; -- cgit v1.2.1