[font] Saturate fallback origin conversion

Bulk origin fallback converts between horizontal and vertical origins
by adding advances and ascenders. Saturate those temporary position
updates before applying them to the buffer.

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:48:20 -06:00
1 parent 5528a71752
commit eb4e60290f
1 file changed
+4 -4
+4 -4
View File
@@ -905,8 +905,8 @@ struct hb_font_t
for (unsigned j = 0; j < n; j++)
{
hb_codepoint_t glyph = buf->info[offset + j].codepoint;
origins[j].x -= get_glyph_h_advance (glyph) / 2;
origins[j].y -= ascender;
origins[j].x = hb_saturate_sub (origins[j].x, get_glyph_h_advance (glyph) / 2);
origins[j].y = hb_saturate_sub (origins[j].y, ascender);
}
}
else
@@ -969,8 +969,8 @@ struct hb_font_t
for (unsigned j = 0; j < n; j++)
{
hb_codepoint_t glyph = buf->info[offset + j].codepoint;
origins[j].x += get_glyph_h_advance (glyph) / 2;
origins[j].y += ascender;
origins[j].x = hb_saturate_add (origins[j].x, get_glyph_h_advance (glyph) / 2);
origins[j].y = hb_saturate_add (origins[j].y, ascender);
}
}
else