[trak] Saturate tracking advances

AAT tracking adds the selected tracking value to the first glyph of
each grapheme. Saturate horizontal and vertical advance updates so an
extreme scale or repeated application cannot overflow hb_position_t.

This is part of the complete position-overflow fix for issue #6151.

Testing: meson test -C build --print-errorlogs

Assisted-by: Codex <codex@openai.com>
This commit is contained in:
Behdad Esfahbod committed 2026-08-12 17:31:45 -06:00
1 parent d9bd6e9895
commit 91b07e93d4
1 file changed
+2 -2
+2 -2
View File
@@ -230,13 +230,13 @@ struct trak
{
hb_position_t advance_to_add = get_h_tracking (c->font, track);
foreach_grapheme (buffer, start, end)
buffer->pos[start].x_advance += advance_to_add;
buffer->pos[start].x_advance = hb_saturate_add (buffer->pos[start].x_advance, advance_to_add);
}
else
{
hb_position_t advance_to_add = get_v_tracking (c->font, track);
foreach_grapheme (buffer, start, end)
buffer->pos[start].y_advance += advance_to_add;
buffer->pos[start].y_advance = hb_saturate_add (buffer->pos[start].y_advance, advance_to_add);
}
return_trace (true);