summaryrefslogtreecommitdiff
path: root/pango/pango-glyph-item.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-10-24 04:50:09 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-10-24 04:50:09 +0000
commitb178da14dabd63937c3867f6d5cbb29f7a31d69f (patch)
treecd998c7bde03f495f0e5badd09cfcbd96f44c0f9 /pango/pango-glyph-item.c
parent24b36e5df683f622cfe9e210716c06da8193f6f8 (diff)
downloadpango-b178da14dabd63937c3867f6d5cbb29f7a31d69f.tar.gz
Bug 471577 – GBoxed GType for PangoGlyphItem
2007-10-24 Behdad Esfahbod <behdad@gnome.org> Bug 471577 – GBoxed GType for PangoGlyphItem * pango/pango-glyph-item.h: * pango/pango-glyph-item.c: New public API: PANGO_TYPE_GLYPH_ITEM pango_glyph_item_copy() pango_glyph_item_get_type() * pango/pango-layout.c: New public API: pango_layout_iter_copy() * pango/fonts.c (pango_font_description_copy), (pango_font_description_copy_static), (pango_font_description_free), (pango_font_descriptions_free), (pango_font_metrics_ref), (pango_font_metrics_unref): * pango/glyphstring.c (pango_glyph_string_copy), (pango_glyph_string_free): * pango/pango-attributes.c (pango_attr_list_ref), (pango_attr_list_unref), (pango_attr_list_copy): * pango/pango-color.c (pango_color_copy), (pango_color_free): * pango/pango-item.c (pango_item_copy), (pango_item_free): * pango/pango-layout.c (pango_layout_line_ref), (pango_layout_line_unref), (pango_layout_iter_copy), (pango_layout_iter_free): * pango/pango-layout.h: * pango/pango-matrix.c (pango_matrix_copy), (pango_matrix_free): Update all copy/free functions to accept NULL as legitimate input. Previously all were g_return_[val_]if_fail()ing it. * pango/pango.def: * docs/pango-sections.txt: * docs/tmpl/glyphs.sgml: * docs/tmpl/layout.sgml: Update. svn path=/trunk/; revision=2457
Diffstat (limited to 'pango/pango-glyph-item.c')
-rw-r--r--pango/pango-glyph-item.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/pango/pango-glyph-item.c b/pango/pango-glyph-item.c
index 07b844bc..1da934a4 100644
--- a/pango/pango-glyph-item.c
+++ b/pango/pango-glyph-item.c
@@ -24,6 +24,7 @@
#include "pango-glyph-item.h"
#include "pango-glyph-item-private.h"
+#include "pango-impl-utils.h"
#define LTR(glyph_item) (((glyph_item)->item->analysis.level % 2) == 0)
@@ -130,8 +131,36 @@ pango_glyph_item_split (PangoGlyphItem *orig,
}
/**
+ * pango_glyph_item_copy:
+ * @orig: a #PangoGlyphItem, may be %NULL
+ *
+ * Make a deep copy an existing #PangoGlyphItem structure.
+ *
+ * Return value: the newly allocated #PangoGlyphItem, which should
+ * be freed with pango_glyph_item_free(), or %NULL
+ * if @orig was %NULL.
+ *
+ * Since: 1.20
+ **/
+PangoGlyphItem *
+pango_glyph_item_copy (PangoGlyphItem *orig)
+{
+ PangoGlyphItem *result;
+
+ if (orig == NULL)
+ return NULL;
+
+ result = g_slice_new (PangoGlyphItem);
+
+ result->item = pango_item_copy (orig->item);
+ result->glyphs = pango_glyph_string_copy (orig->glyphs);
+
+ return result;
+}
+
+/**
* pango_glyph_item_free:
- * @glyph_item: a #PangoGlyphItem
+ * @glyph_item: a #PangoGlyphItem, may be %NULL
*
* Frees a #PangoGlyphItem and memory to which it points.
*
@@ -140,6 +169,9 @@ pango_glyph_item_split (PangoGlyphItem *orig,
void
pango_glyph_item_free (PangoGlyphItem *glyph_item)
{
+ if (glyph_item == NULL)
+ return;
+
if (glyph_item->item)
pango_item_free (glyph_item->item);
if (glyph_item->glyphs)
@@ -148,6 +180,18 @@ pango_glyph_item_free (PangoGlyphItem *glyph_item)
g_slice_free (PangoGlyphItem, glyph_item);
}
+GType
+pango_glyph_item_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (G_UNLIKELY (our_type == 0))
+ our_type = g_boxed_type_register_static (I_("PangoGlyphItem"),
+ (GBoxedCopyFunc) pango_glyph_item_copy,
+ (GBoxedFreeFunc) pango_glyph_item_free);
+ return our_type;
+}
+
/**
* _pango_glyph_item_iter_next_cluster:
* @iter: a #PangoGlyphItemIter