Rewrite main normalizer loop to isolate runs of simple clusters

This commit is contained in:
Behdad Esfahbod 2018-10-09 14:33:24 -04:00
parent b5371f18ef
commit 24382debe8
1 changed files with 19 additions and 5 deletions

View File

@ -321,18 +321,32 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
buffer->clear_output (); buffer->clear_output ();
count = buffer->len; count = buffer->len;
for (buffer->idx = 0; buffer->idx < count && buffer->successful;) buffer->idx = 0;
do
{ {
unsigned int end; unsigned int end;
for (end = buffer->idx + 1; end < count; 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; 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); 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 (); buffer->swap_buffers ();