[pango/simple-fontmap: 5/9] Add a PangoFcHbFontMap test




commit dbbe827e3052d2577bd693b9bb517bc757d77c2b
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Dec 28 09:35:44 2021 -0500

    Add a PangoFcHbFontMap test

 tests/testhbfont.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
---
diff --git a/tests/testhbfont.c b/tests/testhbfont.c
index 8c956b65..971de287 100644
--- a/tests/testhbfont.c
+++ b/tests/testhbfont.c
@@ -22,6 +22,7 @@
 #include "config.h"
 #include <glib.h>
 #include <pango/pangocairo.h>
+#include <pango/pangofc-hbfontmap.h>
 
 #ifdef HAVE_CAIRO_FREETYPE
 #include <pango/pango-ot.h>
@@ -222,6 +223,39 @@ test_hbfont_describe (void)
   g_free (path);
 }
 
+/* Verify that pango_fontmap_load_fontset produces a non-empty result
+ * even if the language isn't covered - our itemization code relies
+ * on this.
+ */
+static void
+test_hbfont_language (void)
+{
+  PangoFontMap *map;
+  PangoContext *context;
+  PangoFontDescription *desc;
+  PangoFontset *fonts;
+  gboolean found;
+
+  map = PANGO_FONT_MAP (pango_fc_hb_font_map_new ());
+  context = pango_font_map_create_context (map);
+  desc = pango_font_description_from_string ("serif 11");
+
+  /* zz isn't assigned, so there should not be any fonts claiming to support
+   * this language. We are expecting to get a nonempty fontset regardless.
+   */
+  fonts = pango_font_map_load_fontset (map, context, desc, pango_language_from_string ("zz"));
+  g_assert_true (PANGO_IS_FONTSET (fonts));
+
+  found = FALSE;
+  pango_fontset_foreach (fonts, get_font, &found);
+  g_assert_true (found);
+
+  g_object_unref (fonts);
+  pango_font_description_free (desc);
+  g_object_unref (context);
+  g_object_unref (map);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -231,6 +265,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/hbface/roundtrip", test_hbface_roundtrip);
   g_test_add_func ("/hbfont/roundtrip", test_hbfont_roundtrip);
   g_test_add_func ("/hbfont/describe", test_hbfont_describe);
+  g_test_add_func ("/hbfont/language", test_hbfont_language);
 
   return g_test_run ();
 }


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