summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-24 15:52:26 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-07-24 16:10:05 -0400
commit23aca088a2c0beff648f83c9909e45ee01c597b8 (patch)
tree0a73b2ab9e5f967f80af954e36e6131ad9f0c494 /tests
parent8ce63f0865090a33713c87c690b5609ce13e156c (diff)
downloadpango-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')
-rw-r--r--tests/itemize/two.expected12
-rw-r--r--tests/test-itemize.c60
2 files changed, 65 insertions, 7 deletions
diff --git a/tests/itemize/two.expected b/tests/itemize/two.expected
index 57446958..ebe9757c 100644
--- a/tests/itemize/two.expected
+++ b/tests/itemize/two.expected
@@ -1,8 +1,8 @@
<span font="Cantarell 11">one <span font_features="tnum=0">tw<u>o</u> <span font_features="dlig=1">two</span> </span>th<b>r</b>ee</span>
-Items: one |tw |o | |two | |th |r |ee
-Font: Cantarell 11|Cantarell 11 |Cantarell 11 |Cantarell 11 |Cantarell 11 |Cantarell 11 |Cantarell 11|Cantarell Bold 11|Cantarell 11
-Script: latin |latin |latin |latin |latin |latin |latin |latin |latin
-Lang: en-us |en-us |en-us |en-us |en-us |en-us |en-us |en-us |en-us
-Bidi: 0 |0 |0 |0 |0 |0 |0 |0 |0
-Attrs: |[4,12]font-features=tnum=0|[4,12]font-features=tnum=0,[6,7]underline=1|[4,12]font-features=tnum=0|[4,12]font-features=tnum=0,[8,11]font-features=dlig=1|[4,12]font-features=tnum=0| | |
+Items: one tw |o | two th |r |ee
+Font: Cantarell 11 |Cantarell 11 |Cantarell 11 |Cantarell Bold 11|Cantarell 11
+Script: latin |latin |latin |latin |latin
+Lang: en-us |en-us |en-us |en-us |en-us
+Bidi: 0 |0 |0 |0 |0
+Attrs: [4,12]font-features=tnum=0|[6,7]underline=1,[4,12]font-features=tnum=0|[8,11]font-features=dlig=1,[4,12]font-features=tnum=0| |
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)
{