[pango/pango2: 68/118] Add default fontmap API




commit 9b278403e95ec02bf81b1c65a061eb9caeaba604
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 10 20:51:20 2022 -0400

    Add default fontmap API
    
    Now that all our fontmaps handle the same kinds
    of fonts, we can make the default fontmap a
    frontend api, and not longer cairo-specific.

 examples/columns.c              |   2 +-
 examples/parshape.c             |   2 +-
 pango/meson.build               |   1 -
 pango/pango-fontmap.c           | 138 +++++++++++++++++++++
 pango/pango-fontmap.h           |   7 ++
 pango/pangocairo-context.c      |   2 +-
 pango/pangocairo-fontmap.c      | 265 ----------------------------------------
 pango/pangocairo-private.h      |  17 ---
 pango/pangocairo.h              |  44 -------
 tests/test-bidi.c               |   3 +-
 tests/test-ellipsize.c          |   3 +-
 tests/test-font.c               |  18 +--
 tests/test-harfbuzz.c           |  33 ++---
 tests/test-itemize.c            |   4 +-
 tests/test-pangocairo-threads.c |   2 +-
 tests/testiter.c                |   6 +-
 tests/testmisc.c                |  40 +++---
 tests/testrandom.c              |   6 +-
 utils/pango-list.c              |   5 +-
 utils/pango-segmentation.c      |   4 +-
 utils/viewer-pangocairo.c       |   7 +-
 21 files changed, 212 insertions(+), 397 deletions(-)
---
diff --git a/examples/columns.c b/examples/columns.c
index a8a21c784..7f76335cb 100644
--- a/examples/columns.c
+++ b/examples/columns.c
@@ -33,7 +33,7 @@ main (int argc, char *argv[])
 
   filename = argv[2];
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
 
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 600, 600);
   cr = cairo_create (surface);
diff --git a/examples/parshape.c b/examples/parshape.c
index da4b5516f..e33f9600f 100644
--- a/examples/parshape.c
+++ b/examples/parshape.c
@@ -30,7 +30,7 @@ main (int argc, char *argv[])
 
   filename = argv[2];
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
 
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 400, 600);
   cr = cairo_create (surface);
diff --git a/pango/meson.build b/pango/meson.build
index b4050885b..33b518717 100644
--- a/pango/meson.build
+++ b/pango/meson.build
@@ -106,7 +106,6 @@ if cairo_dep.found()
   pango_sources += [
     'pangocairo-context.c',
     'pangocairo-font.c',
-    'pangocairo-fontmap.c',
     'pangocairo-render.c',
   ]
 
diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c
index 1f0a0b7fc..d05c65bca 100644
--- a/pango/pango-fontmap.c
+++ b/pango/pango-fontmap.c
@@ -955,6 +955,144 @@ pango_font_map_set_resolution (PangoFontMap *self,
   pango_font_map_changed (self);
 }
 
