[pango] [pangocairo] Allow backend selection



commit 1a043201e0b1ef4496ada1e980e66996570b1efe
Author: Behdad Esfahbod <behdad behdad org>
Date:   Wed Jul 23 12:21:53 2014 -0400

    [pangocairo] Allow backend selection
    
    Based on:
    
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-pango/0008-allow-backend-selection.mingw.patch

 pango/pangocairo-fontmap.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/pango/pangocairo-fontmap.c b/pango/pangocairo-fontmap.c
index a143190..2a46d71 100644
--- a/pango/pangocairo-fontmap.c
+++ b/pango/pangocairo-fontmap.c
@@ -58,6 +58,13 @@ pango_cairo_font_map_default_init (PangoCairoFontMapIface *iface)
  * You generally should only use the #PangoFontMap and
  * #PangoCairoFontMap interfaces on the returned object.
  *
+ * 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 quartz.
+ * If requested type is not available, NULL is returned. Ie.
+ * 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().
  *
@@ -66,20 +73,26 @@ pango_cairo_font_map_default_init (PangoCairoFontMapIface *iface)
 PangoFontMap *
 pango_cairo_font_map_new (void)
 {
+  const char *backend = getenv ("PANGOCAIRO_BACKEND");
+  if (backend && !*backend)
+    backend = NULL;
 #if !GLIB_CHECK_VERSION (2, 35, 3)
   /* Make sure that the type system is initialized */
   g_type_init ();
 #endif
 #if defined(HAVE_CORE_TEXT) && defined (HAVE_CAIRO_QUARTZ)
-  return g_object_new (PANGO_TYPE_CAIRO_CORE_TEXT_FONT_MAP, NULL);
+  if (!backend || 0 == strcmp (backend, "quartz"))
+    return g_object_new (PANGO_TYPE_CAIRO_CORE_TEXT_FONT_MAP, NULL);
 #elif defined(HAVE_CAIRO_WIN32)
-  return g_object_new (PANGO_TYPE_CAIRO_WIN32_FONT_MAP, NULL);
+  if (!backend || 0 == strcmp (backend, "win32"))
+    return g_object_new (PANGO_TYPE_CAIRO_WIN32_FONT_MAP, NULL);
 #elif defined(HAVE_CAIRO_FREETYPE)
-  return g_object_new (PANGO_TYPE_CAIRO_FC_FONT_MAP, NULL);
-#else
-  g_assert_not_reached ();
-  return NULL;
+  if (!backend || 0 == strcmp (backend, "fontconfig"))
+    return g_object_new (PANGO_TYPE_CAIRO_FC_FONT_MAP, NULL);
 #endif
+  if (!backend)
+    g_assert_not_reached ();
+  return NULL;
 }
 
 /**


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