[coord-setter] Don't modify font coords

This commit is contained in:
Behdad Esfahbod 2022-12-09 18:45:37 -07:00
parent e9e503b80b
commit 82b4f3791e
2 changed files with 11 additions and 26 deletions

View File

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

View File

@ -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<int> 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<int> old_coords;
hb_vector_t<int> new_coords;
hb_array_t<int> get_coords ()
{ return coords.as_array (); }
hb_vector_t<int> coords;
};