[HVAR] Cache VarStore region scalars

pull/3605/head
Behdad Esfahbod 3 years ago
parent 880f50f7e4
commit 5336ba70f6
  1. 8
      src/hb-ot-font.cc
  2. 9
      src/hb-ot-hmtx-table.hh
  3. 11
      src/hb-ot-var-hvar-table.hh

@ -110,12 +110,18 @@ 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;
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;
for (unsigned int i = 0; i < count; i++)
{
*first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font));
*first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font, cache));
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
}
OT::VariationStore::destroy_cache (cache);
}
#ifndef HB_NO_VERTICAL

@ -242,7 +242,7 @@ struct hmtxvmtx
return side_bearing;
if (var_table.get_length ())
return side_bearing + var_table->get_side_bearing_var (glyph, font->coords, font->num_coords); // TODO Optimize?!
return side_bearing + var_table->get_side_bearing_var (glyph, font->coords, font->num_coords);
return _glyf_get_side_bearing_var (font, glyph, T::tableTag == HB_OT_TAG_vmtx);
#else
@ -284,7 +284,8 @@ struct hmtxvmtx
}
unsigned int get_advance (hb_codepoint_t glyph,
hb_font_t *font) const
hb_font_t *font,
VariationStore::cache_t *store_cache = nullptr) const
{
unsigned int advance = get_advance (glyph);
@ -293,7 +294,7 @@ struct hmtxvmtx
return advance;
if (var_table.get_length ())
return advance + roundf (var_table->get_advance_var (glyph, font)); // TODO Optimize?!
return advance + roundf (var_table->get_advance_var (glyph, font, store_cache)); // TODO Optimize?!
return _glyf_get_advance_var (font, glyph, T::tableTag == HB_OT_TAG_vmtx);
#else
@ -310,7 +311,7 @@ struct hmtxvmtx
unsigned int default_advance;
private:
public:
hb_blob_ptr_t<hmtxvmtx> table;
hb_blob_ptr_t<HVARVVAR> var_table;
};

@ -319,10 +319,15 @@ struct HVARVVAR
hvar_plan.index_map_plans.as_array ()));
}
float get_advance_var (hb_codepoint_t glyph, hb_font_t *font) const
float get_advance_var (hb_codepoint_t glyph,
hb_font_t *font,
VariationStore::cache_t *store_cache = nullptr) const
{
uint32_t varidx = (this+advMap).map (glyph);
return (this+varStore).get_delta (varidx, font->coords, font->num_coords);
return (this+varStore).get_delta (varidx,
font->coords,
font->num_coords,
store_cache);
}
float get_side_bearing_var (hb_codepoint_t glyph,
@ -335,7 +340,7 @@ struct HVARVVAR
bool has_side_bearing_deltas () const { return lsbMap && rsbMap; }
protected:
public:
FixedVersion<>version; /* Version of the metrics variation table
* initially set to 0x00010000u */
Offset32To<VariationStore>

Loading…
Cancel
Save