diff options
-rw-r--r-- | pango/pango-item.c | 45 | ||||
-rw-r--r-- | pango/pango-item.h | 4 |
2 files changed, 49 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); +} diff --git a/pango/pango-item.h b/pango/pango-item.h index cb6a7ed3..2d7e58a1 100644 --- a/pango/pango-item.h +++ b/pango/pango-item.h @@ -23,6 +23,7 @@ #define __PANGO_ITEM_H__ #include <pango/pango-types.h> +#include <pango/pango-attributes.h> G_BEGIN_DECLS @@ -112,6 +113,9 @@ PANGO_AVAILABLE_IN_ALL PangoItem *pango_item_split (PangoItem *orig, int split_index, int split_offset); +PANGO_AVAILABLE_IN_1_44 +void pango_item_apply_attrs (PangoItem *item, + PangoAttrIterator *iter); G_END_DECLS |