[tt-font] Apply VVAR.vOrg variation to VORG origin

Mostly fixes https://github.com/harfbuzz/harfbuzz/issues/1694
This commit is contained in:
Behdad Esfahbod 2022-06-30 14:08:29 -06:00
parent eee29f7327
commit d5921b379b
2 changed files with 22 additions and 1 deletions

View File

@ -293,9 +293,20 @@ hb_ot_get_glyph_v_origin (hb_font_t *font,
const OT::VORG &VORG = *ot_face->VORG;
if (VORG.has_data ())
{
*y = font->em_scale_y (VORG.get_y_origin (glyph));
float delta = 0;
const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
const OT::VVAR &VVAR = *vmtx.var_table;
if (font->num_coords &&
!VVAR.get_vorg_var (glyph,
font->coords, font->num_coords,
&delta))
goto out;
*y = font->em_scale_y (VORG.get_y_origin (glyph) + delta);
return true;
}
out:
hb_glyph_extents_t extents = {0};
if (ot_face->glyf->get_extents (font, glyph, &extents))

View File

@ -392,6 +392,16 @@ struct VVAR : HVARVVAR {
bool subset (hb_subset_context_t *c) const { return HVARVVAR::_subset<VVAR> (c); }
bool get_vorg_var (hb_codepoint_t glyph,
const int *coords, unsigned int coord_count,
float *delta) const
{
if (!vorgMap) return false;
uint32_t varidx = (this+vorgMap).map (glyph);
*delta = (this+varStore).get_delta (varidx, coords, coord_count);
return true;
}
protected:
Offset32To<DeltaSetIndexMap>
vorgMap; /* Offset to vertical-origin var-idx mapping. */