+/* }}} */
+/* {{{ Default handling */
+
+static GPrivate default_font_map = G_PRIVATE_INIT (g_object_unref); /* MT-safe */
+
+/**
+ * pango_font_map_new_default:
+ *
+ * Creates a new `PangoFontMap` object.
+ *
+ * A fontmap is used to cache information about available fonts,
+ * and holds certain global parameters such as the resolution.
+ * In most cases, you can use `func@Pango.font_map_get_default]
+ * instead.
+ *
+ * Note that the type of the returned object will depend
+ * on the platform that Pango is used on. If you want to
+ * explicitly create an instance of `PangoFontMap` itself
+ * (and not a platform-specific subclass), see [ctor Pango FontMap new].
+ *
+ * You can override the type of backend returned by using an
+ * environment variable %PANGOCAIRO_BACKEND. Supported types,
+ * based on your build, are fontconfig, win32, and coretext.
+ *
+ * If requested type is not available, `NULL` is returned.
+ * This is only useful for testing, when at least two backends
+ * are compiled in.
+ *
+ * Return value: (transfer full): the newly allocated `PangoFontMap`,
+ *   which should be freed with g_object_unref().
+ */
+PangoFontMap *
+pango_font_map_new_default (void)
+{
+  const char *backend;
+
+  backend = getenv ("PANGOCAIRO_BACKEND");
+  if (backend && !*backend)
+    backend = NULL;
+
+#if defined (HAVE_CORE_TEXT) && defined (HAVE_CAIRO_QUARTZ)
+  if (!backend || 0 == strcmp (backend, "coretext"))
+    return PANGO_FONT_MAP (pango_core_text_font_map_new ());
+#endif
+
+#if defined (HAVE_CAIRO_WIN32)
+  if (!backend || 0 == strcmp (backend, "win32"))
+    return PANGO_FONT_MAP (pango_direct_write_font_map_new ());
+#endif
+
+#if defined (HAVE_CAIRO_FREETYPE)
+  if (!backend || 0 == strcmp (backend, "fc")
+               || 0 == strcmp (backend, "fontconfig"))
+    return PANGO_FONT_MAP (pango_fc_font_map_new ());
+#endif
+
+  {
+    const char backends[] = ""
+#if defined (HAVE_CORE_TEXT) && defined (HAVE_CAIRO_QUARTZ)
+      " coretext"
+#endif
+#if defined (HAVE_CAIRO_WIN32)
+      " win32"
+#endif
+#if defined (HAVE_CAIRO_FREETYPE)
+      " fontconfig"
+#endif
+      ;
+
+    g_critical ("Unknown PANGOCAIRO_BACKEND value.\n"
+                "Available backends are:%s", backends);
+  }
+
+  return NULL;
+}
+
+/**
+ * pango_font_map_get_default:
+ *
+ * Gets a default `PangoFontMap`.
+ *
+ * Note that the type of the returned object will depend on the
+ * platform that Pango is used on.
+ *
+ * The default fontmap can be changed by using
+ * [method@Pango.FontMap.set_default]. This can be used to
+ *
+ * Note that the default fontmap is per-thread. Each thread gets
+ * its own default fontmap. In this way, Pango can be used safely
+ * from multiple threads.
+ *
+ * Return value: (transfer none): the default fontmap
+ *  for the current thread. This object is owned by Pango and must
+ *  not be freed.
+ */
+PangoFontMap *
+pango_font_map_get_default (void)
+{
+  PangoFontMap *fontmap = g_private_get (&default_font_map);
+
+  if (G_UNLIKELY (!fontmap))
+    {
+      fontmap = pango_font_map_new_default ();
+      g_private_replace (&default_font_map, fontmap);
+    }
+
+  return fontmap;
+}
+
+/**
+ * pango_font_map_set_default:
+ * @fontmap: (nullable): The new default font map
+ *
+ * Sets a default `PangoFontMap`.
+ *
+ * The old default font map is unreffed and the new font map referenced.
+ *
+ * Note that the default fontmap is per-thread.
+ * This function only changes the default fontmap for
+ * the current thread. Default fontmaps of existing threads
+ * are not changed. Default fontmaps of any new threads will
+ * still be created using [func@Pango.FontMap.new_default].
+ *
+ * A value of %NULL for @fontmap will cause the current default
+ * font map to be released and a new default font map to be created
+ * on demand, using [func@Pango.FontMap.new_default].
+ */
+void
+pango_font_map_set_default (PangoFontMap *fontmap)
+{
+  g_return_if_fail (fontmap == NULL || PANGO_IS_FONT_MAP (fontmap));
+
+  if (fontmap)
+    g_object_ref (fontmap);
+
+  g_private_replace (&default_font_map, fontmap);
+}
+
 /* }}} */
 
 /* vim:set foldmethod=marker expandtab: */
diff --git a/pango/pango-fontmap.h b/pango/pango-fontmap.h
index 6b40cd13b..104a63d5f 100644
--- a/pango/pango-fontmap.h
+++ b/pango/pango-fontmap.h
@@ -74,4 +74,11 @@ PANGO_AVAILABLE_IN_ALL
 void                    pango_font_map_set_resolution           (PangoFontMap               *self,
                                                                  double                      dpi);
 
+PANGO_AVAILABLE_IN_ALL
+PangoFontMap *          pango_font_map_new_default              (void);
+PANGO_AVAILABLE_IN_ALL
+PangoFontMap *          pango_font_map_get_default              (void);
+PANGO_AVAILABLE_IN_ALL
+void                    pango_font_map_set_default              (PangoFontMap *fontmap);
+
 G_END_DECLS
