summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-06 21:36:05 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-11-07 09:59:09 -0500
commit0eec5fab2af80e43c9141ffc21c523be6415f0a8 (patch)
tree8a8aa7eed922d23fd647d2b6a3f1debb85b00205
parent397f121f76ddbca646610976a5c03d7a74aedd2e (diff)
downloadpango-0eec5fab2af80e43c9141ffc21c523be6415f0a8.tar.gz
Add variant roundtrip tests
Test some more tests for roundtripping casing variants from font description to font and back.
-rw-r--r--tests/test-font.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/tests/test-font.c b/tests/test-font.c
index cd243a95..bfe321a0 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -294,27 +294,65 @@ test_roundtrip_small_caps (void)
return;
}
- desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
-
- g_assert_true (pango_font_description_get_variant (desc) == PANGO_VARIANT_SMALL_CAPS);
-
fontmap = pango_cairo_font_map_get_default ();
context = pango_font_map_create_context (fontmap);
+ desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
+ g_assert_true (pango_font_description_get_variant (desc) == PANGO_VARIANT_SMALL_CAPS);
+
font = pango_context_load_font (context, desc);
desc2 = pango_font_describe (font);
+ num = 0;
pango_font_get_features (font, features, G_N_ELEMENTS (features), &num);
g_assert_true (num == 1);
g_assert_true (features[0].tag == HB_TAG ('s', 'm', 'c', 'p'));
g_assert_true (features[0].value == 1);
g_assert_true (pango_font_description_get_variant (desc2) == PANGO_VARIANT_SMALL_CAPS);
+ g_assert_true (pango_font_description_equal (desc2, desc));
+ pango_font_description_free (desc2);
+ g_object_unref (font);
+ pango_font_description_free (desc);
+
+ desc = pango_font_description_from_string ("Cantarell All-Small-Caps 11");
+ g_assert_true (pango_font_description_get_variant (desc) == PANGO_VARIANT_ALL_SMALL_CAPS);
+
+ font = pango_context_load_font (context, desc);
+ desc2 = pango_font_describe (font);
+
+ num = 0;
+ pango_font_get_features (font, features, G_N_ELEMENTS (features), &num);
+ g_assert_true (num == 2);
+ g_assert_true (features[0].tag == HB_TAG ('s', 'm', 'c', 'p'));
+ g_assert_true (features[0].value == 1);
+ g_assert_true (features[1].tag == HB_TAG ('c', '2', 's', 'c'));
+ g_assert_true (features[1].value == 1);
+ g_assert_true (pango_font_description_get_variant (desc2) == PANGO_VARIANT_ALL_SMALL_CAPS);
+ g_assert_true (pango_font_description_equal (desc2, desc));
+
+ pango_font_description_free (desc2);
+ g_object_unref (font);
+ pango_font_description_free (desc);
+
+ desc = pango_font_description_from_string ("Cantarell Unicase 11");
+ g_assert_true (pango_font_description_get_variant (desc) == PANGO_VARIANT_UNICASE);
+
+ font = pango_context_load_font (context, desc);
+ desc2 = pango_font_describe (font);
+
+ num = 0;
+ pango_font_get_features (font, features, G_N_ELEMENTS (features), &num);
+ g_assert_true (num == 1);
+ g_assert_true (features[0].tag == HB_TAG ('u', 'n', 'i', 'c'));
+ g_assert_true (features[0].value == 1);
+ g_assert_true (pango_font_description_get_variant (desc2) == PANGO_VARIANT_UNICASE);
g_assert_true (pango_font_description_equal (desc2, desc));
pango_font_description_free (desc2);
g_object_unref (font);
pango_font_description_free (desc);
+
g_object_unref (context);
}