[pango/simple-fontmap: 8/15] Add a test for PangoHbFace getters




commit 8a17539d51a598ebf7861bf0dd78f73f46d5c102
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 31 19:48:52 2021 -0400

    Add a test for PangoHbFace getters
    
    Test that is_variable() and is_monospace() work
    as expected for PangoHbFace.

 tests/testmisc.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
---
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 75c40b0e..a8f14445 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -736,6 +736,38 @@ test_transform_rectangle (void)
   g_assert_cmpint (rect2.height, ==, rect.width);
 }
 
+static void
+test_hbfont_monospace (void)
+{
+  PangoSimpleFontMap *map;
+  PangoFontFamily *family;
+
+  map = pango_simple_font_map_new ();
+
+  if (g_file_test ("/usr/share/fonts/cantarell/Cantarell-VF.otf", G_FILE_TEST_EXISTS))
+    {
+      pango_simple_font_map_add_file (map, "/usr/share/fonts/cantarell/Cantarell-VF.otf", 0);
+
+      family = pango_font_map_get_family (PANGO_FONT_MAP (map), "Cantarell");
+
+      g_assert_nonnull (family);
+      g_assert_true (pango_font_family_is_variable (family));
+      g_assert_false (pango_font_family_is_monospace (family));
+    }
+
+  if (g_file_test ("/usr/share/fonts/dejavu-mono-sans-mono-fonts/DejaVuSansMono.ttf", G_FILE_TEST_EXISTS))
+    {
+      pango_simple_font_map_add_file (map, "/usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono.ttf", 0);
+      family = pango_font_map_get_family (PANGO_FONT_MAP (map), "DejaVu Sans Mono");
+
+      g_assert_nonnull (family);
+      g_assert_false (pango_font_family_is_variable (family));
+      g_assert_true (pango_font_family_is_monospace (family));
+    }
+
+  g_object_unref (map);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -769,6 +801,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/layout/empty-line-height", test_empty_line_height);
   g_test_add_func ("/layout/gravity-metrics", test_gravity_metrics);
   g_test_add_func ("/matrix/transform-rectangle", test_transform_rectangle);
+  g_test_add_func ("/hbfont/monospace", test_hbfont_monospace);
 
   return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]