[ot-font] Only use vmtx side-bearing if table exists

Part of fixing https://github.com/harfbuzz/harfbuzz/issues/537
This commit is contained in:
Behdad Esfahbod 2022-03-21 21:07:11 -06:00
parent f41945e313
commit 6d0e67dee0
3 changed files with 5 additions and 1 deletions

View File

@ -382,6 +382,7 @@ hb_ft_get_glyph_v_advance (hb_font_t *font,
/* Note: FreeType's vertical metrics grows downward while other FreeType coordinates /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates
* have a Y growing upward. Hence the extra negation. */ * have a Y growing upward. Hence the extra negation. */
return (-v + (1<<9)) >> 10; return (-v + (1<<9)) >> 10;
} }
#endif #endif

View File

@ -161,7 +161,8 @@ hb_ot_get_glyph_v_origin (hb_font_t *font,
} }
hb_glyph_extents_t extents = {0}; hb_glyph_extents_t extents = {0};
if (ot_face->glyf->get_extents (font, glyph, &extents)) if (ot_face->vmtx->has_data () &&
ot_face->glyf->get_extents (font, glyph, &extents))
{ {
const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx; const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
hb_position_t tsb = vmtx.get_side_bearing (font, glyph); hb_position_t tsb = vmtx.get_side_bearing (font, glyph);

View File

@ -220,6 +220,8 @@ struct hmtxvmtx
var_table.destroy (); var_table.destroy ();
} }
bool has_data () const { return (bool) num_bearings; }
int get_side_bearing (hb_codepoint_t glyph) const int get_side_bearing (hb_codepoint_t glyph) const
{ {
if (glyph < num_long_metrics) if (glyph < num_long_metrics)