[instance] we need to update hmtx/vmtx values even for empty glyphs

Update metrics using the 4 phantom points
This commit is contained in:
Qunxin Liu 2022-08-24 14:16:55 -07:00
parent 7d7b492344
commit 8b7e2a1373
1 changed files with 14 additions and 8 deletions

View File

@ -101,14 +101,12 @@ struct Glyph
const contour_point_vector_t &all_points, const contour_point_vector_t &all_points,
hb_bytes_t &dest_bytes /* OUT */) const hb_bytes_t &dest_bytes /* OUT */) const
{ {
if (all_points.length == 4) //Empty glyph GlyphHeader *glyph_header = nullptr;
if (all_points.length > 4)
{ {
dest_bytes = hb_bytes_t (); glyph_header = (GlyphHeader *) hb_calloc (1, GlyphHeader::static_size);
return true;
}
GlyphHeader *glyph_header = (GlyphHeader *) hb_calloc (1, GlyphHeader::static_size);
if (unlikely (!glyph_header)) return false; if (unlikely (!glyph_header)) return false;
}
int xMin, xMax; int xMin, xMax;
xMin = xMax = roundf (all_points[0].x); xMin = xMax = roundf (all_points[0].x);
@ -128,6 +126,11 @@ struct Glyph
update_mtx (plan, xMin, yMax, all_points); update_mtx (plan, xMin, yMax, all_points);
/*for empty glyphs: all_points only include phantom points.
*just update metrics and then return */
if (all_points.length == 4)
return true;
glyph_header->numberOfContours = header->numberOfContours; glyph_header->numberOfContours = header->numberOfContours;
glyph_header->xMin = xMin; glyph_header->xMin = xMin;
glyph_header->yMin = yMin; glyph_header->yMin = yMin;
@ -161,8 +164,11 @@ struct Glyph
return false; return false;
break; break;
default: default:
//no need to compile empty glyph (.notdef) /* set empty bytes for empty glyph
return true; * do not use source glyph's pointers */
dest_start = hb_bytes_t ();
dest_end = hb_bytes_t ();
break;
} }
return compile_header_bytes (plan, all_points, dest_start); return compile_header_bytes (plan, all_points, dest_start);