Files
harfbuzz/test/shape/data
nussaibah shaikh 6c8fe9f278 [aat] Don't divide by zero interpolating duplicate trak tracks (#6425)
* Don't divide by zero interpolating duplicate trak tracks

TrackData::get_tracking() brackets the requested track value (always
0 when shaping) between entries i and j and interpolates with
(track - t0) / (t1 - t0).  The bracketing scan doesn't assume the
entries are sorted or distinct, so two entries that both have track
value 0.0 end with i = 1, j = 0.  That skips the exact-match return
and computes 0/0.  The NaN reaches hb_font_t::em_multf(), where the
cast to hb_position_t is undefined (UBSan float-cast-overflow at
hb-font.hh:1167); in practice the advance becomes INT_MIN on x86 and
the tracking is dropped on arm64.

Sanitize accepts such a table, so any font with STAT plus this trak
reaches it from hb_shape(); the CoreText font funcs call the same
getter.

Handle t0 == t1 the way TrackTableEntry::interpolate_at() already
handles equal sizes, by averaging the two values.

Added a 108-byte font to the aat-trak shape tests.  It fails without
the fix and passes with it.  meson test passes on an ASan+UBSan
debug build.

Assisted-by: Claude

* [aat] Pin duplicate-trak test to ot font funcs

The 108-byte test font only carries STAT and trak, with no head,
hhea or hmtx.  The ot font funcs give each glyph a 500 advance, but
FreeType reports 1000 and DirectWrite refuses to load the font, so
the ft and directwrite runs of the test disagreed with the expected
output.  The test only needs to exercise the trak interpolation,
so pin it to --font-funcs=ot like other minimal-font tests.

Tested with meson test -C build; the shape suites pass with
FreeType enabled.

Assisted-by: Claude
2026-10-27 14:44:18 -06:00
..