Index: third_party/harfbuzz-ng/src/hb-ot-shape-normalize.cc |
diff --git a/third_party/harfbuzz-ng/src/hb-ot-shape-normalize.cc b/third_party/harfbuzz-ng/src/hb-ot-shape-normalize.cc |
index 6531e1b215caba8b2a45a82e22ec876ef7e88896..2a6a4390030313bd265d067db2d502a04b4d95d8 100644 |
--- a/third_party/harfbuzz-ng/src/hb-ot-shape-normalize.cc |
+++ b/third_party/harfbuzz-ng/src/hb-ot-shape-normalize.cc |
@@ -213,8 +213,9 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor |
} |
static inline void |
-handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end) |
+handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool short_circuit) |
{ |
+ /* TODO Currently if there's a variation-selector we give-up, it's just too hard. */ |
hb_buffer_t * const buffer = c->buffer; |
hb_font_t * const font = c->font; |
for (; buffer->idx < end - 1;) { |
@@ -250,27 +251,26 @@ handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns |
} |
static inline void |
-decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end) |
+decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool short_circuit) |
{ |
hb_buffer_t * const buffer = c->buffer; |
- /* TODO Currently if there's a variation-selector we give-up, it's just too hard. */ |
for (unsigned int i = buffer->idx; i < end; i++) |
if (unlikely (buffer->unicode->is_variation_selector (buffer->info[i].codepoint))) { |
- handle_variation_selector_cluster (c, end); |
+ handle_variation_selector_cluster (c, end, short_circuit); |
return; |
} |
while (buffer->idx < end) |
- decompose_current_character (c, false); |
+ decompose_current_character (c, short_circuit); |
} |
static inline void |
-decompose_cluster (const hb_ot_shape_normalize_context_t *c, bool short_circuit, unsigned int end) |
+decompose_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool might_short_circuit, bool always_short_circuit) |
{ |
if (likely (c->buffer->idx + 1 == end)) |
- decompose_current_character (c, short_circuit); |
+ decompose_current_character (c, might_short_circuit); |
else |
- decompose_multi_char_cluster (c, end); |
+ decompose_multi_char_cluster (c, end, always_short_circuit); |
} |
@@ -289,9 +289,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, |
hb_buffer_t *buffer, |
hb_font_t *font) |
{ |
- hb_ot_shape_normalization_mode_t mode = plan->shaper->normalization_preference ? |
- plan->shaper->normalization_preference (&buffer->props) : |
- HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT; |
+ hb_ot_shape_normalization_mode_t mode = plan->shaper->normalization_preference; |
const hb_ot_shape_normalize_context_t c = { |
plan, |
buffer, |
@@ -301,8 +299,10 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, |
plan->shaper->compose ? plan->shaper->compose : compose_unicode |
}; |
- bool short_circuit = mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED && |
- mode != HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT; |
+ bool always_short_circuit = mode == HB_OT_SHAPE_NORMALIZATION_MODE_NONE; |
+ bool might_short_circuit = always_short_circuit || |
+ (mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED && |
+ mode != HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT); |
unsigned int count; |
/* We do a fairly straightforward yet custom normalization process in three |
@@ -323,7 +323,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, |
if (buffer->cur().cluster != buffer->info[end].cluster) |
break; |
- decompose_cluster (&c, short_circuit, end); |
+ decompose_cluster (&c, end, might_short_circuit, always_short_circuit); |
} |
buffer->swap_buffers (); |
@@ -355,7 +355,8 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, |
} |
- if (mode == HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED) |
+ if (mode == HB_OT_SHAPE_NORMALIZATION_MODE_NONE || |
+ mode == HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED) |
return; |
/* Third round, recompose */ |
@@ -393,8 +394,9 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, |
return; |
buffer->merge_out_clusters (starter, buffer->out_len); |
buffer->out_len--; /* Remove the second composable. */ |
- buffer->out_info[starter].codepoint = composed; /* Modify starter and carry on. */ |
- set_glyph (buffer->out_info[starter], font); |
+ /* Modify starter and carry on. */ |
+ buffer->out_info[starter].codepoint = composed; |
+ buffer->out_info[starter].glyph_index() = glyph; |
_hb_glyph_info_set_unicode_props (&buffer->out_info[starter], buffer->unicode); |
continue; |