[instancer] no need to create hb_font_t object when fetching delta from varstore

This commit is contained in:
Qunxin Liu 2023-04-27 11:17:24 -07:00 committed by Behdad Esfahbod
parent 58f79063bb
commit b9b85da3c9
2 changed files with 8 additions and 15 deletions

View file

@ -189,7 +189,7 @@ struct hb_collect_variation_indices_context_t :
hb_set_t *layout_variation_indices;
hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *varidx_delta_map;
hb_font_t *font;
hb_vector_t<int> *normalized_coords;
const VariationStore *var_store;
const hb_set_t *glyph_set;
const hb_map_t *gpos_lookups;
@ -197,14 +197,14 @@ struct hb_collect_variation_indices_context_t :
hb_collect_variation_indices_context_t (hb_set_t *layout_variation_indices_,
hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *varidx_delta_map_,
hb_font_t *font_,
hb_vector_t<int> *normalized_coords_,
const VariationStore *var_store_,
const hb_set_t *glyph_set_,
const hb_map_t *gpos_lookups_,
float *store_cache_) :
layout_variation_indices (layout_variation_indices_),
varidx_delta_map (varidx_delta_map_),
font (font_),
normalized_coords (normalized_coords_),
var_store (var_store_),
glyph_set (glyph_set_),
gpos_lookups (gpos_lookups_),
@ -3547,8 +3547,9 @@ struct VariationDevice
{
c->layout_variation_indices->add (varIdx);
int delta = 0;
if (c->font && c->var_store)
delta = roundf (get_delta (c->font, *c->var_store, c->store_cache));
if (c->normalized_coords && c->var_store)
delta = roundf (c->var_store->get_delta (varIdx, c->normalized_coords->arrayZ,
c->normalized_coords->length, c->store_cache));
/* set new varidx to HB_OT_LAYOUT_NO_VARIATIONS_INDEX here, will remap
* varidx later*/

View file

@ -381,18 +381,10 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan)
const OT::VariationStore *var_store = nullptr;
hb_set_t varidx_set;
hb_font_t *font = nullptr;
float *store_cache = nullptr;
bool collect_delta = plan->pinned_at_default ? false : true;
if (collect_delta)
{
if (unlikely (!plan->check_success (font = _get_hb_font_with_variations (plan)))) {
hb_font_destroy (font);
gdef.destroy ();
gpos.destroy ();
return;
}
if (gdef->has_var_store ())
{
var_store = &(gdef->get_var_store ());
@ -402,7 +394,8 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan)
OT::hb_collect_variation_indices_context_t c (&varidx_set,
&plan->layout_variation_idx_delta_map,
font, var_store,
plan->normalized_coords ? &(plan->normalized_coords) : nullptr,
var_store,
&plan->_glyphset_gsub,
&plan->gpos_lookups,
store_cache);
@ -411,7 +404,6 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan)
if (hb_ot_layout_has_positioning (plan->source))
gpos->collect_variation_indices (&c);
hb_font_destroy (font);
var_store->destroy_cache (store_cache);
gdef->remap_layout_variation_indices (&varidx_set, &plan->layout_variation_idx_delta_map);