From b9e31281a03357f5176409cbfc9cfc3d4402a92b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Aug 2026 18:48:32 -0600 Subject: [PATCH] [fallback] Widen space advance formulas Fallback space advances negate, round, and multiply the font scale. Perform those operations in 64-bit arithmetic so full-range scales do not overflow before the final, bounded division. Tested with: meson test -C build --print-errorlogs Assisted-by: OpenAI Codex --- src/hb-ot-shape-fallback.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc index e00eb9af7..acf55c76a 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -573,7 +573,7 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, if (horizontal) pos[i].x_advance = +font->x_scale / 4; else - pos[i].y_advance = -font->y_scale / 4; + pos[i].y_advance = -(int64_t) font->y_scale / 4; } hb_unicode_funcs_t::space_t space_type = _hb_glyph_info_get_unicode_space_fallback_type (&info[i]); @@ -593,16 +593,16 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, case t::SPACE_EM_6: case t::SPACE_EM_16: if (horizontal) - pos[i].x_advance = +(font->x_scale + ((int) space_type)/2) / (int) space_type; + pos[i].x_advance = ((int64_t) font->x_scale + ((int) space_type)/2) / (int) space_type; else - pos[i].y_advance = -(font->y_scale + ((int) space_type)/2) / (int) space_type; + pos[i].y_advance = -((int64_t) font->y_scale + ((int) space_type)/2) / (int) space_type; break; case t::SPACE_4_EM_18: if (horizontal) - pos[i].x_advance = (int64_t) +font->x_scale * 4 / 18; + pos[i].x_advance = (int64_t) font->x_scale * 4 / 18; else - pos[i].y_advance = (int64_t) -font->y_scale * 4 / 18; + pos[i].y_advance = -(int64_t) font->y_scale * 4 / 18; break; case t::SPACE_FIGURE: