diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-11-08 13:47:52 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-11-08 13:47:52 +0000 |
commit | 78d4efd6af8fc37b93b1dafb7c3b7101b389a565 (patch) | |
tree | 857deeac1c70f10038c2e967d0238f1845964533 /tests/test-font.c | |
parent | 9d389e936707ebcf84fbc64d07b8aa17cdf2ef04 (diff) | |
parent | 1790dbf9da8a4249528833ead1af32d232861b64 (diff) | |
download | pango-78d4efd6af8fc37b93b1dafb7c3b7101b389a565.tar.gz |
Merge branch 'small-caps' into 'main'
Emulate Small Caps if not available from the font
See merge request GNOME/pango!497
Diffstat (limited to 'tests/test-font.c')
-rw-r--r-- | tests/test-font.c | 46 |
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); } |