font/shaper: prevent underflow in multi-cell lig detection

Fixes #1251

See the comment for details.
This commit is contained in:
Mitchell Hashimoto
2024-01-07 22:16:11 -08:00
parent e63870c094
commit 2082751a65

View File

@ -182,7 +182,12 @@ pub const Shaper = struct {
// multiple can be replaced. e.g. "==="
for (info[i + 1 ..]) |next_info_v| {
if (next_info_v.cluster != info_v.cluster) {
break :width next_info_v.cluster - info_v.cluster;
// We do a saturating sub here because for RTL
// text, the next cluster can be less than the
// current cluster. We don't really support RTL
// currently so we do this to prevent an underflow
// but it isn't correct generally.
break :width next_info_v.cluster -| info_v.cluster;
}
}
}