From dd21621c1bba8121151c6828abbb68ef403c7d76 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 1 Sep 2021 12:52:48 -0400 Subject: Be more forgiving about attribute ordering We don't really have firm control over the way attributes are ordered in the list, so the assumtion that we see proper nesting for baseline shifts was a bit optimistic. Just look through all open stack items for a match, and remove that. Test included. --- pango/pango-layout.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'pango/pango-layout.c') diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 098e3a3e..21e2c9c6 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -6248,20 +6248,26 @@ collect_baseline_shift (ParaBreakState *state, if (attr->end_index == item->offset + item->length) { - BaselineItem *entry = state->baseline_shifts->data; + GList *t; - if (attr->start_index == entry->attr->start_index && - attr->end_index == entry->attr->end_index && - ((PangoAttrInt *)attr)->value == ((PangoAttrInt *)entry->attr)->value) + for (t = state->baseline_shifts; t; t = t->next) { - *end_x_offset -= entry->x_offset; - *end_y_offset -= entry->y_offset; + BaselineItem *entry = t->data; + + if (attr->start_index == entry->attr->start_index && + attr->end_index == entry->attr->end_index && + ((PangoAttrInt *)attr)->value == ((PangoAttrInt *)entry->attr)->value) + { + *end_x_offset -= entry->x_offset; + *end_y_offset -= entry->y_offset; + } + + state->baseline_shifts = g_list_remove (state->baseline_shifts, entry); + g_free (entry); + break; } - else + if (t == NULL) g_warning ("Baseline attributes mismatch\n"); - - state->baseline_shifts = g_list_remove (state->baseline_shifts, entry); - g_free (entry); } } } -- cgit v1.2.1