summaryrefslogtreecommitdiff
path: root/pango/glyphstring.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-08-12 18:36:36 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-08-12 18:36:36 -0400
commit7b1b94b255d616759672b03b2cf4b88aa013271a (patch)
tree7efde87280cc8e59d0980d251f992c354c0ad6ff /pango/glyphstring.c
parent1f1b4df1d08f5b9a8e85d9282240aaaf3d8d8023 (diff)
downloadpango-7b1b94b255d616759672b03b2cf4b88aa013271a.tar.gz
New public API: pango_glyph_item_get_logical_widths()
Diffstat (limited to 'pango/glyphstring.c')
-rw-r--r--pango/glyphstring.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index 9e7c5f85..923a9360 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -329,6 +329,8 @@ pango_glyph_string_get_width (PangoGlyphString *glyphs)
* text, determine the screen width corresponding to each character. When
* multiple characters compose a single cluster, the width of the entire
* cluster is divided equally among the characters.
+ *
+ * See also pango_glyph_item_get_logical_widths().
**/
void
pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
@@ -337,48 +339,15 @@ pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
int embedding_level,
int *logical_widths)
{
- /* Build a PangoGlyphItem so we can use PangoGlyphItemIter.
- * This API should have been made to take a PangoGlyphItem... */
+ /* Build a PangoGlyphItem and call the other API */
PangoItem item = {0, length, pango_utf8_strlen (text, length),
{NULL, NULL, NULL,
embedding_level, PANGO_GRAVITY_AUTO, 0,
PANGO_SCRIPT_UNKNOWN, NULL,
NULL}};
PangoGlyphItem glyph_item = {&item, glyphs};
- PangoGlyphItemIter iter;
- gboolean has_cluster;
- int dir;
-
- dir = embedding_level % 2 == 0 ? +1 : -1;
- for (has_cluster = pango_glyph_item_iter_init_start (&iter, &glyph_item, text);
- has_cluster;
- has_cluster = pango_glyph_item_iter_next_cluster (&iter))
- {
- int glyph_index, char_index, num_chars, cluster_width = 0, char_width;
-
- for (glyph_index = iter.start_glyph;
- glyph_index != iter.end_glyph;
- glyph_index += dir)
- {
- cluster_width += glyphs->glyphs[glyph_index].geometry.width;
- }
-
- num_chars = iter.end_char - iter.start_char;
- if (num_chars) /* pedantic */
- {
- char_width = cluster_width / num_chars;
- for (char_index = iter.start_char;
- char_index < iter.end_char;
- char_index++)
- {
- logical_widths[char_index] = char_width;
- }
-
- /* add any residues to the first char */
- logical_widths[iter.start_char] += cluster_width - (char_width * num_chars);
- }
- }
+ return pango_glyph_item_get_logical_widths (&glyph_item, text, logical_widths);
}
/* The initial implementation here is script independent,