[pango/simple-fontmap: 14/16] testmisc: Add another test




commit 243f4219355e132e4a2a58b8e6dd132ed2be793e
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Dec 25 21:40:17 2021 -0500

    testmisc: Add another test

 tests/testhbfont.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/testmisc.c   |  1 +
 2 files changed, 53 insertions(+)
---
diff --git a/tests/testhbfont.c b/tests/testhbfont.c
index 1838d13a..f590db3a 100644
--- a/tests/testhbfont.c
+++ b/tests/testhbfont.c
@@ -185,6 +185,57 @@ test_hbfont_roundtrip (void)
   g_free (path);
 }
 
+static gboolean
+get_font (PangoFontset *fonts,
+          PangoFont    *font,
+          gpointer      data)
+{
+  gboolean *found = data;
+
+  PangoFontDescription *desc = pango_font_describe (font);
+  char *s = pango_font_description_to_string (desc);
+  g_print ("%s\n", s);
+  g_free (s);
+  pango_font_description_free (desc);
+
+  *found = TRUE;
+
+  return FALSE;
+}
+
+/* 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_font_map2_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[])
 {
@@ -194,6 +245,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/hbfont/monospace", test_hbfont_monospace);
   g_test_add_func ("/hbface/roundtrip", test_hbface_roundtrip);
   g_test_add_func ("/hbfont/roundtrip", test_hbfont_roundtrip);
+  g_test_add_func ("/hbfont/language", test_hbfont_language);
 
   return g_test_run ();
 }
diff --git a/tests/testmisc.c b/tests/testmisc.c
index e708d1bb..87235886 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -22,6 +22,7 @@
 #include "config.h"
 #include <glib.h>
 #include <pango/pangocairo.h>
+#include <pango/pangofc-fontmap2.h>
 
 #ifdef HAVE_CAIRO_FREETYPE
 #include <pango/pango-ot.h>


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