summaryrefslogtreecommitdiff
path: root/thirdparty/harfbuzz/src/OT/glyf
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/harfbuzz/src/OT/glyf')
-rw-r--r--thirdparty/harfbuzz/src/OT/glyf/CompositeGlyph.hh36
-rw-r--r--thirdparty/harfbuzz/src/OT/glyf/Glyph.hh20
-rw-r--r--thirdparty/harfbuzz/src/OT/glyf/GlyphHeader.hh8
-rw-r--r--thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh4
-rw-r--r--thirdparty/harfbuzz/src/OT/glyf/glyf.hh59
5 files changed, 84 insertions, 43 deletions
diff --git a/thirdparty/harfbuzz/src/OT/glyf/CompositeGlyph.hh b/thirdparty/harfbuzz/src/OT/glyf/CompositeGlyph.hh
index c145beaa49..abe4c8330c 100644
--- a/thirdparty/harfbuzz/src/OT/glyf/CompositeGlyph.hh
+++ b/thirdparty/harfbuzz/src/OT/glyf/CompositeGlyph.hh
@@ -25,13 +25,16 @@ struct CompositeGlyphRecord
USE_MY_METRICS = 0x0200,
OVERLAP_COMPOUND = 0x0400,
SCALED_COMPONENT_OFFSET = 0x0800,
- UNSCALED_COMPONENT_OFFSET = 0x1000
+ UNSCALED_COMPONENT_OFFSET = 0x1000,
+ GID_IS_24BIT = 0x2000
};
public:
unsigned int get_size () const
{
unsigned int size = min_size;
+ /* glyphIndex is 24bit instead of 16bit */
+ if (flags & GID_IS_24BIT) size += HBGlyphID24::static_size - HBGlyphID16::static_size;
/* arg1 and 2 are int16 */
if (flags & ARG_1_AND_2_ARE_WORDS) size += 4;
/* arg1 and 2 are int8 */
@@ -60,7 +63,11 @@ struct CompositeGlyphRecord
bool is_anchored () const { return !(flags & ARGS_ARE_XY_VALUES); }
void get_anchor_points (unsigned int &point1, unsigned int &point2) const
{
- const HBUINT8 *p = &StructAfter<const HBUINT8> (glyphIndex);
+ const auto *p = &StructAfter<const HBUINT8> (flags);
+ if (flags & GID_IS_24BIT)
+ p += HBGlyphID24::static_size;
+ else
+ p += HBGlyphID16::static_size;
if (flags & ARG_1_AND_2_ARE_WORDS)
{
point1 = ((const HBUINT16 *) p)[0];
@@ -101,8 +108,12 @@ struct CompositeGlyphRecord
matrix[0] = matrix[3] = 1.f;
matrix[1] = matrix[2] = 0.f;
+ const auto *p = &StructAfter<const HBINT8> (flags);
+ if (flags & GID_IS_24BIT)
+ p += HBGlyphID24::static_size;
+ else
+ p += HBGlyphID16::static_size;
int tx, ty;
- const HBINT8 *p = &StructAfter<const HBINT8> (glyphIndex);
if (flags & ARG_1_AND_2_ARE_WORDS)
{
tx = *(const HBINT16 *) p;
@@ -145,8 +156,25 @@ struct CompositeGlyphRecord
}
public:
+ hb_codepoint_t get_gid () const
+ {
+ if (flags & GID_IS_24BIT)
+ return StructAfter<const HBGlyphID24> (flags);
+ else
+ return StructAfter<const HBGlyphID16> (flags);
+ }
+ void set_gid (hb_codepoint_t gid)
+ {
+ if (flags & GID_IS_24BIT)
+ StructAfter<HBGlyphID24> (flags) = gid;
+ else
+ /* TODO assert? */
+ StructAfter<HBGlyphID16> (flags) = gid;
+ }
+
+ protected:
HBUINT16 flags;
- HBGlyphID16 glyphIndex;
+ HBUINT24 pad;
public:
DEFINE_SIZE_MIN (4);
};
diff --git a/thirdparty/harfbuzz/src/OT/glyf/Glyph.hh b/thirdparty/harfbuzz/src/OT/glyf/Glyph.hh
index 2199d2c48b..3efe538f37 100644
--- a/thirdparty/harfbuzz/src/OT/glyf/Glyph.hh
+++ b/thirdparty/harfbuzz/src/OT/glyf/Glyph.hh
@@ -105,19 +105,21 @@ struct Glyph
if (unlikely (!points.resize (points.length + PHANTOM_COUNT))) return false;
hb_array_t<contour_point_t> phantoms = points.sub_array (points.length - PHANTOM_COUNT, PHANTOM_COUNT);
{
- int h_delta = (int) header->xMin -
- glyf_accelerator.hmtx->get_side_bearing (gid);
+ int lsb = 0;
+ int h_delta = glyf_accelerator.hmtx->get_leading_bearing_without_var_unscaled (gid, &lsb) ?
+ (int) header->xMin - lsb : 0;
+ int tsb = 0;
int v_orig = (int) header->yMax +
#ifndef HB_NO_VERTICAL
- glyf_accelerator.vmtx->get_side_bearing (gid)
+ ((void) glyf_accelerator.vmtx->get_leading_bearing_without_var_unscaled (gid, &tsb), tsb)
#else
0
#endif
;
- unsigned h_adv = glyf_accelerator.hmtx->get_advance (gid);
+ unsigned h_adv = glyf_accelerator.hmtx->get_advance_without_var_unscaled (gid);
unsigned v_adv =
#ifndef HB_NO_VERTICAL
- glyf_accelerator.vmtx->get_advance (gid)
+ glyf_accelerator.vmtx->get_advance_without_var_unscaled (gid)
#else
- font->face->get_upem ()
#endif
@@ -144,7 +146,7 @@ struct Glyph
for (auto &item : get_composite_iterator ())
{
comp_points.reset ();
- if (unlikely (!glyf_accelerator.glyph_for_gid (item.glyphIndex)
+ if (unlikely (!glyf_accelerator.glyph_for_gid (item.get_gid ())
.get_points (font, glyf_accelerator, comp_points,
phantom_only, depth + 1)))
return false;
@@ -198,11 +200,11 @@ struct Glyph
return !all_points.in_error ();
}
- bool get_extents (hb_font_t *font, const glyf_accelerator_t &glyf_accelerator,
- hb_glyph_extents_t *extents) const
+ bool get_extents_without_var_scaled (hb_font_t *font, const glyf_accelerator_t &glyf_accelerator,
+ hb_glyph_extents_t *extents) const
{
if (type == EMPTY) return true; /* Empty glyph; zero extents. */
- return header->get_extents (font, glyf_accelerator, gid, extents);
+ return header->get_extents_without_var_scaled (font, glyf_accelerator, gid, extents);
}
hb_bytes_t get_bytes () const { return bytes; }
diff --git a/thirdparty/harfbuzz/src/OT/glyf/GlyphHeader.hh b/thirdparty/harfbuzz/src/OT/glyf/GlyphHeader.hh
index 792bd5478f..e4a9168b79 100644
--- a/thirdparty/harfbuzz/src/OT/glyf/GlyphHeader.hh
+++ b/thirdparty/harfbuzz/src/OT/glyf/GlyphHeader.hh
@@ -14,12 +14,14 @@ struct GlyphHeader
bool has_data () const { return numberOfContours; }
template <typename accelerator_t>
- bool get_extents (hb_font_t *font, const accelerator_t &glyf_accelerator,
- hb_codepoint_t gid, hb_glyph_extents_t *extents) const
+ bool get_extents_without_var_scaled (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));
+ int lsb = hb_min (xMin, xMax);
+ (void) glyf_accelerator.hmtx->get_leading_bearing_without_var_unscaled (gid, &lsb);
+ extents->x_bearing = font->em_scale_x (lsb);
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));
diff --git a/thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh b/thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh
index ebe4372047..7ae8fe3078 100644
--- a/thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh
+++ b/thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh
@@ -42,8 +42,8 @@ struct SubsetGlyph
for (auto &_ : Glyph (dest_glyph).get_composite_iterator ())
{
hb_codepoint_t new_gid;
- if (plan->new_gid_for_old_gid (_.glyphIndex, &new_gid))
- const_cast<CompositeGlyphRecord &> (_).glyphIndex = new_gid;
+ if (plan->new_gid_for_old_gid (_.get_gid(), &new_gid))
+ const_cast<CompositeGlyphRecord &> (_).set_gid (new_gid);
}
if (plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
diff --git a/thirdparty/harfbuzz/src/OT/glyf/glyf.hh b/thirdparty/harfbuzz/src/OT/glyf/glyf.hh
index f74513cb96..bcaf44fc1e 100644
--- a/thirdparty/harfbuzz/src/OT/glyf/glyf.hh
+++ b/thirdparty/harfbuzz/src/OT/glyf/glyf.hh
@@ -194,6 +194,7 @@ struct glyf_accelerator_t
hb_font_t *font;
hb_glyph_extents_t *extents;
contour_point_t *phantoms;
+ bool scaled;
struct contour_bounds_t
{
@@ -209,7 +210,7 @@ struct glyf_accelerator_t
bool empty () const { return (min_x >= max_x) || (min_y >= max_y); }
- void get_extents (hb_font_t *font, hb_glyph_extents_t *extents)
+ void get_extents (hb_font_t *font, hb_glyph_extents_t *extents, bool scaled)
{
if (unlikely (empty ()))
{
@@ -219,26 +220,37 @@ struct glyf_accelerator_t
extents->y_bearing = 0;
return;
}
- extents->x_bearing = font->em_scalef_x (min_x);
- extents->width = font->em_scalef_x (max_x) - extents->x_bearing;
- extents->y_bearing = font->em_scalef_y (max_y);
- extents->height = font->em_scalef_y (min_y) - extents->y_bearing;
+ if (scaled)
+ {
+ extents->x_bearing = font->em_scalef_x (min_x);
+ extents->width = font->em_scalef_x (max_x) - extents->x_bearing;
+ extents->y_bearing = font->em_scalef_y (max_y);
+ extents->height = font->em_scalef_y (min_y) - extents->y_bearing;
+ }
+ else
+ {
+ extents->x_bearing = roundf (min_x);
+ extents->width = roundf (max_x - extents->x_bearing);
+ extents->y_bearing = roundf (max_y);
+ extents->height = roundf (min_y - extents->y_bearing);
+ }
}
protected:
float min_x, min_y, max_x, max_y;
} bounds;
- points_aggregator_t (hb_font_t *font_, hb_glyph_extents_t *extents_, contour_point_t *phantoms_)
+ points_aggregator_t (hb_font_t *font_, hb_glyph_extents_t *extents_, contour_point_t *phantoms_, bool scaled_)
{
font = font_;
extents = extents_;
phantoms = phantoms_;
+ scaled = scaled_;
if (extents) bounds = contour_bounds_t ();
}
void consume_point (const contour_point_t &point) { bounds.add (point); }
- void points_end () { bounds.get_extents (font, extents); }
+ void points_end () { bounds.get_extents (font, extents, scaled); }
bool is_consuming_contour_points () { return extents; }
contour_point_t *get_phantoms_sink () { return phantoms; }
@@ -246,22 +258,22 @@ struct glyf_accelerator_t
public:
unsigned
- get_advance_var (hb_font_t *font, hb_codepoint_t gid, bool is_vertical) const
+ get_advance_with_var_unscaled (hb_font_t *font, hb_codepoint_t gid, bool is_vertical) const
{
if (unlikely (gid >= num_glyphs)) return 0;
bool success = false;
contour_point_t phantoms[glyf_impl::PHANTOM_COUNT];
- if (likely (font->num_coords == gvar->get_axis_count ()))
- success = get_points (font, gid, points_aggregator_t (font, nullptr, phantoms));
+ if (font->num_coords)
+ success = get_points (font, gid, points_aggregator_t (font, nullptr, phantoms, false));
if (unlikely (!success))
return
#ifndef HB_NO_VERTICAL
- is_vertical ? vmtx->get_advance (gid) :
+ is_vertical ? vmtx->get_advance_without_var_unscaled (gid) :
#endif
- hmtx->get_advance (gid);
+ hmtx->get_advance_without_var_unscaled (gid);
float result = is_vertical
? phantoms[glyf_impl::PHANTOM_TOP].y - phantoms[glyf_impl::PHANTOM_BOTTOM].y
@@ -269,23 +281,20 @@ struct glyf_accelerator_t
return hb_clamp (roundf (result), 0.f, (float) UINT_MAX / 2);
}
- int get_side_bearing_var (hb_font_t *font, hb_codepoint_t gid, bool is_vertical) const
+ bool get_leading_bearing_with_var_unscaled (hb_font_t *font, hb_codepoint_t gid, bool is_vertical, int *lsb) const
{
- if (unlikely (gid >= num_glyphs)) return 0;
+ if (unlikely (gid >= num_glyphs)) return false;
hb_glyph_extents_t extents;
contour_point_t phantoms[glyf_impl::PHANTOM_COUNT];
- if (unlikely (!get_points (font, gid, points_aggregator_t (font, &extents, phantoms))))
- return
-#ifndef HB_NO_VERTICAL
- is_vertical ? vmtx->get_side_bearing (gid) :
-#endif
- hmtx->get_side_bearing (gid);
+ if (unlikely (!get_points (font, gid, points_aggregator_t (font, &extents, phantoms, false))))
+ return false;
- return is_vertical
- ? ceilf (phantoms[glyf_impl::PHANTOM_TOP].y) - extents.y_bearing
- : floorf (phantoms[glyf_impl::PHANTOM_LEFT].x);
+ *lsb = is_vertical
+ ? roundf (phantoms[glyf_impl::PHANTOM_TOP].y) - extents.y_bearing
+ : roundf (phantoms[glyf_impl::PHANTOM_LEFT].x);
+ return true;
}
#endif
@@ -296,9 +305,9 @@ struct glyf_accelerator_t
#ifndef HB_NO_VAR
if (font->num_coords)
- return get_points (font, gid, points_aggregator_t (font, extents, nullptr));
+ return get_points (font, gid, points_aggregator_t (font, extents, nullptr, true));
#endif
- return glyph_for_gid (gid).get_extents (font, *this, extents);
+ return glyph_for_gid (gid).get_extents_without_var_scaled (font, *this, extents);
}
const glyf_impl::Glyph