From 8ed78627f0fd1f6957eadffdfab4c8c61d0bfcbb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 25 Jun 2022 17:53:13 -0600 Subject: [PATCH] [glyf] Split off GlyphHeader.hh --- src/Makefile.sources | 1 + src/OT/glyf/Glyph.hh | 33 ++------------------------ src/OT/glyf/GlyphHeader.hh | 48 ++++++++++++++++++++++++++++++++++++++ src/meson.build | 1 + 4 files changed, 52 insertions(+), 31 deletions(-) create mode 100644 src/OT/glyf/GlyphHeader.hh diff --git a/src/Makefile.sources b/src/Makefile.sources index c427a207d..a792eb247 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -91,6 +91,7 @@ HB_BASE_sources = \ OT/glyf/glyf.hh \ OT/glyf/loca.hh \ OT/glyf/Glyph.hh \ + OT/glyf/GlyphHeader.hh \ OT/glyf/SubsetGlyph.hh \ OT/Layout/GSUB/Common.hh \ OT/Layout/GSUB/Sequence.hh \ diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index 2be01575c..93d6f6fab 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -4,6 +4,8 @@ #include "../../hb-open-type.hh" +#include "GlyphHeader.hh" + namespace OT { @@ -216,37 +218,6 @@ enum phantom_point_index_t PHANTOM_COUNT = 4 }; -struct GlyphHeader -{ - bool has_data () const { return numberOfContours; } - - template - bool get_extents (hb_font_t *font, const accelerator_t &glyf_accelerator, - hb_codepoint_t gid, hb_glyph_extents_t *extents) const - { - /* Undocumented rasterizer behavior: shift glyph to the left by (lsb - xMin), i.e., xMin = lsb */ - /* extents->x_bearing = hb_min (glyph_header.xMin, glyph_header.xMax); */ - extents->x_bearing = font->em_scale_x (glyf_accelerator.hmtx->get_side_bearing (gid)); - extents->y_bearing = font->em_scale_y (hb_max (yMin, yMax)); - extents->width = font->em_scale_x (hb_max (xMin, xMax) - hb_min (xMin, xMax)); - extents->height = font->em_scale_y (hb_min (yMin, yMax) - hb_max (yMin, yMax)); - - return true; - } - - HBINT16 numberOfContours; - /* If the number of contours is - * greater than or equal to zero, - * this is a simple glyph; if negative, - * this is a composite glyph. */ - FWORD xMin; /* Minimum x for coordinate data. */ - FWORD yMin; /* Minimum y for coordinate data. */ - FWORD xMax; /* Maximum x for coordinate data. */ - FWORD yMax; /* Maximum y for coordinate data. */ - public: - DEFINE_SIZE_STATIC (10); -}; - struct SimpleGlyph { enum simple_glyph_flag_t diff --git a/src/OT/glyf/GlyphHeader.hh b/src/OT/glyf/GlyphHeader.hh new file mode 100644 index 000000000..792bd5478 --- /dev/null +++ b/src/OT/glyf/GlyphHeader.hh @@ -0,0 +1,48 @@ +#ifndef OT_GLYF_GLYPHHEADER_HH +#define OT_GLYF_GLYPHHEADER_HH + + +#include "../../hb-open-type.hh" + + +namespace OT { +namespace glyf_impl { + + +struct GlyphHeader +{ + bool has_data () const { return numberOfContours; } + + template + bool get_extents (hb_font_t *font, const accelerator_t &glyf_accelerator, + hb_codepoint_t gid, hb_glyph_extents_t *extents) const + { + /* Undocumented rasterizer behavior: shift glyph to the left by (lsb - xMin), i.e., xMin = lsb */ + /* extents->x_bearing = hb_min (glyph_header.xMin, glyph_header.xMax); */ + extents->x_bearing = font->em_scale_x (glyf_accelerator.hmtx->get_side_bearing (gid)); + extents->y_bearing = font->em_scale_y (hb_max (yMin, yMax)); + extents->width = font->em_scale_x (hb_max (xMin, xMax) - hb_min (xMin, xMax)); + extents->height = font->em_scale_y (hb_min (yMin, yMax) - hb_max (yMin, yMax)); + + return true; + } + + HBINT16 numberOfContours; + /* If the number of contours is + * greater than or equal to zero, + * this is a simple glyph; if negative, + * this is a composite glyph. */ + FWORD xMin; /* Minimum x for coordinate data. */ + FWORD yMin; /* Minimum y for coordinate data. */ + FWORD xMax; /* Maximum x for coordinate data. */ + FWORD yMax; /* Maximum y for coordinate data. */ + public: + DEFINE_SIZE_STATIC (10); +}; + + +} /* namespace glyf_impl */ +} /* namespace OT */ + + +#endif /* OT_GLYF_GLYPHHEADER_HH */ diff --git a/src/meson.build b/src/meson.build index 4698024e5..3a5dc98f6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -95,6 +95,7 @@ hb_base_sources = files( 'OT/glyf/glyf.hh', 'OT/glyf/loca.hh', 'OT/glyf/Glyph.hh', + 'OT/glyf/GlyphHeader.hh', 'OT/glyf/SubsetGlyph.hh', 'OT/Layout/GSUB/Common.hh', 'OT/Layout/GSUB/Sequence.hh',