From 71d52e10aa353ab5e6161c66aeb00fcc68d510da Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 2 Jul 2022 11:21:36 -0600 Subject: [PATCH] [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 --- src/hb-ot-hmtx-table.hh | 5 +++-- src/hb-ot-var-hvar-table.hh | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh index c9192fa60..421c914f8 100644 --- a/src/hb-ot-hmtx-table.hh +++ b/src/hb-ot-hmtx-table.hh @@ -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 diff --git a/src/hb-ot-var-hvar-table.hh b/src/hb-ot-var-hvar-table.hh index 38a392ed7..c9ecc08eb 100644 --- a/src/hb-ot-var-hvar-table.hh +++ b/src/hb-ot-var-hvar-table.hh @@ -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 */