diff --git a/pango/pangocairo-context.c b/pango/pangocairo-context.c
index d72791d71..30541c137 100644
--- a/pango/pangocairo-context.c
+++ b/pango/pangocairo-context.c
@@ -349,7 +349,7 @@ pango_cairo_create_context (cairo_t *cr)
 
   g_return_val_if_fail (cr != NULL, NULL);
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
   pango_cairo_update_context (cr, context);
 
diff --git a/pango/pangocairo-private.h b/pango/pangocairo-private.h
index 8b0243bb8..57081f438 100644
--- a/pango/pangocairo-private.h
+++ b/pango/pangocairo-private.h
@@ -22,23 +22,6 @@
 #include <pango/pangocairo.h>
 #include <pango/pango-renderer.h>
 
-
-#define PANGO_CAIRO_FONT_MAP_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), 
PANGO_TYPE_CAIRO_FONT_MAP, PangoCairoFontMapIface))
-
-typedef struct _PangoCairoFontMapIface PangoCairoFontMapIface;
-
-struct _PangoCairoFontMapIface
-{
-  GTypeInterface g_iface;
-
-  void           (*set_resolution) (PangoCairoFontMap *fontmap,
-                                    double             dpi);
-  double         (*get_resolution) (PangoCairoFontMap *fontmap);
-
-  cairo_font_type_t (*get_font_type) (PangoCairoFontMap *fontmap);
-};
-
-
 #define PANGO_CAIRO_FONT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PANGO_TYPE_CAIRO_FONT, 
PangoCairoFontIface))
 
 typedef struct _PangoCairoFontIface                  PangoCairoFontIface;
diff --git a/pango/pangocairo.h b/pango/pangocairo.h
index 6f99190c7..477d0eb9a 100644
--- a/pango/pangocairo.h
+++ b/pango/pangocairo.h
@@ -49,50 +49,6 @@ typedef struct _PangoCairoFont      PangoCairoFont;
 #define PANGO_IS_CAIRO_FONT(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_CAIRO_FONT))
 #endif
 
-/**
- * PangoCairoFontMap:
- *
- * `PangoCairoFontMap` is an interface exported by font maps for
- * use with Cairo.
- *
- * The actual type of the font map will depend on the particular
- * font technology Cairo was compiled to use.
- */
-typedef struct _PangoCairoFontMap        PangoCairoFontMap;
-
-#ifdef __GI_SCANNER__
-#define PANGO_CAIRO_TYPE_FONT_MAP       (pango_cairo_font_map_get_type())
-#define PANGO_CAIRO_FONT_MAP(obj)       (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANGO_CAIRO_TYPE_FONT_MAP, 
PangoCairoFontMap))
-#define PANGO_CAIRO_IS_FONT_MAP(obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANGO_CAIRO_TYPE_FONT_MAP))
-#else
-#define PANGO_TYPE_CAIRO_FONT_MAP       (pango_cairo_font_map_get_type ())
-#define PANGO_CAIRO_FONT_MAP(object)    (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_CAIRO_FONT_MAP, 
PangoCairoFontMap))
-#define PANGO_IS_CAIRO_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_CAIRO_FONT_MAP))
-#endif
-
-/*
- * PangoCairoFontMap
- */
-PANGO_AVAILABLE_IN_ALL
-GType         pango_cairo_font_map_get_type          (void) G_GNUC_CONST;
-
-PANGO_AVAILABLE_IN_ALL
-PangoFontMap *pango_cairo_font_map_new               (void);
-PANGO_AVAILABLE_IN_ALL
-PangoFontMap *pango_cairo_font_map_new_for_font_type (cairo_font_type_t fonttype);
-PANGO_AVAILABLE_IN_ALL
-PangoFontMap *pango_cairo_font_map_get_default       (void);
-PANGO_AVAILABLE_IN_ALL
-void          pango_cairo_font_map_set_default       (PangoCairoFontMap *fontmap);
-PANGO_AVAILABLE_IN_ALL
-cairo_font_type_t pango_cairo_font_map_get_font_type (PangoCairoFontMap *fontmap);
-
-PANGO_AVAILABLE_IN_ALL
-void          pango_cairo_font_map_set_resolution (PangoCairoFontMap *fontmap,
-                                                   double             dpi);
-PANGO_AVAILABLE_IN_ALL
-double        pango_cairo_font_map_get_resolution (PangoCairoFontMap *fontmap);
-
 /*
  * PangoCairoFont
  */
