From 4ec77814978b675d0aa74e869c24abc8b5270678 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 17 Oct 2022 12:53:58 -0600 Subject: [PATCH] [glyf] Move coord-setter to its own file --- src/Makefile.sources | 1 + src/OT/glyf/Glyph.hh | 29 +------------------- src/OT/glyf/VarCompositeGlyph.hh | 1 + src/OT/glyf/coord-setter.hh | 45 ++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 src/OT/glyf/coord-setter.hh diff --git a/src/Makefile.sources b/src/Makefile.sources index 5fc16a165..6c4fc5de7 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -96,6 +96,7 @@ HB_BASE_sources = \ OT/glyf/Glyph.hh \ OT/glyf/GlyphHeader.hh \ OT/glyf/SimpleGlyph.hh \ + OT/glyf/coord-setter.hh \ OT/glyf/composite-iter.hh \ OT/glyf/CompositeGlyph.hh \ OT/glyf/VarCompositeGlyph.hh \ diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index fda6c191a..14c901825 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -8,6 +8,7 @@ #include "SimpleGlyph.hh" #include "CompositeGlyph.hh" #include "VarCompositeGlyph.hh" +#include "coord-setter.hh" namespace OT { @@ -16,34 +17,6 @@ struct glyf_accelerator_t; namespace glyf_impl { -struct CoordSetter -{ - CoordSetter (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; - } - - ~CoordSetter () - { - font->coords = old_coords.arrayZ; - font->num_coords = old_coords.length; - } - - int& operator [] (unsigned idx) - { - if (new_coords.length < idx + 1) - new_coords.resize (idx + 1); - return new_coords[idx]; - } - - hb_font_t *font; - hb_array_t old_coords; - hb_vector_t new_coords; -}; #ifndef HB_GLYF_MAX_POINTS #define HB_GLYF_MAX_POINTS 10000 diff --git a/src/OT/glyf/VarCompositeGlyph.hh b/src/OT/glyf/VarCompositeGlyph.hh index 86f291ac2..f15ead8c3 100644 --- a/src/OT/glyf/VarCompositeGlyph.hh +++ b/src/OT/glyf/VarCompositeGlyph.hh @@ -3,6 +3,7 @@ #include "../../hb-open-type.hh" +#include "coord-setter.hh" namespace OT { diff --git a/src/OT/glyf/coord-setter.hh b/src/OT/glyf/coord-setter.hh new file mode 100644 index 000000000..c3d5ce5b7 --- /dev/null +++ b/src/OT/glyf/coord-setter.hh @@ -0,0 +1,45 @@ +#ifndef OT_GLYF_COORD_SETTER_HH +#define OT_GLYF_COORD_SETTER_HH + + +#include "../../hb.hh" + + +namespace OT { +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; + } + + int& operator [] (unsigned idx) + { + if (new_coords.length < idx + 1) + new_coords.resize (idx + 1); + return new_coords[idx]; + } + + hb_font_t *font; + hb_array_t old_coords; + hb_vector_t new_coords; +}; + + +} /* namespace glyf_impl */ +} /* namespace OT */ + +#endif /* OT_GLYF_COORD_SETTER_HH */