diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2014-07-23 12:21:53 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2014-07-23 12:21:53 -0400 |
commit | 1a043201e0b1ef4496ada1e980e66996570b1efe (patch) | |
tree | 8fe07e93f5beffe8fa87bbc1596bf853b10bdaf8 /pango/pangocairo-fontmap.c | |
parent | 1075fc4bd12df3b81bdfb94f6a2c960595e98a3f (diff) | |
download | pango-1a043201e0b1ef4496ada1e980e66996570b1efe.tar.gz |
[pangocairo] Allow backend selection
Based on:
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-pango/0008-allow-backend-selection.mingw.patch
Diffstat (limited to 'pango/pangocairo-fontmap.c')
-rw-r--r-- | 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 a1431902..2a46d715 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; } /** |