[font] Saturate synthetic contour points

Synthetic slant and emboldening add adjustments to full-range contour
coordinates.  Keep the slant calculation in float, clamp its rounded
delta, and saturate both additions.

Tested with: meson test -C build --print-errorlogs

Assisted-by: OpenAI Codex
This commit is contained in:
Behdad Esfahbod committed 2026-08-12 18:52:43 -06:00
1 parent b9e31281a0
commit d09f9bbc21
1 file changed
+4 -3
+4 -3
View File
@@ -667,13 +667,14 @@ struct hb_font_t
{
/* Slant */
if (slant_xy)
*x += roundf (*y * slant_xy);
*x = hb_saturate_add (*x,
hb_clamp_to<hb_position_t> (roundf (*y * slant_xy)));
/* Embolden */
if (!embolden_in_place)
{
int x_shift = x_scale < 0 ? -x_strength : x_strength;
*x += x_shift;
hb_position_t x_shift = x_scale < 0 ? hb_saturate_neg (x_strength) : x_strength;
*x = hb_saturate_add (*x, x_shift);
}
}