summaryrefslogtreecommitdiff
path: root/pango/pango-item.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-11 11:31:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-07-11 15:19:17 -0400
commit4315d4f49b054e8d322fe87845bc3843f7523835 (patch)
tree5f4f544542319d1126ea58b80d3b8f3a4938aed0 /pango/pango-item.c
parente445b8978ea73ab60f5462af4403987d73300a1f (diff)
downloadpango-4315d4f49b054e8d322fe87845bc3843f7523835.tar.gz
Add pango_item_apply_attrs
This adds attrs that are overlapping the range of the item to the extra_attrs in the analysis.
Diffstat (limited to 'pango/pango-item.c')
-rw-r--r--pango/pango-item.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/pango/pango-item.c b/pango/pango-item.c
index 8c368874..787fb65e 100644
--- a/pango/pango-item.c
+++ b/pango/pango-item.c
@@ -153,3 +153,48 @@ pango_item_split (PangoItem *orig,
return new_item;
}
+
+static int
+compare_attr (gconstpointer p1, gconstpointer p2)
+{
+ if (pango_attribute_equal ((PangoAttribute *)p1, (PangoAttribute *)p2))
+ return 0;
+
+ return 1;
+}
+
+void
+pango_item_apply_attrs (PangoItem *item,
+ PangoAttrIterator *iter)
+{
+ int start, end;
+ GSList *attrs = NULL;
+
+ do
+ {
+ pango_attr_iterator_range (iter, &start, &end);
+
+ if (start >= item->offset + item->length)
+ break;
+
+ if (end >= item->offset)
+ {
+ GSList *list, *l;
+
+ list = pango_attr_iterator_get_attrs (iter);
+ for (l = list; l; l = l->next)
+ {
+ if (!g_slist_find_custom (attrs, l->data, compare_attr))
+
+ attrs = g_slist_prepend (attrs, pango_attribute_copy (l->data));
+ }
+ g_slist_free_full (list, (GDestroyNotify)pango_attribute_destroy);
+ }
+
+ if (end >= item->offset + item->length)
+ break;
+ }
+ while (pango_attr_iterator_next (iter));
+
+ item->analysis.extra_attrs = g_slist_concat (item->analysis.extra_attrs, attrs);
+}