From 7cc348041d0b026ca6d2c240134e8f9100600e99 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 4 Sep 2017 20:04:59 -0700 Subject: [PATCH] [unsafe-to-break] Fix unsafe-to-break for cluster-level=1 Fixes tests/shaping/tests/cluster.tests --- src/hb-ot-shape.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 54c33a3e1..8cd8fcc17 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -275,8 +275,7 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font) static void hb_form_clusters (hb_buffer_t *buffer) { - if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII) || - buffer->cluster_level != HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) + if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII)) return; /* Loop duplicated in hb_ensure_native_direction(), and in _hb-coretext.cc */ @@ -288,11 +287,17 @@ hb_form_clusters (hb_buffer_t *buffer) if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[i])) && !_hb_glyph_info_is_joiner (&info[i]))) { - buffer->merge_clusters (base, i); + if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) + buffer->merge_clusters (base, i); + else + buffer->unsafe_to_break (base, i); base = i; } } - buffer->merge_clusters (base, count); + if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) + buffer->merge_clusters (base, count); + else + buffer->unsafe_to_break (base, count); } static void @@ -580,8 +585,6 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c) { hb_buffer_t *buffer = c->buffer; - hb_ot_shape_initialize_masks (c); - hb_ot_mirror_chars (c); HB_BUFFER_ALLOCATE_VAR (buffer, glyph_index); @@ -836,8 +839,10 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) c->buffer->clear_output (); + hb_ot_shape_initialize_masks (c); hb_set_unicode_props (c->buffer); hb_insert_dotted_circle (c->buffer, c->font); + hb_form_clusters (c->buffer); hb_ensure_native_direction (c->buffer);