summaryrefslogtreecommitdiff
path: root/pango/glyphstring.c
diff options
context:
space:
mode:
Diffstat (limited to 'pango/glyphstring.c')
-rw-r--r--pango/glyphstring.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index c4c5c8cd..82770349 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -264,6 +264,33 @@ pango_glyph_string_extents (PangoGlyphString *glyphs,
}
/**
+ * pango_glyph_string_get_width:
+ * @glyphs: a #PangoGlyphString
+ * @font: a #PangoFont
+ *
+ * Computes the logical width of the glyph string as can also be computed
+ * using pango_glyph_string_extents(). However, since this only computes the
+ * width, it's much faster. This is in fact only a convenience function that
+ * computes the sum of geometry.width for each glyph in the @glyphs.
+ *
+ * Return value: the logical width of the glyph string.
+ *
+ * Since: 1.14
+ */
+int
+pango_glyph_string_get_width (PangoGlyphString *glyphs,
+ PangoFont *font)
+{
+ int i;
+ int width = 0;
+
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ width += &glyphs->glyphs[i].geometry.width;
+
+ return width;
+}
+
+/**
* pango_glyph_string_get_logical_widths:
* @glyphs: a #PangoGlyphString
* @text: the text corresponding to the glyphs