[instancer] always recalculate bounds when --instance option enabled
But don't recompile glyph bytes if pinned at default
diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh
index 70adf56..088854a 100644
--- a/src/OT/glyf/Glyph.hh
+++ b/src/OT/glyf/Glyph.hh
@@ -116,7 +116,7 @@
hb_bytes_t &dest_bytes /* OUT */) const
{
GlyphHeader *glyph_header = nullptr;
- if (type != EMPTY && all_points.length > 4)
+ if (!plan->pinned_at_default && type != EMPTY && all_points.length > 4)
{
glyph_header = (GlyphHeader *) hb_calloc (1, GlyphHeader::static_size);
if (unlikely (!glyph_header)) return false;
@@ -155,8 +155,9 @@
plan->head_maxp_info.yMax = hb_max (plan->head_maxp_info.yMax, rounded_yMax);
}
- /*for empty glyphs: all_points only include phantom points.
- *just update metrics and then return */
+ /* when pinned at default, no need to compile glyph header
+ * and for empty glyphs: all_points only include phantom points.
+ * just update metrics and then return */
if (!glyph_header)
return true;
@@ -188,25 +189,28 @@
!(plan->flags & HB_SUBSET_FLAGS_NOTDEF_OUTLINE))
type = EMPTY;
- switch (type) {
- case COMPOSITE:
- if (!CompositeGlyph (*header, bytes).compile_bytes_with_deltas (dest_start,
- deltas,
- dest_end))
- return false;
- break;
- case SIMPLE:
- if (!SimpleGlyph (*header, bytes).compile_bytes_with_deltas (all_points,
- plan->flags & HB_SUBSET_FLAGS_NO_HINTING,
- dest_end))
- return false;
- break;
- default:
- /* set empty bytes for empty glyph
- * do not use source glyph's pointers */
- dest_start = hb_bytes_t ();
- dest_end = hb_bytes_t ();
- break;
+ //dont compile bytes when pinned at default, just recalculate bounds
+ if (!plan->pinned_at_default) {
+ switch (type) {
+ case COMPOSITE:
+ if (!CompositeGlyph (*header, bytes).compile_bytes_with_deltas (dest_start,
+ deltas,
+ dest_end))
+ return false;
+ break;
+ case SIMPLE:
+ if (!SimpleGlyph (*header, bytes).compile_bytes_with_deltas (all_points,
+ plan->flags & HB_SUBSET_FLAGS_NO_HINTING,
+ dest_end))
+ return false;
+ break;
+ default:
+ /* set empty bytes for empty glyph
+ * do not use source glyph's pointers */
+ dest_start = hb_bytes_t ();
+ dest_end = hb_bytes_t ();
+ break;
+ }
}
if (!compile_header_bytes (plan, all_points, dest_start))
diff --git a/src/OT/glyf/glyf.hh b/src/OT/glyf/glyf.hh
index fafaa0e..f3d862b 100644
--- a/src/OT/glyf/glyf.hh
+++ b/src/OT/glyf/glyf.hh
@@ -80,7 +80,7 @@
_populate_subset_glyphs (c->plan, glyphs);
hb_font_t *font = nullptr;
- if (!c->plan->pinned_at_default)
+ if (c->plan->normalized_coords)
{
font = _create_font_for_instancing (c->plan);
if (unlikely (!font)) return false;
@@ -108,7 +108,8 @@
if (font)
{
- _free_compiled_subset_glyphs (&glyphs);
+ if (!c->plan->pinned_at_default)
+ _free_compiled_subset_glyphs (&glyphs);
hb_font_destroy (font);
}