fix empty glyf's advance width

This commit is contained in:
Michiharu Ariza 2019-03-18 17:16:43 -07:00
parent 511518c759
commit 10f264da75
2 changed files with 9 additions and 3 deletions

View File

@ -418,7 +418,13 @@ struct glyf
unsigned int num_points = 0;
unsigned int start_offset, end_offset;
if (unlikely (!get_offsets (glyph, &start_offset, &end_offset))) return false;
if (unlikely (end_offset - start_offset < GlyphHeader::static_size)) return false;
if (unlikely (end_offset - start_offset < GlyphHeader::static_size))
{
/* empty glyph */
points_.resize (PHANTOM_COUNT);
for (unsigned int i = 0; i < points_.length; i++) points_[i].init ();
return true;
}
CompositeGlyphHeader::Iterator composite;
if (get_composite (glyph, &composite))

View File

@ -37,7 +37,7 @@ int hmtxvmtx_accelerator_base_t::get_side_bearing_var_tt (hb_font_t *font, hb_co
float side_bearing = glyf_accel.get_side_bearing_var (glyph, font->coords, font->num_coords, vertical);
glyf_accel.fini ();
return (int)side_bearing;
return (int)roundf (side_bearing);
}
unsigned int hmtxvmtx_accelerator_base_t::get_advance_var_tt (hb_font_t *font, hb_codepoint_t glyph, bool vertical)
@ -48,7 +48,7 @@ unsigned int hmtxvmtx_accelerator_base_t::get_advance_var_tt (hb_font_t *font, h
float advance = glyf_accel.get_advance_var (glyph, font->coords, font->num_coords, vertical);
glyf_accel.fini ();
return (unsigned int)advance;
return (unsigned int)roundf (advance);
}
}