From 82b4f3791e1348273ebc8c13d410638842eef833 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 9 Dec 2022 18:45:37 -0700 Subject: [PATCH] [coord-setter] Don't modify font coords --- src/OT/glyf/Glyph.hh | 4 ++-- src/OT/glyf/coord-setter.hh | 33 +++++++++------------------------ 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index e04e00b2b..0ba4c970e 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -367,7 +367,7 @@ struct Glyph comp_points.reset (); - coord_setter_t coord_setter (font); + coord_setter_t coord_setter (coords); item.set_variations (coord_setter, record_points); if (unlikely (!glyf_accelerator.glyph_for_gid (item.get_gid ()) @@ -378,7 +378,7 @@ struct Glyph shift_points_hori, use_my_metrics, phantom_only, - hb_array (font->coords, font->num_coords), + coord_setter.get_coords (), depth + 1))) return false; diff --git a/src/OT/glyf/coord-setter.hh b/src/OT/glyf/coord-setter.hh index 8ef20e76a..df64ed5af 100644 --- a/src/OT/glyf/coord-setter.hh +++ b/src/OT/glyf/coord-setter.hh @@ -11,35 +11,20 @@ namespace glyf_impl { struct coord_setter_t { - coord_setter_t (hb_font_t *font) : - font (font), - old_coords (font->coords, font->num_coords), - new_coords (old_coords) - { - font->coords = new_coords.arrayZ; - font->num_coords = new_coords.length; - } - - ~coord_setter_t () - { - font->coords = old_coords.arrayZ; - font->num_coords = old_coords.length; - } + coord_setter_t (hb_array_t coords) : + coords (coords) {} int& operator [] (unsigned idx) { - if (new_coords.length < idx + 1) - { - new_coords.resize (idx + 1); - font->coords = new_coords.arrayZ; - font->num_coords = new_coords.length; - } - return new_coords[idx]; + if (coords.length < idx + 1) + coords.resize (idx + 1); + return coords[idx]; } - hb_font_t *font; - hb_array_t old_coords; - hb_vector_t new_coords; + hb_array_t get_coords () + { return coords.as_array (); } + + hb_vector_t coords; };