diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-11-18 20:58:12 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-11-18 20:58:12 +0000 |
commit | 169e4c0deedc111f2bc26b4fc5479d3af24260c2 (patch) | |
tree | 26195bd5a0dba22d85a21018291b17c5ad2e8640 | |
parent | 645ed4e538c29dd5e0f4f5d9295564dd71eff5ab (diff) | |
parent | db089c2f5d2e14fbfa7aeed857b9fd7a70a1cc7e (diff) | |
download | pango-169e4c0deedc111f2bc26b4fc5479d3af24260c2.tar.gz |
Merge branch 'fix-char-offset' into 'main'
Fix char offset calculations
Closes #716
See merge request GNOME/pango!658
-rw-r--r-- | pango/itemize.c | 12 | ||||
-rw-r--r-- | pango/pango-layout.c | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/pango/itemize.c b/pango/itemize.c index cf9d6a8f..35f17d54 100644 --- a/pango/itemize.c +++ b/pango/itemize.c @@ -1495,13 +1495,14 @@ handle_variants (const char *text, static GList * reorder_items (PangoContext *context, - GList *items) + GList *items, + int initial_offset) { - int char_offset = 0; + int char_offset = initial_offset; items = g_list_reverse (items); - /* Also cmpute the char offset for each item here */ + /* Also compute the char offset for each item here */ for (GList *l = items; l; l = l->next) { PangoItemPrivate *item = l->data; @@ -1544,6 +1545,7 @@ pango_itemize_with_font (PangoContext *context, const PangoFontDescription *desc) { ItemizeState state; + int initial_offset; g_return_val_if_fail (context->font_map != NULL, NULL); @@ -1559,7 +1561,9 @@ pango_itemize_with_font (PangoContext *context, itemize_state_finish (&state); - return reorder_items (context, state.result); + initial_offset = g_utf8_strlen (text, start_index); + + return reorder_items (context, state.result, initial_offset); } /* Apply post-processing steps that may require log attrs. diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 306741b5..54271387 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -4913,7 +4913,7 @@ pango_layout_check_lines (PangoLayout *layout) state.items = pango_itemize_post_process_items (layout->context, layout->text, - layout->log_attrs + start_offset, + layout->log_attrs, state.items); state.base_dir = base_dir; |