[pango/pango2: 55/115] test-layout: port to PangoFcHbFontMap




commit d1f99b8086756e72df71332952f95529409bf23c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 13 09:12:28 2022 -0400

    test-layout: port to PangoFcHbFontMap

 tests/test-layout.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
---
diff --git a/tests/test-layout.c b/tests/test-layout.c
index f440952b..5c9a466d 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -30,8 +30,10 @@
 #include "config.h"
 #include <pango/pangocairo.h>
 #include <pango/pangocairo-fc.h>
+#include <pango/pangofc-hbfontmap.h>
 #include "test-common.h"
 
+static PangoFontMap *map = NULL;
 
 static void
 test_layout (gconstpointer d)
@@ -46,12 +48,6 @@ test_layout (gconstpointer d)
   PangoContext *context;
   PangoLayout *layout;
 
-  if (!PANGO_FC_IS_FONT_MAP (pango_cairo_font_map_get_default ()))
-    {
-      g_test_skip ("Not an fc fontmap. Skipping...");
-      return;
-    }
-
   char *old_locale = g_strdup (setlocale (LC_ALL, NULL));
   setlocale (LC_ALL, "en_US.UTF-8");
   if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL)
@@ -67,7 +63,7 @@ test_layout (gconstpointer d)
   g_assert_no_error (error);
   orig = g_bytes_new_take (contents, length);
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (map);
   layout = pango_layout_deserialize (context, orig, PANGO_LAYOUT_DESERIALIZE_CONTEXT, &error);
   g_assert_no_error (error);
 
@@ -108,13 +104,10 @@ static void
 install_fonts (const char *dir)
 {
   FcConfig *config;
-  PangoFontMap *map;
   char *path;
   gsize len;
   char *conf;
 
-  map = g_object_new (PANGO_TYPE_CAIRO_FC_FONT_MAP, NULL);
-
   config = FcConfigCreate ();
 
   path = g_build_filename (dir, "fonts.conf", NULL);
@@ -127,12 +120,10 @@ install_fonts (const char *dir)
   g_free (path);
 
   FcConfigAppFontAddDir (config, (const FcChar8 *) dir);
-  pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (map), config);
-  FcConfigDestroy (config);
 
-  pango_cairo_font_map_set_default (PANGO_CAIRO_FONT_MAP (map));
+  map = PANGO_FONT_MAP (pango_fc_hb_font_map_new (config));
 
-  g_object_unref (map);
+  FcConfigDestroy (config);
 }
 
 int
@@ -180,7 +171,7 @@ main (int argc, char *argv[])
       g_file_get_contents (argv[1], &contents, &length, &error);
       g_assert_no_error (error);
       orig = g_bytes_new_take (contents, length);
-      context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+      context = pango_font_map_create_context (map);
       layout = pango_layout_deserialize (context, orig, PANGO_LAYOUT_DESERIALIZE_CONTEXT, &error);
       g_assert_no_error (error);
 


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