summaryrefslogtreecommitdiff
path: root/pango/pango-layout.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-09-01 12:52:48 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-09-01 17:19:30 -0400
commitdd21621c1bba8121151c6828abbb68ef403c7d76 (patch)
tree6d201fcb3feca60159217e04d57ac54cd4aec5b7 /pango/pango-layout.c
parent6b7d85480653f83c5f5605bf99582d04d721fbb5 (diff)
downloadpango-dd21621c1bba8121151c6828abbb68ef403c7d76.tar.gz
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.
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r--pango/pango-layout.c26
1 files changed, 16 insertions, 10 deletions
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);
}
}
}