summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog13
-rw-r--r--docs/pango-sections.txt1
-rw-r--r--pango/pangocairo-context.c39
-rw-r--r--pango/pangocairo.def1
-rw-r--r--pango/pangocairo.h1
5 files changed, 50 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 13cc5d37..fc058ecf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
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()
+
+2008-04-21 Behdad Esfahbod <behdad@gnome.org>
+
Bug 404416 – pango_layout_get_baseline or something
* docs/pango-sections.txt:
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index a6f42db3..38ee192d 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -852,6 +852,7 @@ pango_cairo_context_get_font_options
PangoCairoShapeRendererFunc
pango_cairo_context_set_shape_renderer
pango_cairo_context_get_shape_renderer
+pango_cairo_create_context
pango_cairo_update_context
pango_cairo_create_layout
pango_cairo_update_layout
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;
diff --git a/pango/pangocairo.def b/pango/pangocairo.def
index 5b243892..3bceacd2 100644
--- a/pango/pangocairo.def
+++ b/pango/pangocairo.def
@@ -5,6 +5,7 @@ EXPORTS
pango_cairo_context_set_font_options
pango_cairo_context_set_resolution
pango_cairo_context_set_shape_renderer
+ pango_cairo_create_context
pango_cairo_create_layout
pango_cairo_error_underline_path
; pango_cairo_fc_font_get_type
diff --git a/pango/pangocairo.h b/pango/pangocairo.h
index 0f15d757..b9191cd8 100644
--- a/pango/pangocairo.h
+++ b/pango/pangocairo.h
@@ -105,6 +105,7 @@ PangoCairoShapeRendererFunc pango_cairo_context_get_shape_renderer (PangoContext
/* Convenience
*/
+PangoContext *pango_cairo_create_context (cairo_t *cr);
PangoLayout *pango_cairo_create_layout (cairo_t *cr);
void pango_cairo_update_layout (cairo_t *cr,
PangoLayout *layout);