diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-07-24 15:52:26 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-07-24 16:10:05 -0400 |
commit | 23aca088a2c0beff648f83c9909e45ee01c597b8 (patch) | |
tree | 0a73b2ab9e5f967f80af954e36e6131ad9f0c494 /tests/test-itemize.c | |
parent | 8ce63f0865090a33713c87c690b5609ce13e156c (diff) | |
download | pango-23aca088a2c0beff648f83c9909e45ee01c597b8.tar.gz |
test-itemize: Match PangoLayout
Use the same logic as PangoLayout for
filtering attributes.
Update expected output to match.
Diffstat (limited to 'tests/test-itemize.c')
-rw-r--r-- | tests/test-itemize.c | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/tests/test-itemize.c b/tests/test-itemize.c index 8ddf2ec9..d66c40d1 100644 --- a/tests/test-itemize.c +++ b/tests/test-itemize.c @@ -51,6 +51,59 @@ append_text (GString *s, } } +static gboolean +affects_itemization (PangoAttribute *attr, + gpointer data) +{ + switch (attr->klass->type) + { + /* These affect font selection */ + case PANGO_ATTR_LANGUAGE: + case PANGO_ATTR_FAMILY: + case PANGO_ATTR_STYLE: + case PANGO_ATTR_WEIGHT: + case PANGO_ATTR_VARIANT: + case PANGO_ATTR_STRETCH: + case PANGO_ATTR_SIZE: + case PANGO_ATTR_FONT_DESC: + case PANGO_ATTR_SCALE: + case PANGO_ATTR_FALLBACK: + case PANGO_ATTR_ABSOLUTE_SIZE: + case PANGO_ATTR_GRAVITY: + case PANGO_ATTR_GRAVITY_HINT: + /* These are part of ItemProperties, so need to break runs */ + case PANGO_ATTR_SHAPE: + case PANGO_ATTR_RISE: + case PANGO_ATTR_UNDERLINE: + case PANGO_ATTR_STRIKETHROUGH: + case PANGO_ATTR_LETTER_SPACING: + return TRUE; + default: + return FALSE; + } +} + +static void +apply_attributes_to_items (GList *items, + PangoAttrList *attrs) +{ + GList *l; + PangoAttrIterator *iter; + + if (!attrs) + return; + + iter = pango_attr_list_get_iterator (attrs); + + for (l = items; l; l = l->next) + { + PangoItem *item = l->data; + pango_item_apply_attrs (item, iter); + } + + pango_attr_iterator_destroy (iter); +} + static void test_file (const gchar *filename, GString *string) { @@ -61,6 +114,7 @@ test_file (const gchar *filename, GString *string) char *test; char *text; PangoAttrList *attrs; + PangoAttrList *itemize_attrs; GList *items, *l; const char *sep = ""; @@ -96,7 +150,11 @@ test_file (const gchar *filename, GString *string) if (text[length - 1] == '\n') length--; - items = pango_itemize (context, text, 0, length, attrs, NULL); + itemize_attrs = pango_attr_list_filter (attrs, affects_itemization, NULL); + items = pango_itemize (context, text, 0, length, itemize_attrs, NULL); + + apply_attributes_to_items (items, attrs); + pango_attr_list_unref (itemize_attrs); for (l = items; l; l = l->next) { |