[var] Fix getting side-bearing variations

In HVAR/VVAR, if the side-bearing mappings are null, it means the
table does not have them and they should be loaded from glyf table.
Previous logic was returning zer0.

Part of fixing https://github.com/harfbuzz/harfbuzz/issues/1694
This commit is contained in:
Behdad Esfahbod 2022-07-02 11:21:36 -06:00
parent 78b4f39821
commit 71d52e10aa
2 changed files with 9 additions and 8 deletions

View File

@ -241,8 +241,9 @@ struct hmtxvmtx
if (unlikely (glyph >= num_bearings) || !font->num_coords)
return side_bearing;
if (var_table.get_length ())
return side_bearing + var_table->get_side_bearing_var (glyph, font->coords, font->num_coords);
float lsb;
if (var_table->get_side_bearing_var (glyph, font->coords, font->num_coords, &lsb))
return side_bearing + lsb;
return _glyf_get_side_bearing_var (font, glyph, T::tableTag == HB_OT_TAG_vmtx);
#else

View File

@ -329,16 +329,16 @@ struct HVARVVAR
store_cache);
}
float get_side_bearing_var (hb_codepoint_t glyph,
const int *coords, unsigned int coord_count) const
bool get_side_bearing_var (hb_codepoint_t glyph,
const int *coords, unsigned int coord_count,
float *lsb) const
{
if (!has_side_bearing_deltas ()) return 0.f;
if (!lsbMap) return false;
uint32_t varidx = (this+lsbMap).map (glyph);
return (this+varStore).get_delta (varidx, coords, coord_count);
*lsb = (this+varStore).get_delta (varidx, coords, coord_count);
return true;
}
bool has_side_bearing_deltas () const { return lsbMap && rsbMap; }
public:
FixedVersion<>version; /* Version of the metrics variation table
* initially set to 0x00010000u */