From 2b042cc5c6e90736754acdbbd035fe4a230b9fd6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 21 Apr 2023 16:43:47 -0600 Subject: [PATCH] [VarComposite] Implement trim_padding() --- src/OT/glyf/Glyph.hh | 2 +- src/OT/glyf/VarCompositeGlyph.hh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index d772cfc5e..914b484e5 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -58,7 +58,7 @@ struct Glyph { switch (type) { #ifndef HB_NO_VAR_COMPOSITES - case VAR_COMPOSITE: return bytes; // TODO + case VAR_COMPOSITE: return VarCompositeGlyph (*header, bytes).trim_padding (); #endif case COMPOSITE: return CompositeGlyph (*header, bytes).trim_padding (); case SIMPLE: return SimpleGlyph (*header, bytes).trim_padding (); diff --git a/src/OT/glyf/VarCompositeGlyph.hh b/src/OT/glyf/VarCompositeGlyph.hh index 189122bed..8c774aa27 100644 --- a/src/OT/glyf/VarCompositeGlyph.hh +++ b/src/OT/glyf/VarCompositeGlyph.hh @@ -352,6 +352,13 @@ struct VarCompositeGlyph var_composite_iter_t iter () const { return var_composite_iter_t (bytes, &StructAfter (header)); } + const hb_bytes_t trim_padding () const + { + unsigned length = GlyphHeader::static_size; + for (auto &comp : iter ()) + length += comp.get_size (); + return bytes.sub_array (0, length); + } };