[pango/small-caps: 5/6] Add variant roundtrip tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/small-caps: 5/6] Add variant roundtrip tests
- Date: Sun, 7 Nov 2021 14:22:44 +0000 (UTC)
commit 99028507809e6e24fdb65de6c0f36410b1964f02
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Nov 6 21:36:05 2021 -0400
Add variant roundtrip tests
Test some more tests for roundtripping
casing variants from font description to
font and back.
tests/test-font.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
1 file 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]