diff --git a/tests/test-bidi.c b/tests/test-bidi.c
index 6332edf87..f46283544 100644
--- a/tests/test-bidi.c
+++ b/tests/test-bidi.c
@@ -21,7 +21,6 @@
 
 #include <locale.h>
 #include <pango/pango.h>
-#include <pango/pangocairo.h>
 
 static PangoContext *context;
 
@@ -378,7 +377,7 @@ main (int argc, char *argv[])
 
   setlocale (LC_ALL, "");
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
 
   g_test_init (&argc, &argv, NULL);
diff --git a/tests/test-ellipsize.c b/tests/test-ellipsize.c
index f8512a09f..b8304442b 100644
--- a/tests/test-ellipsize.c
+++ b/tests/test-ellipsize.c
@@ -20,7 +20,6 @@
  */
 
 #include <pango/pango.h>
-#include <pango/pangocairo.h>
 #include "test-common.h"
 
 static PangoContext *context;
@@ -111,7 +110,7 @@ main (int argc, char *argv[])
 {
   PangoFontMap *fontmap;
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
 
   g_test_init (&argc, &argv, NULL);
diff --git a/tests/test-font.c b/tests/test-font.c
index 207b28188..edfde0021 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -24,7 +24,7 @@
 #include <locale.h>
 
 #include <gio/gio.h>
-#include <pango/pangocairo.h>
+#include <pango/pango.h>
 
 static PangoContext *context;
 
@@ -200,7 +200,7 @@ test_extents (void)
   PangoFontDescription *desc;
   PangoDirection dir;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   desc = pango_font_description_from_string("Cantarell 11");
   pango_context_set_font_description (context, desc);
   pango_font_description_free (desc);
@@ -234,7 +234,7 @@ test_enumerate (void)
   PangoFont *font;
   gboolean found_face;
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
 
   g_assert_cmpint (g_list_model_get_n_items (G_LIST_MODEL (fontmap)), >, 0);
@@ -297,7 +297,7 @@ test_roundtrip_plain (void)
   desc = pango_font_description_from_string ("Cantarell 11");
 #endif
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
 
 
@@ -328,13 +328,13 @@ test_roundtrip_small_caps (void)
   hb_feature_t features[32];
   guint num = 0;
 
-  if (strcmp (G_OBJECT_TYPE_NAME (pango_cairo_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
+  if (strcmp (G_OBJECT_TYPE_NAME (pango_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
     {
       g_test_skip ("Small Caps support needs to be added to PangoCoreTextFontMap");
       return;
     }
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
 
   desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
@@ -408,7 +408,7 @@ test_roundtrip_emoji (void)
   PangoFontDescription *desc, *desc2;
   PangoFont *font;
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
 
   /* This is how pango_itemize creates the emoji font desc */
@@ -435,7 +435,7 @@ test_roundtrip_emoji (void)
 static void
 test_font_models (void)
 {
-  PangoFontMap *map = pango_cairo_font_map_get_default ();
+  PangoFontMap *map = pango_font_map_get_default ();
   int n_families = 0;
 
   g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (map)) == PANGO_TYPE_FONT_FAMILY);
@@ -582,7 +582,7 @@ main (int argc, char *argv[])
 
   g_test_init (&argc, &argv, NULL);
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
 
   g_test_add_func ("/pango/font/metrics", test_metrics);
   g_test_add_func ("/pango/fontdescription/parse", test_parse);
diff --git a/tests/test-harfbuzz.c b/tests/test-harfbuzz.c
index cba9026c9..8c9d27ed4 100644
--- a/tests/test-harfbuzz.c
+++ b/tests/test-harfbuzz.c
@@ -20,28 +20,35 @@
  */
 
 #include <pango/pango.h>
-#include <pango/pangocairo.h>
 #include "test-common.h"
 
-static PangoContext *context;
-
 /* Some basic checks that the hb_font_t returned
  * by pango_font_get_hb_font is functional
  */
 static void
 test_hb_font (void)
 {
-  PangoFontDescription *desc;
+  PangoFontMap *map = pango_font_map_get_default ();
+  PangoFontFamily *family;
+  PangoFontFace *face;
   PangoFont *font;
   hb_font_t *hb_font;
   hb_bool_t res;
   hb_codepoint_t glyph;
 
- if (strcmp (G_OBJECT_TYPE_NAME (pango_context_get_font_map (context)), "PangoCairoWin32FontMap") == 0)
-    desc = pango_font_description_from_string ("Verdana 11");
-  else
-    desc = pango_font_description_from_string ("Cantarell 11");
-  font = pango_context_load_font (context, desc);
+  g_assert_true (g_list_model_get_n_items (G_LIST_MODEL (map)) > 0);
+
+  family = g_list_model_get_item (G_LIST_MODEL (map), 0);
+  g_assert_true (g_list_model_get_n_items (G_LIST_MODEL (family)) > 0);
+  face = g_list_model_get_item (G_LIST_MODEL (family), 0);
+
+  font = PANGO_FONT (pango_hb_font_new (PANGO_HB_FACE (face),
+                                        12 * PANGO_SCALE,
+                                        NULL, 0,
+                                        NULL, 0,
+                                        PANGO_GRAVITY_SOUTH,
+                                        96., NULL));
+
   hb_font = pango_font_get_hb_font (font);
 
   g_assert (hb_font != NULL);
@@ -52,17 +59,13 @@ test_hb_font (void)
   g_assert (glyph != 0);
 
   g_object_unref (font);
-  pango_font_description_free (desc);
+  g_object_unref (face);
+  g_object_unref (family);
 }
 
 int
 main (int argc, char *argv[])
 {
-  PangoFontMap *fontmap;
-
-  fontmap = pango_cairo_font_map_get_default ();
-  context = pango_font_map_create_context (fontmap);
-
   g_test_init (&argc, &argv, NULL);
 
   g_test_add_func ("/harfbuzz/font", test_hb_font);
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index 70f1127e4..a260b7568 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -28,7 +28,7 @@
 #endif
 
 #include "config.h"
-#include <pango/pangocairo.h>
+#include <pango/pango.h>
 #include "test-common.h"
 
 #include "pango/pango-item-private.h"
@@ -332,7 +332,7 @@ main (int argc, char *argv[])
   const gchar *name;
   gchar *path;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   pango_context_set_language (context, pango_language_from_string ("en-us"));
 
   /* allow to easily generate expected output for new test cases */
diff --git a/tests/test-pangocairo-threads.c b/tests/test-pangocairo-threads.c
index abdc56246..aa1e1bcad 100644
--- a/tests/test-pangocairo-threads.c
+++ b/tests/test-pangocairo-threads.c
@@ -135,7 +135,7 @@ pangocairo_threads (void)
 
   g_ptr_array_unref (surfaces);
 
-  pango_cairo_font_map_set_default (NULL);
+  pango_font_map_set_default (NULL);
 
 }
 
diff --git a/tests/testiter.c b/tests/testiter.c
index 43e6e9324..3dea2e728 100644
--- a/tests/testiter.c
+++ b/tests/testiter.c
@@ -30,7 +30,7 @@
 
 #include <glib.h>
 
-#include <pango/pangocairo.h>
+#include <pango/pango.h>
 
 static void verbose (const char *format, ...) G_GNUC_PRINTF (1, 2);
 static void
@@ -227,7 +227,7 @@ test_line_iter (void)
   PangoFontDescription *font_desc;
   PangoLayout  *layout;
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
   font_desc = pango_font_description_from_string ("cantarell 11");
   pango_context_set_font_description (context, font_desc);
@@ -262,7 +262,7 @@ test_glyphitem_iter (void)
   PangoLine *line;
   const char *text;
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   context = pango_font_map_create_context (fontmap);
   font_desc = pango_font_description_from_string ("cantarell 11");
   pango_context_set_font_description (context, font_desc);
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 42ea77c42..4e47593c9 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -30,7 +30,7 @@ test_itemize_empty_crash (void)
 {
   PangoContext *context;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   pango_itemize (context, PANGO_DIRECTION_LTR, "", 0, 1, NULL);
 
   g_object_unref (context);
@@ -42,7 +42,7 @@ test_itemize_utf8 (void)
   PangoContext *context;
   GList *result = NULL;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   result = pango_itemize (context, PANGO_DIRECTION_LTR, "\xc3\xa1\na", 3, 1, NULL);
   g_assert (result != NULL);
 
@@ -60,7 +60,7 @@ test_short_string_crash (void)
   PangoLayout *layout;
   PangoRectangle ext;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   layout = pango_layout_new (context);
   pango_layout_set_text (layout, "short text", 200);
   pango_lines_get_extents (pango_layout_get_lines (layout), &ext, &ext);
@@ -91,7 +91,7 @@ test_line_height (void)
   PangoLine *line;
   PangoRectangle ext;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   layout = pango_layout_new (context);
   pango_layout_set_text (layout, "one\ttwo", -1);
   line = pango_lines_get_lines (pango_layout_get_lines (layout))[0];
@@ -111,7 +111,7 @@ test_line_height2 (void)
   PangoLine *line;
   PangoRectangle ext1, ext2;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   layout = pango_layout_new (context);
   pango_layout_set_text (layout, "one", -1);
 
@@ -141,7 +141,7 @@ test_line_height3 (void)
   PangoRectangle ext1;
   PangoRectangle ext2;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   layout = pango_layout_new (context);
   pango_layout_set_text (layout, "one", -1);
   attrs = pango_attr_list_new ();
@@ -173,13 +173,13 @@ test_run_height (void)
   PangoLineIter *iter;
   PangoRectangle logical1, logical2;
 
-  if (strcmp (G_OBJECT_TYPE_NAME (pango_cairo_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
+  if (strcmp (G_OBJECT_TYPE_NAME (pango_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
     {
       g_test_skip ("This test fails on macOS and needs debugging");
       return;
     }
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   layout = pango_layout_new (context);
   pango_layout_set_text (layout, "one", -1);
 
@@ -206,7 +206,7 @@ test_cursor_height (void)
   PangoLayout *layout;
   PangoRectangle strong;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   layout = pango_layout_new (context);
 
   pango_layout_set_text (layout, "one\ttwo", -1);
@@ -352,7 +352,7 @@ test_fallback_shape (void)
   GList *items, *l;
   PangoDirection dir;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   dir = pango_context_get_base_dir (context);
 
   text = "Some text to sha​pe ﺄﻧﺍ ﻕﺍﺩﺭ ﻊﻟﻯ ﺄﻜﻟ ﺎﻟﺰﺟﺎﺟ ﻭ ﻩﺫﺍ ﻻ ﻱﺆﻠﻤﻨﻳ";
@@ -392,7 +392,7 @@ test_get_cursor_crash (void)
 
   const char *string = "foo\n\rbar\r\nbaz\n\nqux\n\n..";
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
 
   layout = pango_layout_new (context);
 
@@ -422,7 +422,7 @@ test_get_cursor (void)
   PangoLayout *layout;
   PangoRectangle strong, weak;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
 
   layout = pango_layout_new (context);
   pango_layout_set_text (layout, text, -1);
@@ -455,7 +455,7 @@ test_index_to_x (void)
     "ac​ual​ly", // zero-width space
   };
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
 
   for (int i = 0; i < G_N_ELEMENTS (tests); i++)
     {
@@ -524,7 +524,7 @@ test_extents (void)
     { "pa­ra­graph", -1 }, // soft hyphens
   };
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
 
   for (int i = 0; i < G_N_ELEMENTS (tests); i++)
     {
@@ -604,13 +604,13 @@ test_empty_line_height (void)
   int hint;
   int size;
 
-  if (strcmp (G_OBJECT_TYPE_NAME (pango_cairo_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
+  if (strcmp (G_OBJECT_TYPE_NAME (pango_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
     {
       g_test_skip ("This test fails on macOS and needs debugging");
       return;
     }
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   description = pango_font_description_new ();
 
   for (size = 10; size <= 20; size++)
@@ -661,7 +661,7 @@ test_gravity_metrics (void)
   PangoRectangle ink[4];
   PangoRectangle log[4];
 
-  map = pango_cairo_font_map_get_default ();
+  map = pango_font_map_get_default ();
   context = pango_font_map_create_context (map);
 
   desc = pango_font_description_from_string ("Cantarell 64");
@@ -785,7 +785,7 @@ test_wrap_char (void)
   PangoLayout *layout;
   PangoRectangle ext, ext1;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   layout = pango_layout_new (context);
   pango_layout_set_text (layout, "Rows can have suffix widgets", -1);
   pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
@@ -812,13 +812,13 @@ test_small_caps_crash (void)
   PangoFontDescription *desc;
   PangoRectangle ext;
 
-  if (strcmp (G_OBJECT_TYPE_NAME (pango_cairo_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
+  if (strcmp (G_OBJECT_TYPE_NAME (pango_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
     {
       g_test_skip ("This test needs a fontmap that supports Small-Caps");
       return;
     }
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   layout = pango_layout_new (context);
   desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
   pango_layout_set_font_description (layout, desc);
diff --git a/tests/testrandom.c b/tests/testrandom.c
index 325eec095..f3aeb6b5d 100644
--- a/tests/testrandom.c
+++ b/tests/testrandom.c
@@ -23,7 +23,7 @@
 
 #include <locale.h>
 #include <gio/gio.h>
-#include <pango/pangocairo.h>
+#include <pango/pango.h>
 
 #define N_SENTENCES 20
 
@@ -111,7 +111,7 @@ test_wrap_char (gconstpointer data)
   Size sizes[100];
   gsize i, j;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   desc = pango_font_description_from_string ("Sans 10");
   layout = pango_layout_new (context);
   pango_layout_set_font_description (layout, desc);
@@ -181,7 +181,7 @@ test_wrap_char_min_width (gconstpointer data)
   gsize j;
   int test_width, ref_width;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
   desc = pango_font_description_from_string ("Sans 10");
   ref_layout = pango_layout_new (context);
   pango_layout_set_font_description (ref_layout, desc);
diff --git a/utils/pango-list.c b/utils/pango-list.c
index c963e5e0c..2f0fbc027 100644
--- a/utils/pango-list.c
+++ b/utils/pango-list.c
@@ -21,8 +21,7 @@
  */
 
 #include "config.h"
-#include <pango/pangocairo.h>
-#include <pango/pangofc-fontmap.h>
+#include <pango/pango.h>
 #include <pango/pango-hbface-private.h>
 #include <hb-ot.h>
 #include <glib/gstdio.h>
@@ -141,7 +140,7 @@ main (int    argc,
       exit (0);
     }
 
-  fontmap = pango_cairo_font_map_get_default ();
+  fontmap = pango_font_map_get_default ();
   ctx = pango_font_map_create_context (fontmap);
 
   if (opt_verbose)
diff --git a/utils/pango-segmentation.c b/utils/pango-segmentation.c
index 4c00dcc47..573e0cf23 100644
--- a/utils/pango-segmentation.c
+++ b/utils/pango-segmentation.c
@@ -20,7 +20,7 @@
  */
 
 #include <glib.h>
-#include <pango/pangocairo.h>
+#include <pango/pango.h>
 #include <string.h>
 #include <stdlib.h>
 #include <locale.h>
@@ -70,7 +70,7 @@ show_segmentation (const char *input,
   PangoAttrList *attributes;
   PangoLayout *layout;
 
-  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+  context = pango_font_map_create_context (pango_font_map_get_default ());
 
   string = g_string_new ("");
 
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c
index bcb8a75f8..a9daf388d 100644
--- a/utils/viewer-pangocairo.c
+++ b/utils/viewer-pangocairo.c
@@ -51,11 +51,8 @@ pangocairo_view_create (const PangoViewer *klass G_GNUC_UNUSED)
 
   instance->backend = cairo_viewer_iface_create (&instance->iface);
 
-  instance->fontmap = pango_cairo_font_map_new ();
-  if (PANGO_IS_CAIRO_FONT_MAP (instance->fontmap))
-    pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (instance->fontmap), opt_dpi);
-  else
-    pango_font_map_set_resolution (PANGO_FONT_MAP (instance->fontmap), opt_dpi);
+  instance->fontmap = pango_font_map_new_default ();
+  pango_font_map_set_resolution (PANGO_FONT_MAP (instance->fontmap), opt_dpi);
 
   instance->font_options = cairo_font_options_create ();
   if (opt_hinting != HINT_DEFAULT)


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