Match backtrack/lookahead per syllable (#5635)

* [match-backtrack] Fix syllable-setting logic

If accidentally backtrack_len() was equal idx, we were setting
syllable, even though we want to match backtrack, which shouldn't
match syllable.

I'm surprised how this was not exposed before.

Fixes https://github.com/harfbuzz/harfbuzz/issues/5597

* Always match backtrack per syllable

* Always match lookahead per syllable as well

* Add Indic test for per-syllable backtrack/lookahead matching
This commit is contained in:
Behdad Esfahbod authored and GitHub committed 2025-11-04 13:49:52 -07:00
1 parent 844f2fea06
commit b11c14227f
5 files changed
+11 -2

No files matched your search

+9 -2
View File
@@ -523,9 +523,16 @@ struct skipping_iterator_t
#endif
void reset (unsigned int start_index_)
{
// For GSUB forward iterator
idx = start_index_;
end = c->buffer->len;
matcher.syllable = start_index_ == c->buffer->idx ? c->buffer->cur().syllable () : 0;
matcher.syllable = c->buffer->cur().syllable();
}
void reset_back (unsigned int start_index_, bool from_out_buffer = false)
{
// For GSUB backward iterator
idx = start_index_;
matcher.syllable = c->buffer->cur().syllable();
}
#ifndef HB_OPTIMIZE_SIZE
@@ -1554,7 +1561,7 @@ static bool match_backtrack (hb_ot_apply_context_t *c,
TRACE_APPLY (nullptr);
auto &skippy_iter = c->iter_context;
skippy_iter.reset (c->buffer->backtrack_len ());
skippy_iter.reset_back (c->buffer->backtrack_len ());
skippy_iter.set_match_func (match_func, match_data);
skippy_iter.set_glyph_data (backtrack);
@@ -4,3 +4,4 @@
../fonts/43ef465752be9af900745f72fe29cb853a1401a5.ttf;--cluster-level=1;U+05D4,U+05B7,U+05E9,U+05BC,U+05C1,U+05B8,U+05DE,U+05B4,U+05DD;[uni05DD=8+1359|uni05B4=7@111,0+0|uni05DE=6+1391|uni05B8=5+0|uni05BC=3+0|uni05C1=3+0|uni05E9=2+1451|uni05B7=1@28,0+0|uni05D4=0+1338]
../fonts/6f36d056bad6d478fc0bf7397bd52dc3bd197d5f.ttf;--cluster-level=1;U+099B,U+09CB,U+09C8,U+09C2,U+09CB,U+098C;[evowelsigninibeng=0+346|aivowelsignbeng=0+346|evowelsignbeng=0+346|chabeng=0+687|uuvowelsignlongbeng=0@-96,0+0|aavowelsignbeng=0+266|aavowelsignbeng=4+266|lvocalicbeng=5+639]
../fonts/fd07ea46e4d8368ada1776208c07fd596f727852.ttf;--cluster-level=1;U+0D4E,U+0D4D,U+200D;[uni0D4E=0+0|uni25CC=0+418|uni0D4D=0+0|space=0+0]
../fonts/c2d320136762887c43d245ecd2ffc2c0d57cfcb3.ttf;;U+0DAF,U+0DCF,U+0DAF;[dasinh=0+547|aavowelsignsinh=0+379|dasinh=2+532]
@@ -4,3 +4,4 @@
../fonts/5bbf3712e6f79775c66a4407837a90e591efbef2.ttf;;U+1F1FA,U+1F1FC;[gid3=0+2550]
../fonts/a59fd13f1525a91cbe529c882e93d9d1fbb80463.ttf;--font-funcs=ot;U+0041,U+0042;[gid4=0+1366|gid4=0+1366|gid4=0+1366|gid4=0+1366|gid5=1+1366]
../fonts/bef923f4ccb474f961c43b63a9c74b7d9b7a023f.ttf;;U+0061,U+002E,U+002E,U+002E;[a=0+600|SPC=1+600|SPC=2+600|period_period_period.liga=3+600]
../fonts/49bd922bd447fb15bb05abab5c7ceac8d547a3a2.ttf;;U+0995,U+09BE,U+09B9,U+09BF,U+09A8,U+09C0;[uni0995=0+807|uni09BE=0+266|uni09BF.short01=2+266|uni09B9=2+534|uni09A8=4+602|uni09C0=4+266]