mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-26 01:11:25 +01:00
hb-ft's vertical-origin callback cached a full origin -- x, y, and a load-failure flag -- in a bespoke 256-entry direct-mapped cache, because hb_cache_t holds only a single non-negative integer. Do what hb-ot does instead. The vertical origin's x is half the glyph's horizontal advance, already cached for horizontal advances, so only y needs a cache of its own, and y fits hb_cache_t once its sign is normalized the way hb-ot normalizes the origin. v_origins now fills x from hb_ft_get_glyph_h_advances() before taking the lock and caches only y; the custom cache and its origin struct are removed. This changes the origin's x for fonts whose FreeType vertical bearing does not center the glyph (eg. a proportional font laid out vertically): x was horiBearingX - vertBearingX and is now advance/2, which matches hb-ot. For CJK and other centered glyphs it is unchanged. A FreeType load failure is no longer turned into a failed origin that sent the whole run to the caller's fallback. The glyph will not render, so its y origin is cached as 0 and the rest of the run keeps its real origins. Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-Y24FNCOQ. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>