From c7edd14dc96af59cb53e9560a45f48d809fe8bb1 Mon Sep 17 00:00:00 2001 From: Michiharu Ariza Date: Mon, 18 Mar 2019 17:16:43 -0700 Subject: [PATCH] fix empty glyf's advance width --- src/hb-ot-glyf-table.hh | 8 +++++++- src/hb-ot-hmtx-table.cc | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index f60655fa8..06a799d20 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -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)) diff --git a/src/hb-ot-hmtx-table.cc b/src/hb-ot-hmtx-table.cc index d686fe3b8..69b0f365f 100644 --- a/src/hb-ot-hmtx-table.cc +++ b/src/hb-ot-hmtx-table.cc @@ -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); } }