summaryrefslogtreecommitdiff
path: root/pango/pangocairo-fontmap.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2008-04-21 19:41:40 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2008-04-21 19:41:40 +0000
commite026cad714ef709b680efa8489012b823665d7e7 (patch)
tree9fdd1bf6df94485f81dab90e25560e0f22b9bace /pango/pangocairo-fontmap.c
parentb9bd159e4b71404bfa15d415ddf8b68eb4248af3 (diff)
downloadpango-e026cad714ef709b680efa8489012b823665d7e7.tar.gz
Bug 514617 – Add pango_cairo_font_map_set_default()
2008-04-21 Behdad Esfahbod <behdad@gnome.org> Bug 514617 – Add pango_cairo_font_map_set_default() * docs/pango-sections.txt: * docs/tmpl/pangocairo.sgml: * pango/pangocairo-fontmap.c (pango_cairo_font_map_get_default), (pango_cairo_font_map_set_default): * pango/pangocairo.def: * pango/pangocairo.h: New public API: pango_cairo_font_map_set_default() svn path=/trunk/; revision=2600
Diffstat (limited to 'pango/pangocairo-fontmap.c')
-rw-r--r--pango/pangocairo-fontmap.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/pango/pangocairo-fontmap.c b/pango/pangocairo-fontmap.c
index cb7dd9d8..2dbb588d 100644
--- a/pango/pangocairo-fontmap.c
+++ b/pango/pangocairo-fontmap.c
@@ -146,6 +146,8 @@ pango_cairo_font_map_new_for_font_type (cairo_font_type_t fonttype)
}
}
+static PangoFontMap *default_font_map = NULL;
+
/**
* pango_cairo_font_map_get_default:
*
@@ -156,7 +158,12 @@ pango_cairo_font_map_new_for_font_type (cairo_font_type_t fonttype)
* You generally should only use the #PangoFontMap and
* #PangoCairoFontMap interfaces on the returned object.
*
- * Return value: the default Cairo fontmap for #Pango. This
+ * The default Cairo fontmap can be changed by using
+ * pango_cairo_font_map_set_default(). This can be used to
+ * change the Cairo font backend that the default fontmap
+ * uses for example.
+ *
+ * Return value: the default Cairo fontmap for Pango. This
* object is owned by Pango and must not be freed.
*
* Since: 1.10
@@ -164,8 +171,6 @@ pango_cairo_font_map_new_for_font_type (cairo_font_type_t fonttype)
PangoFontMap *
pango_cairo_font_map_get_default (void)
{
- static PangoFontMap *default_font_map = NULL;
-
if (G_UNLIKELY (!default_font_map))
default_font_map = pango_cairo_font_map_new ();
@@ -173,6 +178,35 @@ pango_cairo_font_map_get_default (void)
}
/**
+ * pango_cairo_font_map_set_default:
+ * @fontmap: The new default font map, or %NULL
+ *
+ * Sets a default #PangoCairoFontMap to use with Cairo.
+ *
+ * This can be used to change the Cairo font backend that the
+ * default fontmap uses for example. The old default font map
+ * is unreffed and the new font map referenced.
+ *
+ * A value of %NULL for @fontmap will cause a new default font
+ * map to be created on demand, using pango_cairo_font_map_new().
+ *
+ * Since: 1.22
+ **/
+void
+pango_cairo_font_map_set_default (PangoCairoFontMap *fontmap)
+{
+ g_return_if_fail (PANGO_IS_CAIRO_FONT_MAP (fontmap));
+
+ if ((PangoFontMap *) fontmap == default_font_map)
+ return;
+
+ if (default_font_map)
+ g_object_unref (default_font_map);
+
+ default_font_map = g_object_ref (fontmap);
+}
+
+/**
* pango_cairo_font_map_set_resolution:
* @fontmap: a #PangoCairoFontMap
* @dpi: the resolution in "dots per inch". (Physical inches aren't actually