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:55:52 -0500
commitdb089c2f5d2e14fbfa7aeed857b9fd7a70a1cc7e (patch)
tree26195bd5a0dba22d85a21018291b17c5ad2e8640
parent645ed4e538c29dd5e0f4f5d9295564dd71eff5ab (diff)
downloadpango-fix-char-offset.tar.gz
Fix char offset calculationsfix-char-offset
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
-rw-r--r--pango/pango-layout.c2
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;