summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-11-18 14:02:17 -0500
committerMatthias Clasen <mclasen@redhat.com>2022-11-18 14:02:17 -0500
commitd6527dd41616e32a224d70cd0a531940ea38b82d (patch)
tree0a783e5798ad46f098c8d71c7885c4e44cfe823b
parent29a72d39debea8f84eada42914aaa7d78b9d9fdc (diff)
downloadpango-fix-char-offsets.tar.gz
Fix char offset calculationsfix-char-offsets
When dealing with multi-paragraph layouts, the char offsets of the items are expected to be relative to the beginning of the text, not relative to the beginning of the current paragraph. This error was introduced in a03bf5bc6b07ba6e. Fixes: #716
-rw-r--r--pango/itemize.c12
1 files changed, 8 insertions, 4 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.