[VarComposite] Implement trim_padding()

This commit is contained in:
Behdad Esfahbod 2023-04-21 16:43:47 -06:00
parent 591c9460dc
commit 2b042cc5c6
2 changed files with 8 additions and 1 deletions

View File

@ -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 ();

View File

@ -352,6 +352,13 @@ struct VarCompositeGlyph
var_composite_iter_t iter () const
{ return var_composite_iter_t (bytes, &StructAfter<VarCompositeGlyphRecord, GlyphHeader> (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);
}
};