From eb4e60290fe5fcb28790ae9970afcc0e2a8ed6ea Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Aug 2026 17:48:20 -0600 Subject: [PATCH] [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 --- src/hb-font.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-font.hh b/src/hb-font.hh index f07e69f07..d567c8d23 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -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