summaryrefslogtreecommitdiff
path: root/pango/pango-attributes.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-11-19 22:57:11 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-11-19 22:57:11 +0000
commit25eb23b0c27d6c447240fcf8505ad35a2a5a5d93 (patch)
tree52bcfb8069fb7bdfe31b0537da68f1f4338637ee /pango/pango-attributes.c
parentcb18309673f263d54eba9c312ab5802b4a6beb70 (diff)
downloadpango-25eb23b0c27d6c447240fcf8505ad35a2a5a5d93.tar.gz
Remove color_set() virtual function ... it's not absolutely necessary for
Fri Nov 19 17:44:33 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-renderer.[ch]: Remove color_set() virtual function ... it's not absolutely necessary for chaining renderers, and it's not clear that chaining renderers is actually useful, anyways. * pango/pango-renderer.[ch] (pango_renderer_set_color): Constify color argument. * pango/pango-render.c: Fix various bugs. * pango/pango-attributes.[ch] (pango_attr_shape_new_with_data): Add the ability to create a shape attribute with user data. * pango/pango-renderer.[ch] (PangoRendererClass): Add a draw_shape virtual function, to draw content for PangoAttrShape. * pango/pangoxft-fontmap.c (pango_xft_shutdown_display): Add note to docs that XCloseDisplay() will automatically take care of releasing Pango's allocated resources for the display. * docs/Makefile.am (SCAN_OPTIONS): Add the appropriate --deprecated-guards option. * docs/tmpl/xft-fonts.sgml: Add long description. * docs/tmpl/x-fonts.sgml: Document as dead.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r--pango/pango-attributes.c69
1 files changed, 59 insertions, 10 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index fd5be6fb..276f7acd 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -697,13 +697,25 @@ static PangoAttribute *
pango_attr_shape_copy (const PangoAttribute *attr)
{
const PangoAttrShape *shape_attr = (PangoAttrShape *)attr;
+ gpointer data;
+
+ if (shape_attr->copy_func)
+ data = shape_attr->copy_func (shape_attr->data);
+ else
+ data = shape_attr->data;
- return pango_attr_shape_new (&shape_attr->ink_rect, &shape_attr->logical_rect);
+ return pango_attr_shape_new_with_data (&shape_attr->ink_rect, &shape_attr->logical_rect,
+ data, shape_attr->copy_func, shape_attr->destroy_func);
}
static void
pango_attr_shape_destroy (PangoAttribute *attr)
{
+ const PangoAttrShape *shape_attr = (PangoAttrShape *)attr;
+
+ if (shape_attr->destroy_func)
+ shape_attr->destroy_func (shape_attr->data);
+
g_free (attr);
}
@@ -713,7 +725,7 @@ pango_attr_shape_equal (const PangoAttribute *attr1,
{
const PangoAttrShape *shape_attr1 = (const PangoAttrShape *)attr1;
const PangoAttrShape *shape_attr2 = (const PangoAttrShape *)attr2;
-
+
return (shape_attr1->logical_rect.x == shape_attr2->logical_rect.x &&
shape_attr1->logical_rect.y == shape_attr2->logical_rect.y &&
shape_attr1->logical_rect.width == shape_attr2->logical_rect.width &&
@@ -721,24 +733,35 @@ pango_attr_shape_equal (const PangoAttribute *attr1,
shape_attr1->ink_rect.x == shape_attr2->ink_rect.x &&
shape_attr1->ink_rect.y == shape_attr2->ink_rect.y &&
shape_attr1->ink_rect.width == shape_attr2->ink_rect.width &&
- shape_attr1->ink_rect.height == shape_attr2->ink_rect.height);
+ shape_attr1->ink_rect.height == shape_attr2->ink_rect.height &&
+ shape_attr1->data == shape_attr2->data);
}
/**
- * pango_attr_shape_new:
+ * pango_attr_shape_new_with_data:
* @ink_rect: ink rectangle to assign to each character
* @logical_rect: logical rectangle assign to each character
+ * @data: user data pointer
+ * @copy_func: function to copy @data when the attribute
+ * is copied. If %NULL, @data is simply copied
+ * as a pointer.
+ * @destroy_func: function to free @data when the attribute
+ * is freed, or %NULL.
*
- * Create a new shape attribute. A shape is used to impose a
- * particular ink and logical rect on the result of shaping a
- * particular glyph. This might be used, for instance, for
- * embedding a picture or a widget inside a PangoLayout.
+ * Like pango_attr_shape_new(), but a user data pointer is also
+ * provided; this pointer can be accessed when rendering later
+ * rendering the glyph.
*
* Return value: the newly created attribute
+ *
+ * Since: 1.8
**/
PangoAttribute *
-pango_attr_shape_new (const PangoRectangle *ink_rect,
- const PangoRectangle *logical_rect)
+pango_attr_shape_new_with_data (const PangoRectangle *ink_rect,
+ const PangoRectangle *logical_rect,
+ gpointer data,
+ PangoAttrDataCopyFunc copy_func,
+ GDestroyNotify destroy_func)
{
static const PangoAttrClass klass = {
PANGO_ATTR_SHAPE,
@@ -756,10 +779,36 @@ pango_attr_shape_new (const PangoRectangle *ink_rect,
result->attr.klass = &klass;
result->ink_rect = *ink_rect;
result->logical_rect = *logical_rect;
+ result->data = data;
+ result->copy_func = copy_func;
+ result->destroy_func = destroy_func;
return (PangoAttribute *)result;
}
+/**
+ * pango_attr_shape_new:
+ * @ink_rect: ink rectangle to assign to each character
+ * @logical_rect: logical rectangle assign to each character
+ *
+ * Create a new shape attribute. A shape is used to impose a
+ * particular ink and logical rect on the result of shaping a
+ * particular glyph. This might be used, for instance, for
+ * embedding a picture or a widget inside a PangoLayout.
+ *
+ * Return value: the newly created attribute
+ **/
+PangoAttribute *
+pango_attr_shape_new (const PangoRectangle *ink_rect,
+ const PangoRectangle *logical_rect)
+{
+ g_return_val_if_fail (ink_rect != NULL, NULL);
+ g_return_val_if_fail (logical_rect != NULL, NULL);
+
+ return pango_attr_shape_new_with_data (ink_rect, logical_rect,
+ NULL, NULL, NULL);
+}
+
GType
pango_attr_list_get_type (void)
{