[pango] Provide access to PangoLayout.n_chars
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] Provide access to PangoLayout.n_chars
- Date: Mon, 16 May 2011 13:35:01 +0000 (UTC)
commit ff16b948572c1bdc301d27af41b34566d28c6610
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 16 09:32:59 2011 -0400
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
docs/pango-sections.txt | 1 +
pango/pango-layout.c | 20 ++++++++++++++++++++
pango/pango-layout.h | 2 ++
pango/pango.def | 1 +
4 files changed, 24 insertions(+), 0 deletions(-)
---
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]