summaryrefslogtreecommitdiff
path: root/pango/pangocairo-context.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2008-04-21 22:52:41 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2008-04-21 22:52:41 +0000
commit30401e22f1a7417ad71045966a51c30e5f126cbb (patch)
tree5fd988f4b82b3e588a7410dfcc983e74d43712a1 /pango/pangocairo-context.c
parent9b3aa20fc9ba19a2727e9388c60bb398c4d60978 (diff)
downloadpango-30401e22f1a7417ad71045966a51c30e5f126cbb.tar.gz
Bug 517119 – Add pango_cairo_create_context()
2008-04-21 Behdad Esfahbod <behdad@gnome.org> Bug 517119 – Add pango_cairo_create_context() * docs/pango-sections.txt: * pango/pangocairo-context.c (pango_cairo_create_context), (pango_cairo_create_layout): * pango/pangocairo.def: * pango/pangocairo.h: New public API: pango_cairo_create_context() svn path=/trunk/; revision=2606
Diffstat (limited to 'pango/pangocairo-context.c')
-rw-r--r--pango/pangocairo-context.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/pango/pangocairo-context.c b/pango/pangocairo-context.c
index 1948ebc9..c8ccbe15 100644
--- a/pango/pangocairo-context.c
+++ b/pango/pangocairo-context.c
@@ -387,6 +387,39 @@ pango_cairo_context_get_shape_renderer (PangoContext *context,
}
/**
+ * pango_cairo_create_context:
+ * @cr: a Cairo context
+ *
+ * Creates a context object set up to match the current transformation
+ * and target surface of the Cairo context. This context can then be
+ * used to create a layout using pango_layout_new().
+ *
+ * This function is a convenience function that creates a context using
+ * the default font map, then updates it to @cr. If you just need to
+ * create a layout for use with @cr and do not need to access #PangoContext
+ * directly, you can use pango_cairo_create_layout() instead.
+ *
+ * Return value: the newly created #PangoContext. Free with
+ * g_object_unref().
+ *
+ * Since: 1.22
+ **/
+PangoContext *
+pango_cairo_create_context (cairo_t *cr)
+{
+ PangoFontMap *fontmap;
+ PangoContext *context;
+
+ g_return_val_if_fail (cr != NULL, NULL);
+
+ fontmap = pango_cairo_font_map_get_default ();
+ context = pango_cairo_font_map_create_context ((PangoCairoFontMap *) (fontmap));
+ pango_cairo_update_context (cr, context);
+
+ return context;
+}
+
+/**
* pango_cairo_create_layout:
* @cr: a Cairo context
*
@@ -410,17 +443,13 @@ pango_cairo_context_get_shape_renderer (PangoContext *context,
PangoLayout *
pango_cairo_create_layout (cairo_t *cr)
{
- PangoFontMap *fontmap;
PangoContext *context;
PangoLayout *layout;
g_return_val_if_fail (cr != NULL, NULL);
- fontmap = pango_cairo_font_map_get_default ();
- context = pango_cairo_font_map_create_context ((PangoCairoFontMap *) (fontmap));
+ context = pango_cairo_create_context (cr);
layout = pango_layout_new (context);
-
- pango_cairo_update_context (cr, context);
g_object_unref (context);
return layout;