From cafaa1d886d9a80b97f647dcddc7aa1e3cd4b360 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 2 Oct 2026 11:20:28 -0600 Subject: [PATCH] [ot-font] Keep vertical origins available without variations The glyf vertical-origin path also handles static VARC-backed fonts, but its point aggregator and origin helper were hidden by HB_NO_VAR. The caller also accessed the absent gvar accelerator in that configuration. Keep the static-capable helpers available and guard only variation cache acquisition and release. Do not change glyph placement or origin math. Testing: C++11 syntax checks of harfbuzz-world.cc with and without HB_NO_VAR; full Meson suite: 281 passed, one skipped. Assisted-by: OpenAI Codex --- src/OT/glyf/glyf.hh | 4 +--- src/hb-ot-font.cc | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/OT/glyf/glyf.hh b/src/OT/glyf/glyf.hh index 0bda4b761..de84eb768 100644 --- a/src/OT/glyf/glyf.hh +++ b/src/OT/glyf/glyf.hh @@ -390,7 +390,6 @@ struct glyf_accelerator_t public: -#ifndef HB_NO_VAR struct points_aggregator_t { hb_font_t *font; @@ -485,6 +484,7 @@ struct glyf_accelerator_t : phantoms[glyf_impl::PHANTOM_RIGHT].x - phantoms[glyf_impl::PHANTOM_LEFT].x; return hb_clamp (roundf (result), 0.f, (float) UINT_MAX / 2); } +#endif float get_v_origin_with_var_unscaled (hb_codepoint_t gid, @@ -508,8 +508,6 @@ struct glyf_accelerator_t return phantoms[glyf_impl::PHANTOM_TOP].y; } -#endif -#endif public: diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index def97c5a4..38b406816 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -734,9 +734,12 @@ hb_ot_get_glyph_v_origins (hb_font_t *font, ot_font->v_origin.release_origin_cache (origin_cache); return false; } - OT::hb_scalar_cache_t *gvar_cache = font->has_nonzero_coords ? + OT::hb_scalar_cache_t *gvar_cache = nullptr; +#ifndef HB_NO_VAR + gvar_cache = font->has_nonzero_coords ? ot_font->draw.acquire_gvar_cache (*ot_face->gvar) : nullptr; +#endif for (unsigned i = 0; i < count; i++) { @@ -756,8 +759,10 @@ hb_ot_get_glyph_v_origins (hb_font_t *font, first_y = &StructAtOffsetUnaligned (first_y, y_stride); } +#ifndef HB_NO_VAR if (gvar_cache) ot_font->draw.release_gvar_cache (gvar_cache); +#endif glyf.release_scratch (scratch); ot_font->v_origin.release_origin_cache (origin_cache); return true;