From d09f9bbc218f1a224ce2a2bc79c55ed85f7af306 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Aug 2026 18:52:43 -0600 Subject: [PATCH] [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 --- src/hb-font.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hb-font.hh b/src/hb-font.hh index 5e02ca79f..c2b805a49 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -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 (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); } }