summaryrefslogtreecommitdiff
path: root/pango/pango-attributes.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-07-21 19:19:50 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-07-21 19:19:50 +0000
commitebbd946ac65ac1a20a46652b234288280e7ee5fd (patch)
tree93e204b1cc463b5b3d371406b35dc59dc0c1dda4 /pango/pango-attributes.c
parenta084f42c0e920e2ac91383b8d98ff54f339d17ac (diff)
downloadpango-ebbd946ac65ac1a20a46652b234288280e7ee5fd.tar.gz
A bit of code cleanup.
Fri Jul 21 15:17:26 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-context.c (pango_itemize): A bit of code cleanup. * pango/pango-attributes.[ch]: Add a new attribute type PangoAttrShape, for imposing specific shapes on glyphs. This is used for handling embedded pixmaps and similar objects. * pango/pango-layout.c: Hnadle PangoAttrShape. * pango/pango-context.[ch]:
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r--pango/pango-attributes.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 23cfd8b1..beebcec3 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -548,6 +548,73 @@ pango_attr_rise_new (int rise)
return pango_attr_int_new (&klass, (int)rise);
}
+static PangoAttribute *
+pango_attr_shape_copy (const PangoAttribute *attr)
+{
+ const PangoAttrShape *shape_attr = (PangoAttrShape *)attr;
+
+ return pango_attr_shape_new (&shape_attr->ink_rect, &shape_attr->logical_rect);
+}
+
+static void
+pango_attr_shape_destroy (PangoAttribute *attr)
+{
+ g_free (attr);
+}
+
+static gboolean
+pango_attr_shape_compare (const PangoAttribute *attr1,
+ const PangoAttribute *attr2)
+{
+ 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 &&
+ shape_attr1->logical_rect.height == shape_attr2->logical_rect.height &&
+ 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);
+}
+
+/**
+ * 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)
+{
+ static const PangoAttrClass klass = {
+ PANGO_ATTR_SHAPE,
+ pango_attr_shape_copy,
+ pango_attr_shape_destroy,
+ pango_attr_shape_compare
+ };
+
+ PangoAttrShape *result;
+
+ g_return_val_if_fail (ink_rect != NULL, NULL);
+ g_return_val_if_fail (logical_rect != NULL, NULL);
+
+ result = g_new (PangoAttrShape, 1);
+ result->attr.klass = &klass;
+ result->ink_rect = *ink_rect;
+ result->logical_rect = *logical_rect;
+
+ return (PangoAttribute *)result;
+}
+
/**
* pango_attr_list_new:
*