diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-05-14 08:31:02 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-05-16 09:28:57 -0400 |
commit | 4587e5d2231b717dd116253a49badc1ba3aa5db5 (patch) | |
tree | 0aba3f65c1f71cd6d2697d6d27a5fa20f916ef86 /pango/pango-layout.c | |
parent | c43c4884bf4b405f58a0c966384ee751f82ee69c (diff) | |
download | pango-4587e5d2231b717dd116253a49badc1ba3aa5db5.tar.gz |
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
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r-- | pango/pango-layout.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index f0dbbcc9..0b17ea87 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: |