[glyf] Move coord-setter to its own file

This commit is contained in:
Behdad Esfahbod 2022-10-17 12:53:58 -06:00
parent dadb4ed71d
commit 4ec7781497
4 changed files with 48 additions and 28 deletions

View File

@ -96,6 +96,7 @@ HB_BASE_sources = \
OT/glyf/Glyph.hh \ OT/glyf/Glyph.hh \
OT/glyf/GlyphHeader.hh \ OT/glyf/GlyphHeader.hh \
OT/glyf/SimpleGlyph.hh \ OT/glyf/SimpleGlyph.hh \
OT/glyf/coord-setter.hh \
OT/glyf/composite-iter.hh \ OT/glyf/composite-iter.hh \
OT/glyf/CompositeGlyph.hh \ OT/glyf/CompositeGlyph.hh \
OT/glyf/VarCompositeGlyph.hh \ OT/glyf/VarCompositeGlyph.hh \

View File

@ -8,6 +8,7 @@
#include "SimpleGlyph.hh" #include "SimpleGlyph.hh"
#include "CompositeGlyph.hh" #include "CompositeGlyph.hh"
#include "VarCompositeGlyph.hh" #include "VarCompositeGlyph.hh"
#include "coord-setter.hh"
namespace OT { namespace OT {
@ -16,34 +17,6 @@ struct glyf_accelerator_t;
namespace glyf_impl { 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<int> old_coords;
hb_vector_t<int> new_coords;
};
#ifndef HB_GLYF_MAX_POINTS #ifndef HB_GLYF_MAX_POINTS
#define HB_GLYF_MAX_POINTS 10000 #define HB_GLYF_MAX_POINTS 10000

View File

@ -3,6 +3,7 @@
#include "../../hb-open-type.hh" #include "../../hb-open-type.hh"
#include "coord-setter.hh"
namespace OT { namespace OT {

View File

@ -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<int> old_coords;
hb_vector_t<int> new_coords;
};
} /* namespace glyf_impl */
} /* namespace OT */
#endif /* OT_GLYF_COORD_SETTER_HH */