[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
This commit is contained in:
Behdad Esfahbod committed 2026-08-12 18:48:32 -06:00
1 parent f531c3ffc7
commit b9e31281a0
1 file changed
+5 -5
+5 -5
View File
@@ -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: