From 0edab286ee2916d5a45993eae5aa284acd48d1e2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 2 Dec 2023 07:01:24 -0500 Subject: [PATCH] [matcher] Make per-syllable explicit The logic here was made to enable per-syllable matching for input, and not for backtrack/lookahead. However, if input-length is 1, this was setting per-syllable for lookahead, which caused the following: https://github.com/harfbuzz/harfbuzz/discussions/4509 I have no idea why the tests are failing. Needs investigation. I also have no idea why this was not discovered before. --- src/hb-ot-layout-gsubgpos.hh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 499ad673e..370c30fe5 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -518,11 +518,14 @@ struct hb_ot_apply_context_t : #ifndef HB_OPTIMIZE_SIZE HB_ALWAYS_INLINE #endif - void reset (unsigned int start_index_) + void reset (unsigned int start_index_, bool per_syllable = true) { idx = start_index_; end = c->buffer->len; - matcher.set_syllable (start_index_ == c->buffer->idx ? c->buffer->cur().syllable () : 0); + if (per_syllable) + matcher.set_syllable (start_index_ == c->buffer->idx ? c->buffer->cur().syllable () : 0); + else + matcher.set_syllable (0); } #ifndef HB_OPTIMIZE_SIZE @@ -1505,7 +1508,7 @@ static bool match_backtrack (hb_ot_apply_context_t *c, TRACE_APPLY (nullptr); hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; - skippy_iter.reset (c->buffer->backtrack_len ()); + skippy_iter.reset (c->buffer->backtrack_len (), false); skippy_iter.set_match_func (match_func, match_data); skippy_iter.set_glyph_data (backtrack); @@ -1538,7 +1541,7 @@ static bool match_lookahead (hb_ot_apply_context_t *c, TRACE_APPLY (nullptr); hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; - skippy_iter.reset (start_index - 1); + skippy_iter.reset (start_index - 1, false); skippy_iter.set_match_func (match_func, match_data); skippy_iter.set_glyph_data (lookahead);