diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 1695b1d8c..73af70f06 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -3351,7 +3351,7 @@ struct RuleSet skippy_iter.set_glyph_data ((HBUINT16 *) nullptr); unsigned unsafe_to = (unsigned) -1, unsafe_to1, unsafe_to2 = 0; hb_glyph_info_t *first = nullptr, *second = nullptr; - bool matched = skippy_iter.next (); + bool matched = skippy_iter.next (&unsafe_to1); if (likely (matched)) { if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx])) @@ -3373,16 +3373,22 @@ struct RuleSet } else { - /* Failed to match a next glyph. Only try applying rules that have - * no further input. */ - return_trace ( + bool unsafe_to_concat = false; + bool ret = + hb_iter (rule) | hb_map (hb_add (this)) - | hb_filter ([&] (const Rule &_) { return _.inputCount <= 1; }) + | hb_filter ([&] (const Rule &_) + { + if (_.inputCount <= 1) return true; + unsafe_to_concat = true; + return false; + }) | hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); }) | hb_any - ) ; + if (unsafe_to_concat) + c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to1); + return_trace (ret); } matched = skippy_iter.next (); if (likely (matched)) @@ -4939,7 +4945,7 @@ struct ChainRuleSet skippy_iter.set_glyph_data ((HBUINT16 *) nullptr); unsigned unsafe_to = (unsigned) -1, unsafe_to1, unsafe_to2 = 0; hb_glyph_info_t *first = nullptr, *second = nullptr; - bool matched = skippy_iter.next (); + bool matched = skippy_iter.next (&unsafe_to1); if (likely (matched)) { if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx])) @@ -4961,21 +4967,24 @@ struct ChainRuleSet } else { - /* Failed to match a next glyph. Only try applying rules that have - * no further input and lookahead. */ - return_trace ( + bool unsafe_to_concat = false; + bool ret = + hb_iter (rule) | hb_map (hb_add (this)) | hb_filter ([&] (const ChainRule &_) { const auto &input = StructAfter (_.backtrack); const auto &lookahead = StructAfter (input); - return input.lenP1 <= 1 && lookahead.len == 0; + if (input.lenP1 <= 1 && lookahead.len == 0) return true; + unsafe_to_concat = true; + return false; }) | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); }) | hb_any - ) ; + if (unsafe_to_concat) + c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to1); + return_trace (ret); } matched = skippy_iter.next (); if (likely (matched)) diff --git a/test/shape/data/in-house/fonts/c70495f304286cb87964400d03752ae5bc5622b9.ttf b/test/shape/data/in-house/fonts/c70495f304286cb87964400d03752ae5bc5622b9.ttf new file mode 100644 index 000000000..44a494fb5 Binary files /dev/null and b/test/shape/data/in-house/fonts/c70495f304286cb87964400d03752ae5bc5622b9.ttf differ diff --git a/test/shape/data/in-house/tests/unsafe-to-concat.tests b/test/shape/data/in-house/tests/unsafe-to-concat.tests index 226c994cd..81ae26e36 100644 --- a/test/shape/data/in-house/tests/unsafe-to-concat.tests +++ b/test/shape/data/in-house/tests/unsafe-to-concat.tests @@ -1,2 +1,4 @@ ../fonts/34da9aab7bee86c4dfc3b85e423435822fdf4b62.ttf;--show-flags --unsafe-to-concat;U+0628,U+200C,U+0628;[uni0628=1+993#2|uni0628=0+993#2] ../fonts/3113f846b81ea15c02e05a1c14fa65f9fd342143.otf;--features=test --no-glyph-names --no-positions --no-clusters --show-flags --unsafe-to-concat;U+0042,U+0041,U+0058,U+0042;[66|65#2|88#2|66] +../fonts/c70495f304286cb87964400d03752ae5bc5622b9.ttf;--features=ctxt --no-glyph-names --no-positions --no-clusters --show-flags --unsafe-to-concat;U+0041;[1#2] +../fonts/c70495f304286cb87964400d03752ae5bc5622b9.ttf;--features=chne --no-glyph-names --no-positions --no-clusters --show-flags --unsafe-to-concat;U+0041;[1#2]