From 7efd68da390f5cd125a1dd3a187ae28bbfb282e0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 17 Oct 2022 13:05:22 -0600 Subject: [PATCH] [glyf/VarComposite] Set coordinates Code is untested but complete! --- src/OT/glyf/Glyph.hh | 3 ++- src/OT/glyf/VarCompositeGlyph.hh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index 14c901825..ee89175de 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -356,7 +356,8 @@ struct Glyph comp_points.reset (); - /* XXX Apply variations. */ + coord_setter_t coord_setter (font); + item.set_coordinates (coord_setter, record_points); if (unlikely (!glyf_accelerator.glyph_for_gid (item.get_gid ()) .get_points (font, glyf_accelerator, comp_points, diff --git a/src/OT/glyf/VarCompositeGlyph.hh b/src/OT/glyf/VarCompositeGlyph.hh index f15ead8c3..6ac7aea07 100644 --- a/src/OT/glyf/VarCompositeGlyph.hh +++ b/src/OT/glyf/VarCompositeGlyph.hh @@ -226,6 +226,22 @@ struct VarCompositeGlyphRecord translate (matrix, trans, -tCenterX, -tCenterY); } + void set_coordinates (coord_setter_t &setter, + hb_array_t axis_points) const + { + unsigned axis_width = (flags & AXIS_INDICES_ARE_SHORT) ? 2 : 1; + + const HBUINT8 *p = &StructAfter (num_axes); + const HBUINT16 *q = &StructAfter (num_axes); + + unsigned count = num_axes; + for (unsigned i = 0; i < count; i++) + { + unsigned axis_index = axis_width == 1 ? *p++ : *q++; + setter[axis_index] = axis_points[i].x; + } + } + protected: HBUINT16 flags; HBGlyphID16 gid;