From: Matthias Clasen Date: Mon, 16 May 2011 13:32:59 +0000 (-0400) Subject: Provide access to PangoLayout.n_chars X-Git-Tag: 1.29.1~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff16b948572c1bdc301d27af41b34566d28c6610;p=platform%2Fupstream%2Fpango.git Provide access to PangoLayout.n_chars This lets us avoid a bunch of g_utf8_strlen() calls, when Pango is already maintaining this information anyway. https://bugzilla.gnome.org/show_bug.cgi?id=650208 --- diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt index d0236a2..d8f2c05 100644 --- a/docs/pango-sections.txt +++ b/docs/pango-sections.txt @@ -442,6 +442,7 @@ pango_layout_context_changed pango_layout_set_text pango_layout_get_text +pango_layout_get_character_count pango_layout_set_markup pango_layout_set_markup_with_accel pango_layout_set_attributes diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 0b17ea8..5952fa8 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -1096,6 +1096,26 @@ pango_layout_get_text (PangoLayout *layout) } /** + * pango_layout_get_character_count: + * @layout: a #PangoLayout + * + * Returns the number of Unicode characters in the + * the text of @layout. + * + * Return value: the number of Unicode characters + * in the text of @layout + * + * Since: 1.30 + */ +gint +pango_layout_get_character_count (PangoLayout *layout) +{ + g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); + + return layout->n_chars; +} + +/** * pango_layout_set_markup: * @layout: a #PangoLayout * @markup: marked-up text diff --git a/pango/pango-layout.h b/pango/pango-layout.h index 52dc36a..39d2e70 100644 --- a/pango/pango-layout.h +++ b/pango/pango-layout.h @@ -103,6 +103,8 @@ void pango_layout_set_text (PangoLayout *layout, int length); const char *pango_layout_get_text (PangoLayout *layout); +gint pango_layout_get_character_count (PangoLayout *layout); + void pango_layout_set_markup (PangoLayout *layout, const char *markup, int length); diff --git a/pango/pango.def b/pango/pango.def index 70e1a50..3e6a428 100644 --- a/pango/pango.def +++ b/pango/pango.def @@ -233,6 +233,7 @@ EXPORTS pango_layout_get_attributes pango_layout_get_auto_dir pango_layout_get_baseline + pango_layout_get_character_count pango_layout_get_context pango_layout_get_cursor_pos pango_layout_get_ellipsize