diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2019-10-29 21:32:18 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2019-10-29 21:32:18 +0000 |
commit | dcad66bca87ead79f71baad3b62c164dec82729b (patch) | |
tree | aad05d1eef83274086c25bf8925cb885376c474a /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh | |
parent | d4a75ab9db4e8f02b22024ac4e7eb53f983512eb (diff) |
harfbuzz-2.6.4
git-svn-id: svn://tug.org/texlive/trunk@52576 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh | 82 |
1 files changed, 38 insertions, 44 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh index f5a64b050e8..571e50ea0c7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh @@ -360,9 +360,9 @@ struct glyf { typedef const CompositeGlyphChain *__item_t__; composite_iter_t (hb_bytes_t glyph_, __item_t__ current_) : - glyph (glyph_), current (current_), checker (range_checker_t (glyph.arrayZ, glyph.length)) + glyph (glyph_), current (current_) { if (!in_range (current)) current = nullptr; } - composite_iter_t () : glyph (hb_bytes_t ()), current (nullptr), checker (range_checker_t (nullptr, 0)) {} + composite_iter_t () : glyph (hb_bytes_t ()), current (nullptr) {} const CompositeGlyphChain &__item__ () const { return *current; } bool __more__ () const { return current; } @@ -380,14 +380,13 @@ struct glyf bool in_range (const CompositeGlyphChain *composite) const { - return checker.in_range (composite, CompositeGlyphChain::min_size) - && checker.in_range (composite, composite->get_size ()); + return glyph.in_range (composite, CompositeGlyphChain::min_size) + && glyph.in_range (composite, composite->get_size ()); } private: hb_bytes_t glyph; __item_t__ current; - range_checker_t checker; }; struct Glyph @@ -537,7 +536,7 @@ struct glyf template <typename T> static bool read_points (const HBUINT8 *&p /* IN/OUT */, contour_point_vector_t &points_ /* IN/OUT */, - const range_checker_t &checker) + const hb_bytes_t &bytes) { T coord_setter; float v = 0; @@ -546,7 +545,7 @@ struct glyf uint8_t flag = points_[i].flag; if (coord_setter.is_short (flag)) { - if (unlikely (!checker.in_range (p))) return false; + if (unlikely (!bytes.in_range (p))) return false; if (coord_setter.is_same (flag)) v += *p++; else @@ -556,7 +555,7 @@ struct glyf { if (!coord_setter.is_same (flag)) { - if (unlikely (!checker.in_range ((const HBUINT16 *) p))) return false; + if (unlikely (!bytes.in_range ((const HBUINT16 *) p))) return false; v += *(const HBINT16 *) p; p += HBINT16::static_size; } @@ -571,9 +570,8 @@ struct glyf const bool phantom_only=false) const { const HBUINT16 *endPtsOfContours = &StructAfter<HBUINT16> (header); - range_checker_t checker (bytes.arrayZ, bytes.length); int num_contours = header.numberOfContours; - if (unlikely (!checker.in_range (&endPtsOfContours[num_contours + 1]))) return false; + if (unlikely (!bytes.in_range (&endPtsOfContours[num_contours + 1]))) return false; unsigned int num_points = endPtsOfContours[num_contours - 1] + 1; points_.resize (num_points + PHANTOM_COUNT); @@ -593,12 +591,12 @@ struct glyf /* Read flags */ for (unsigned int i = 0; i < num_points; i++) { - if (unlikely (!checker.in_range (p))) return false; + if (unlikely (!bytes.in_range (p))) return false; uint8_t flag = *p++; points_[i].flag = flag; if (flag & FLAG_REPEAT) { - if (unlikely (!checker.in_range (p))) return false; + if (unlikely (!bytes.in_range (p))) return false; unsigned int repeat_count = *p++; while ((repeat_count-- > 0) && (++i < num_points)) points_[i].flag = flag; @@ -606,8 +604,8 @@ struct glyf } /* Read x & y coordinates */ - return (read_points<x_setter_t> (p, points_, checker) && - read_points<y_setter_t> (p, points_, checker)); + return (read_points<x_setter_t> (p, points_, bytes) && + read_points<y_setter_t> (p, points_, bytes)); } }; @@ -808,20 +806,36 @@ struct glyf struct contour_bounds_t { - contour_bounds_t () { min.x = min.y = FLT_MAX; max.x = max.y = -FLT_MAX; } + contour_bounds_t () { min_x = min_y = FLT_MAX; max_x = max_y = -FLT_MAX; } void add (const contour_point_t &p) { - min.x = hb_min (min.x, p.x); - min.y = hb_min (min.y, p.y); - max.x = hb_max (max.x, p.x); - max.y = hb_max (max.y, p.y); + min_x = hb_min (min_x, p.x); + min_y = hb_min (min_y, p.y); + max_x = hb_max (max_x, p.x); + max_y = hb_max (max_y, p.y); } - bool empty () const { return (min.x >= max.x) || (min.y >= max.y); } + bool empty () const { return (min_x >= max_x) || (min_y >= max_y); } - contour_point_t min; - contour_point_t max; + void get_extents (hb_font_t *font, hb_glyph_extents_t *extents) + { + if (unlikely (empty ())) + { + extents->width = 0; + extents->x_bearing = 0; + extents->height = 0; + extents->y_bearing = 0; + return; + } + extents->x_bearing = font->em_scalef_x (min_x); + extents->width = font->em_scalef_x (max_x - min_x); + extents->y_bearing = font->em_scalef_y (max_y); + extents->height = font->em_scalef_y (min_y - max_y); + } + + protected: + float min_x, min_y, max_x, max_y; }; #ifndef HB_NO_VAR @@ -919,27 +933,7 @@ struct glyf contour_bounds_t bounds; for (unsigned int i = 0; i + PHANTOM_COUNT < all_points.length; i++) bounds.add (all_points[i]); - - if (bounds.min.x > bounds.max.x) - { - extents->width = 0; - extents->x_bearing = 0; - } - else - { - extents->x_bearing = font->em_scalef_x (bounds.min.x); - extents->width = font->em_scalef_x (bounds.max.x - bounds.min.x); - } - if (bounds.min.y > bounds.max.y) - { - extents->height = 0; - extents->y_bearing = 0; - } - else - { - extents->y_bearing = font->em_scalef_y (bounds.max.y); - extents->height = font->em_scalef_y (bounds.min.y - bounds.max.y); - } + bounds.get_extents (font, extents); } if (phantoms) for (unsigned int i = 0; i < PHANTOM_COUNT; i++) @@ -953,7 +947,7 @@ struct glyf bool get_extents_var (hb_font_t *font, hb_codepoint_t gid, hb_glyph_extents_t *extents) const - { return get_var_extents_and_phantoms (font, gid, extents); } + { return get_var_extents_and_phantoms (font, gid, extents); } #endif public: |