From 24382debe893450088acd1e4b387ac31145d4553 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 9 Oct 2018 14:33:24 -0400 Subject: [PATCH] Rewrite main normalizer loop to isolate runs of simple clusters --- src/hb-ot-shape-normalize.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 9436cb5ff..98830e499 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -321,18 +321,32 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, buffer->clear_output (); count = buffer->len; - for (buffer->idx = 0; buffer->idx < count && buffer->successful;) + buffer->idx = 0; + do { unsigned int end; for (end = buffer->idx + 1; end < count; end++) - if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[end])))) + if (unlikely (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[end])))) break; - if (likely (c.buffer->idx + 1 == end)) + if (end < count) + end--; /* Leave one base for the marks to cluster with. */ + + /* From i to end are simple clusters. */ + while (buffer->idx < end && buffer->successful) decompose_current_character (&c, might_short_circuit); - else - decompose_multi_char_cluster (&c, end, always_short_circuit); + + if (buffer->idx == count || !buffer->successful) + break; + + /* Find all the marks now. */ + for (end = buffer->idx + 1; end < count; end++) + if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[end]))) + break; + + decompose_multi_char_cluster (&c, end, always_short_circuit); } + while (buffer->idx < count && buffer->successful); buffer->swap_buffers ();