[pango] Add a readonly version of pango_layout_get_log_attrs()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] Add a readonly version of pango_layout_get_log_attrs()
- Date: Mon, 16 May 2011 13:34:56 +0000 (UTC)
commit 4587e5d2231b717dd116253a49badc1ba3aa5db5
Author: Matthias Clasen <mclasen redhat com>
Date: Sat May 14 08:31:02 2011 -0400
Add a readonly version of pango_layout_get_log_attrs()
Otherwise, we are forced to either make many unnecessary copies
or pass the log attrs around alongside the layout in APIs operating
on the attrs.
https://bugzilla.gnome.org/show_bug.cgi?id=650170
docs/pango-sections.txt | 1 +
pango/pango-layout.c | 35 +++++++++++++++++++++++++++++++++++
pango/pango-layout.h | 3 +++
pango/pango.def | 1 +
4 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 61e3f69..d0236a2 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -481,6 +481,7 @@ PANGO_TYPE_ALIGNMENT
pango_layout_get_unknown_glyphs_count
pango_layout_get_log_attrs
+pango_layout_get_log_attrs_readonly
pango_layout_index_to_pos
pango_layout_index_to_line_x
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index f0dbbcc..0b17ea8 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -1277,6 +1277,41 @@ pango_layout_get_log_attrs (PangoLayout *layout,
*n_attrs = layout->n_chars + 1;
}
+/**
+ * pango_layout_get_log_attrs_readonly:
+ * @layout: a #PangoLayout
+ * @n_attrs: location to store the number of the attributes in the array
+ *
+ * Retrieves an array of logical attributes for each character in
+ * the @layout.
+ *
+ * This is a faster alternative to pango_layout_get_log_attrs().
+ * The returned array is part of @layout and must not be modified.
+ * Modifying the layout will invalidate the returned array.
+ *
+ * The number of attributes returned in @n_attrs will be one more
+ * than the total number of characters in the layout, since there
+ * need to be attributes corresponding to both the position before
+ * the first character and the position after the last character.
+ *
+ * Returns: an array of logical attributes
+ *
+ * Since: 1.30
+ */
+PangoLogAttr *
+pango_layout_get_log_attrs_readonly (PangoLayout *layout,
+ gint *n_attrs)
+{
+ g_return_if_fail (layout != NULL);
+
+ pango_layout_check_lines (layout);
+
+ if (n_attrs)
+ *n_attrs = layout->n_chars + 1;
+
+ return layout->log_attrs;
+}
+
/**
* pango_layout_get_line_count:
diff --git a/pango/pango-layout.h b/pango/pango-layout.h
index 3b769ff..52dc36a 100644
--- a/pango/pango-layout.h
+++ b/pango/pango-layout.h
@@ -166,6 +166,9 @@ void pango_layout_get_log_attrs (PangoLayout *layout,
PangoLogAttr **attrs,
gint *n_attrs);
+PangoLogAttr *pango_layout_get_log_attrs_readonly (PangoLayout *layout,
+ gint *n_attrs);
+
void pango_layout_index_to_pos (PangoLayout *layout,
int index_,
PangoRectangle *pos);
diff --git a/pango/pango.def b/pango/pango.def
index 3b1bc76..70e1a50 100644
--- a/pango/pango.def
+++ b/pango/pango.def
@@ -177,6 +177,7 @@ EXPORTS
pango_fontset_simple_size
pango_get_lib_subdirectory
pango_get_log_attrs
+ pango_get_log_attrs_readonly
pango_get_mirror_char
pango_get_sysconf_subdirectory
pango_glyph_item_apply_attrs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]