Remove varstore cache use if HB_NO_VAR

This commit is contained in:
Behdad Esfahbod 2022-05-21 15:25:53 -06:00
parent 099482a37a
commit 3eb7eff487
2 changed files with 25 additions and 2 deletions

View File

@ -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<hb_position_t> (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<hb_position_t> (first_advance, advance_stride);
}
#ifndef HB_NO_VAR
OT::VariationStore::destroy_cache (cache);
#endif
}
else
{

View File

@ -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 ()
{