From 3eb7eff487f5aa3abaf5f7e1e40f96cb1de1c364 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 21 May 2022 15:25:53 -0600 Subject: [PATCH] Remove varstore cache use if HB_NO_VAR --- src/hb-ot-font.cc | 12 ++++++++++++ src/hb-ot-layout-gsubgpos.hh | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index f1e7479f2..521b3ee92 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -110,9 +110,13 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data; const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx; +#ifndef HB_NO_VAR const OT::HVARVVAR &HVAR = *hmtx.var_table; const OT::VariationStore &varStore = &HVAR + HVAR.varStore; OT::VariationStore::cache_t *cache = font->num_coords ? varStore.create_cache () : nullptr; +#else + OT::VariationStore::cache_t *cache = nullptr; +#endif for (unsigned int i = 0; i < count; i++) { @@ -121,7 +125,9 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } +#ifndef HB_NO_VAR OT::VariationStore::destroy_cache (cache); +#endif } #ifndef HB_NO_VERTICAL @@ -139,9 +145,13 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data, if (vmtx.has_data ()) { +#ifndef HB_NO_VAR const OT::HVARVVAR &VVAR = *vmtx.var_table; const OT::VariationStore &varStore = &VVAR + VVAR.varStore; OT::VariationStore::cache_t *cache = font->num_coords ? varStore.create_cache () : nullptr; +#else + OT::VariationStore::cache_t *cache = nullptr; +#endif for (unsigned int i = 0; i < count; i++) { @@ -150,7 +160,9 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data, first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } +#ifndef HB_NO_VAR OT::VariationStore::destroy_cache (cache); +#endif } else { diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index c2e043a60..d45499fd4 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -660,7 +660,13 @@ struct hb_ot_apply_context_t : #endif ), var_store (gdef.get_var_store ()), - var_store_cache (table_index == 1 && font->num_coords ? var_store.create_cache () : nullptr), + var_store_cache ( +#ifndef HB_NO_VAR + table_index == 1 && font->num_coords ? var_store.create_cache () : nullptr +#else + nullptr +#endif + ), direction (buffer_->props.direction), lookup_mask (1), lookup_index ((unsigned int) -1), @@ -674,7 +680,12 @@ struct hb_ot_apply_context_t : random_state (1) { init_iters (); } - ~hb_ot_apply_context_t () { VariationStore::destroy_cache (var_store_cache); } + ~hb_ot_apply_context_t () + { +#ifndef HB_NO_VAR + VariationStore::destroy_cache (var_store_cache); +#endif + } void init_iters () {