summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2012-09-27 14:08:30 -0400
committerBehdad Esfahbod <behdad@behdad.org>2012-09-27 14:08:30 -0400
commit0d34c10108585b4cfed042aa2ef501780b2d2193 (patch)
tree67b583b307bbba28e9aaa403959b95419ecb3281 /modules
parent97fa7a8d7018a0a7747e5663066d1383bba83fb7 (diff)
downloadpango-0d34c10108585b4cfed042aa2ef501780b2d2193.tar.gz
Fixup grapheme clusters
After adding pango_shape_full() and passing full paragraph text to HarfBuzz, we were getting cluster values relative to beginning to paragraph back from HarfBuzz, and I forgot to account for that. Caused severe crashes. Fixes: Bug 684959 - crash after "Add pango_shape_full()" and the dupes...
Diffstat (limited to 'modules')
-rw-r--r--modules/basic/basic-fc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c
index ef0277ea..991ad299 100644
--- a/modules/basic/basic-fc.c
+++ b/modules/basic/basic-fc.c
@@ -317,6 +317,7 @@ basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
hb_glyph_position_t *hb_position;
int last_cluster;
guint i, num_glyphs;
+ unsigned int item_offset = item_text - paragraph_text;
g_return_if_fail (font != NULL);
g_return_if_fail (analysis != NULL);
@@ -362,7 +363,7 @@ basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
hb_buffer_set_script (hb_buffer, hb_glib_script_to_script (analysis->script));
hb_buffer_set_language (hb_buffer, hb_language_from_string (pango_language_to_string (analysis->language), -1));
- hb_buffer_add_utf8 (hb_buffer, paragraph_text, paragraph_length, item_text - paragraph_text, item_length);
+ hb_buffer_add_utf8 (hb_buffer, paragraph_text, paragraph_length, item_offset, item_length);
hb_shape (hb_font, hb_buffer, NULL, 0);
if (PANGO_GRAVITY_IS_IMPROPER (analysis->gravity))
@@ -376,7 +377,7 @@ basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
for (i = 0; i < num_glyphs; i++)
{
glyphs->glyphs[i].glyph = hb_glyph->codepoint;
- glyphs->log_clusters[i] = hb_glyph->cluster;
+ glyphs->log_clusters[i] = hb_glyph->cluster - item_offset;
glyphs->glyphs[i].attr.is_cluster_start = glyphs->log_clusters[i] != last_cluster;
hb_glyph++;
last_cluster = glyphs->log_clusters[i];