[HarfBuzz] harfbuzz: Branch 'master' - 11 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Tue Nov 6 04:34:48 UTC 2018
src/hb-aat-layout.cc | 109 ++++++----------------------------
src/hb-face.cc | 13 ++--
src/hb-face.hh | 3
src/hb-ot-color.cc | 66 ++++----------------
src/hb-ot-face.cc | 24 -------
src/hb-ot-face.hh | 40 ++++--------
src/hb-ot-font.cc | 27 +++-----
src/hb-ot-layout-gdef-table.hh | 2
src/hb-ot-layout-gpos-table.hh | 9 +-
src/hb-ot-layout-gsub-table.hh | 9 +-
src/hb-ot-layout-gsubgpos.hh | 2
src/hb-ot-layout.cc | 129 ++++++++++++++---------------------------
src/hb-ot-layout.hh | 12 ---
src/hb-ot-math-table.hh | 4 -
src/hb-ot-math.cc | 53 ++++++----------
src/hb-ot-name.cc | 11 ---
src/hb-ot-shape.cc | 5 -
src/hb-ot-var.cc | 33 ++--------
18 files changed, 169 insertions(+), 382 deletions(-)
New commits:
commit fa3ebf845fcffa827600fc4ca9fdde3aaa99f4c5
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:34:07 2018 -0500
Simplify some more
diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index 4c4e2945..1912de0d 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -206,7 +206,7 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer)
{
hb_blob_t *morx_blob = font->face->table.morx.get_blob ();
- const AAT::morx& morx = *font->face->table.morx;
+ const AAT::morx& morx = *morx_blob->as<AAT::morx> ();
if (morx.has_data ())
{
AAT::hb_aat_apply_context_t c (plan, font, buffer, morx_blob);
@@ -215,7 +215,7 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
}
hb_blob_t *mort_blob = font->face->table.morx.get_blob ();
- const AAT::mort& mort = *font->face->table.mort;
+ const AAT::mort& mort = *mort_blob->as<AAT::mort> ();
if (mort.has_data ())
{
AAT::hb_aat_apply_context_t c (plan, font, buffer, mort_blob);
@@ -236,13 +236,13 @@ hb_aat_layout_position (hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
- hb_blob_t *blob = font->face->table.kerx.get_blob ();
- const AAT::kerx& kerx = *font->face->table.kerx;
+ hb_blob_t *kerx_blob = font->face->table.kerx.get_blob ();
+ const AAT::kerx& kerx = *kerx_blob->as<AAT::kerx> ();
hb_blob_t *ankr_blob = font->face->table.ankr.get_blob ();;
const AAT::ankr& ankr = *font->face->table.ankr;
- AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
+ AAT::hb_aat_apply_context_t c (plan, font, buffer, kerx_blob);
c.set_ankr_table (&ankr, ankr_blob->data + ankr_blob->length);
kerx.apply (&c);
}
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 7b0c5a6a..1b366eb7 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -69,7 +69,7 @@ hb_ot_layout_kern (hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer)
{
hb_blob_t *blob = font->face->table.kern.get_blob ();
- const AAT::kern& kern = *font->face->table.kern;
+ const AAT::kern& kern = *blob->as<AAT::kern> ();
AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
commit 61f52231f430c72e1b66b76dabb018cfe45a01d5
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:28:52 2018 -0500
[math] Shorten names a bit
diff --git a/src/hb-ot-math-table.hh b/src/hb-ot-math-table.hh
index e2093597..54c4e7fc 100644
--- a/src/hb-ot-math-table.hh
+++ b/src/hb-ot-math-table.hh
@@ -700,10 +700,10 @@ struct MATH
hb_font_t *font) const
{ return (this+mathConstants).get_value (constant, font); }
- inline const MathGlyphInfo &get_math_glyph_info (void) const
+ inline const MathGlyphInfo &get_glyph_info (void) const
{ return this+mathGlyphInfo; }
- inline const MathVariants &get_math_variants (void) const
+ inline const MathVariants &get_variants (void) const
{ return this+mathVariants; }
protected:
diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc
index e1d26d30..bd31bf56 100644
--- a/src/hb-ot-math.cc
+++ b/src/hb-ot-math.cc
@@ -96,7 +96,7 @@ hb_position_t
hb_ot_math_get_glyph_italics_correction (hb_font_t *font,
hb_codepoint_t glyph)
{
- return font->face->table.MATH->get_math_glyph_info().get_italics_correction (glyph, font);
+ return font->face->table.MATH->get_glyph_info().get_italics_correction (glyph, font);
}
/**
@@ -112,7 +112,7 @@ hb_position_t
hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font,
hb_codepoint_t glyph)
{
- return font->face->table.MATH->get_math_glyph_info().get_top_accent_attachment (glyph, font);
+ return font->face->table.MATH->get_glyph_info().get_top_accent_attachment (glyph, font);
}
/**
@@ -128,7 +128,7 @@ hb_bool_t
hb_ot_math_is_glyph_extended_shape (hb_face_t *face,
hb_codepoint_t glyph)
{
- return face->table.MATH->get_math_glyph_info().is_extended_shape (glyph);
+ return face->table.MATH->get_glyph_info().is_extended_shape (glyph);
}
/**
@@ -154,7 +154,10 @@ hb_ot_math_get_glyph_kerning (hb_font_t *font,
hb_ot_math_kern_t kern,
hb_position_t correction_height)
{
- return font->face->table.MATH->get_math_glyph_info().get_kerning (glyph, kern, correction_height, font);
+ return font->face->table.MATH->get_glyph_info().get_kerning (glyph,
+ kern,
+ correction_height,
+ font);
}
/**
@@ -184,10 +187,10 @@ hb_ot_math_get_glyph_variants (hb_font_t *font,
unsigned int *variants_count, /* IN/OUT */
hb_ot_math_glyph_variant_t *variants /* OUT */)
{
- return font->face->table.MATH->get_math_variants().get_glyph_variants (glyph, direction, font,
- start_offset,
- variants_count,
- variants);
+ return font->face->table.MATH->get_variants().get_glyph_variants (glyph, direction, font,
+ start_offset,
+ variants_count,
+ variants);
}
/**
@@ -208,7 +211,7 @@ hb_position_t
hb_ot_math_get_min_connector_overlap (hb_font_t *font,
hb_direction_t direction)
{
- return font->face->table.MATH->get_math_variants().get_min_connector_overlap (direction, font);
+ return font->face->table.MATH->get_variants().get_min_connector_overlap (direction, font);
}
/**
@@ -240,9 +243,11 @@ hb_ot_math_get_glyph_assembly (hb_font_t *font,
hb_ot_math_glyph_part_t *parts, /* OUT */
hb_position_t *italics_correction /* OUT */)
{
- return font->face->table.MATH->get_math_variants().get_glyph_parts (glyph, direction, font,
- start_offset,
- parts_count,
- parts,
- italics_correction);
+ return font->face->table.MATH->get_variants().get_glyph_parts (glyph,
+ direction,
+ font,
+ start_offset,
+ parts_count,
+ parts,
+ italics_correction);
}
commit 737efbe65583a71d7df9ae7b423d9fb1d68599b7
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:26:29 2018 -0500
[ot-layout] Simplify GSUB/GPOS access
This concludes simplifying table access to face->table.XXXX.
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 33c8c113..7b0c5a6a 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -53,16 +53,6 @@
**/
-static inline const OT::GSUB& _get_gsub (hb_face_t *face)
-{
- return *face->table.GSUB->table;
-}
-static inline const OT::GPOS& _get_gpos (hb_face_t *face)
-{
- return *face->table.GPOS->table;
-}
-
-
/*
* kern
*/
@@ -297,8 +287,8 @@ get_gsubgpos_table (hb_face_t *face,
hb_tag_t table_tag)
{
switch (table_tag) {
- case HB_OT_TAG_GSUB: return _get_gsub (face);
- case HB_OT_TAG_GPOS: return _get_gpos (face);
+ case HB_OT_TAG_GSUB: return *face->table.GSUB->table;
+ case HB_OT_TAG_GPOS: return *face->table.GPOS->table;
default: return Null(OT::GSUBGPOS);
}
}
@@ -470,7 +460,12 @@ hb_ot_layout_script_find_language (hb_face_t *face,
hb_tag_t language_tag,
unsigned int *language_index)
{
- return hb_ot_layout_script_select_language (face, table_tag, script_index, 1, &language_tag, language_index);
+ return hb_ot_layout_script_select_language (face,
+ table_tag,
+ script_index,
+ 1,
+ &language_tag,
+ language_index);
}
/**
@@ -911,7 +906,7 @@ hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
hb_bool_t
hb_ot_layout_has_substitution (hb_face_t *face)
{
- return _get_gsub (face).has_data ();
+ return face->table.GSUB->table->has_data ();
}
/**
@@ -967,7 +962,7 @@ hb_ot_layout_lookup_substitute_closure (hb_face_t *face,
hb_map_t done_lookups;
OT::hb_closure_context_t c (face, glyphs, &done_lookups);
- const OT::SubstLookup& l = _get_gsub (face).get_lookup (lookup_index);
+ const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index);
l.closure (&c, lookup_index);
}
@@ -987,7 +982,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
{
hb_map_t done_lookups;
OT::hb_closure_context_t c (face, glyphs, &done_lookups);
- const OT::GSUB& gsub = _get_gsub (face);
+ const OT::GSUB& gsub = *face->table.GSUB->table;
unsigned int iteration_count = 0;
unsigned int glyphs_length;
@@ -1016,7 +1011,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
hb_bool_t
hb_ot_layout_has_positioning (hb_face_t *face)
{
- return _get_gpos (face).has_data ();
+ return face->table.GPOS->table->has_data ();
}
void
@@ -1050,7 +1045,7 @@ hb_ot_layout_get_size_params (hb_face_t *face,
unsigned int *range_start, /* OUT. May be NULL */
unsigned int *range_end /* OUT. May be NULL */)
{
- const OT::GPOS &gpos = _get_gpos (face);
+ const OT::GPOS &gpos = *face->table.GPOS->table;
const hb_tag_t tag = HB_TAG ('s','i','z','e');
unsigned int num_features = gpos.get_feature_count ();
commit 5e68cec17913e9f6e98e5017a56c78a5614e4030
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:23:57 2018 -0500
[ot-layout] Simplify GDEF access
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 5768cd7f..33c8c113 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -53,34 +53,14 @@
**/
-const OT::GDEF& _get_gdef (hb_face_t *face)
-{
- return *face->table.GDEF->table;
-}
-static hb_blob_t * _get_gsub_blob (hb_face_t *face)
-{
- return face->table.GSUB->blob;
-}
static inline const OT::GSUB& _get_gsub (hb_face_t *face)
{
return *face->table.GSUB->table;
}
-const OT::GSUB& _get_gsub_relaxed (hb_face_t *face)
-{
- return *face->table.GSUB.get_relaxed ()->table;
-}
-static hb_blob_t * _get_gpos_blob (hb_face_t *face)
-{
- return face->table.GPOS->blob;
-}
static inline const OT::GPOS& _get_gpos (hb_face_t *face)
{
return *face->table.GPOS->table;
}
-const OT::GPOS& _get_gpos_relaxed (hb_face_t *face)
-{
- return *face->table.GPOS.get_relaxed ()->table;
-}
/*
@@ -219,8 +199,8 @@ OT::GDEF::accelerator_t::init (hb_face_t *face)
this->blob = hb_sanitize_context_t().reference_table<GDEF> (face);
if (unlikely (_hb_ot_blacklist_gdef (this->blob->length,
- _get_gsub_blob (face)->length,
- _get_gpos_blob (face)->length)))
+ face->table.GSUB->blob->length,
+ face->table.GPOS->blob->length)))
{
hb_blob_destroy (this->blob);
this->blob = hb_blob_get_empty ();
@@ -235,7 +215,7 @@ _hb_ot_layout_set_glyph_props (hb_font_t *font,
{
_hb_buffer_assert_gsubgpos_vars (buffer);
- const OT::GDEF &gdef = _get_gdef (font->face);
+ const OT::GDEF &gdef = *font->face->table.GDEF->table;
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
{
@@ -250,7 +230,7 @@ _hb_ot_layout_set_glyph_props (hb_font_t *font,
hb_bool_t
hb_ot_layout_has_glyph_classes (hb_face_t *face)
{
- return _get_gdef (face).has_glyph_classes ();
+ return face->table.GDEF->table->has_glyph_classes ();
}
/**
@@ -262,7 +242,7 @@ hb_ot_layout_glyph_class_t
hb_ot_layout_get_glyph_class (hb_face_t *face,
hb_codepoint_t glyph)
{
- return (hb_ot_layout_glyph_class_t) _get_gdef (face).get_glyph_class (glyph);
+ return (hb_ot_layout_glyph_class_t) face->table.GDEF->table->get_glyph_class (glyph);
}
/**
@@ -275,7 +255,7 @@ hb_ot_layout_get_glyphs_in_class (hb_face_t *face,
hb_ot_layout_glyph_class_t klass,
hb_set_t *glyphs /* OUT */)
{
- return _get_gdef (face).get_glyphs_in_class (klass, glyphs);
+ return face->table.GDEF->table->get_glyphs_in_class (klass, glyphs);
}
unsigned int
@@ -285,7 +265,10 @@ hb_ot_layout_get_attach_points (hb_face_t *face,
unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */)
{
- return _get_gdef (face).get_attach_points (glyph, start_offset, point_count, point_array);
+ return face->table.GDEF->table->get_attach_points (glyph,
+ start_offset,
+ point_count,
+ point_array);
}
unsigned int
@@ -296,7 +279,12 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font,
unsigned int *caret_count /* IN/OUT */,
hb_position_t *caret_array /* OUT */)
{
- return _get_gdef (font->face).get_lig_carets (font, direction, glyph, start_offset, caret_count, caret_array);
+ return font->face->table.GDEF->table->get_lig_carets (font,
+ direction,
+ glyph,
+ start_offset,
+ caret_count,
+ caret_array);
}
commit 33b006cc51b0d27cbe1d8ed498bbf2b548cb6554
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:19:04 2018 -0500
[ot-layout] Simplify some access
diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh
index 5847953d..ea5f1c07 100644
--- a/src/hb-ot-layout-gdef-table.hh
+++ b/src/hb-ot-layout-gdef-table.hh
@@ -410,7 +410,7 @@ struct GDEF
struct accelerator_t
{
- HB_INTERNAL inline void init (hb_face_t *face);
+ HB_INTERNAL void init (hb_face_t *face);
inline void fini (void)
{
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 399ede43..743a9793 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1736,18 +1736,21 @@ GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
}
+struct GPOS_accelerator_t : GPOS::accelerator_t {};
+
+
/* Out-of-class implementation for methods recursing */
template <typename context_t>
/*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{
- const PosLookup &l = _get_gpos_relaxed (c->face)->get_lookup (lookup_index);
+ const PosLookup &l = c->face->table.GPOS.get_relaxed ()->table->get_lookup (lookup_index);
return l.dispatch (c);
}
/*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{
- const PosLookup &l = _get_gpos_relaxed (c->face).get_lookup (lookup_index);
+ const PosLookup &l = c->face->table.GPOS.get_relaxed ()->table->get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_lookup_index = c->lookup_index;
c->set_lookup_index (lookup_index);
@@ -1758,8 +1761,6 @@ template <typename context_t>
return ret;
}
-struct GPOS_accelerator_t : GPOS::accelerator_t {};
-
} /* namespace OT */
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index d24ea59a..cef64218 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1487,6 +1487,9 @@ struct GSUB : GSUBGPOS
};
+struct GSUB_accelerator_t : GSUB::accelerator_t {};
+
+
/* Out-of-class implementation for methods recursing */
/*static*/ inline bool ExtensionSubst::is_reverse (void) const
@@ -1500,13 +1503,13 @@ struct GSUB : GSUBGPOS
template <typename context_t>
/*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{
- const SubstLookup &l = _get_gsub_relaxed (c->face).get_lookup (lookup_index);
+ const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index);
return l.dispatch (c);
}
/*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{
- const SubstLookup &l = _get_gsub_relaxed (c->face).get_lookup (lookup_index);
+ const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_lookup_index = c->lookup_index;
c->set_lookup_index (lookup_index);
@@ -1517,8 +1520,6 @@ template <typename context_t>
return ret;
}
-struct GSUB_accelerator_t : GSUB::accelerator_t {};
-
} /* namespace OT */
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 0d9eeae5..eccbcf42 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -491,7 +491,7 @@ struct hb_ot_apply_context_t :
iter_input (), iter_context (),
font (font_), face (font->face), buffer (buffer_),
recurse_func (nullptr),
- gdef (_get_gdef (face)),
+ gdef (*face->table.GDEF->table),
var_store (gdef.get_var_store ()),
direction (buffer_->props.direction),
lookup_mask (1),
diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh
index b29f87c5..437ae477 100644
--- a/src/hb-ot-layout.hh
+++ b/src/hb-ot-layout.hh
@@ -38,19 +38,9 @@
#include "hb-set-digest.hh"
-namespace OT
-{
- struct GDEF;
- struct GSUB;
- struct GPOS;
-}
-
-HB_INTERNAL const OT::GDEF& _get_gdef (hb_face_t *face);
-HB_INTERNAL const OT::GSUB& _get_gsub_relaxed (hb_face_t *face);
-HB_INTERNAL const OT::GPOS& _get_gpos_relaxed (hb_face_t *face);
-
struct hb_ot_shape_plan_t;
+
/*
* kern
*/
commit db35409f0db9faf91a10defc81e4d6d60dc7822a
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:11:46 2018 -0500
[ot-layout] Remove ensures
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 1a6cf148..5768cd7f 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -55,17 +55,14 @@
const OT::GDEF& _get_gdef (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF);
return *face->table.GDEF->table;
}
static hb_blob_t * _get_gsub_blob (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return hb_blob_get_empty ();
return face->table.GSUB->blob;
}
static inline const OT::GSUB& _get_gsub (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
return *face->table.GSUB->table;
}
const OT::GSUB& _get_gsub_relaxed (hb_face_t *face)
@@ -74,12 +71,10 @@ const OT::GSUB& _get_gsub_relaxed (hb_face_t *face)
}
static hb_blob_t * _get_gpos_blob (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return hb_blob_get_empty ();
return face->table.GPOS->blob;
}
static inline const OT::GPOS& _get_gpos (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
return *face->table.GPOS->table;
}
const OT::GPOS& _get_gpos_relaxed (hb_face_t *face)
@@ -865,8 +860,6 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
hb_set_t *glyphs_after, /* OUT. May be NULL */
hb_set_t *glyphs_output /* OUT. May be NULL */)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
-
OT::hb_collect_glyphs_context_t c (face,
glyphs_before,
glyphs_input,
@@ -945,8 +938,10 @@ hb_ot_layout_lookup_would_substitute (hb_face_t *face,
unsigned int glyphs_length,
hb_bool_t zero_context)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return false;
- return hb_ot_layout_lookup_would_substitute_fast (face, lookup_index, glyphs, glyphs_length, zero_context);
+ return hb_ot_layout_lookup_would_substitute_fast (face,
+ lookup_index,
+ glyphs, glyphs_length,
+ zero_context);
}
hb_bool_t
@@ -1413,7 +1408,6 @@ hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c,
#if 0
static const OT::BASE& _get_base (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::BASE);
return *face->table.BASE;
}
commit 9198de7b9b6020c1e3d6a48783e36db7e1f7e99a
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:10:37 2018 -0500
[ot-font] Remove ensure
diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc
index 2f88f3ad..cf8cbd35 100644
--- a/src/hb-ot-font.cc
+++ b/src/hb-ot-font.cc
@@ -298,7 +298,6 @@ _hb_ot_get_font_funcs (void)
void
hb_ot_font_set_funcs (hb_font_t *font)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return;
hb_font_set_funcs (font,
_hb_ot_get_font_funcs (),
&font->face->table,
commit ea6d9b661fc3cf6bc4366feeb7694c0b712abfae
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:09:29 2018 -0500
[ot-face] Remove a few ensures
diff --git a/src/hb-face.cc b/src/hb-face.cc
index b3ded6f7..8e731052 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -551,7 +551,6 @@ void
hb_face_collect_unicodes (hb_face_t *face,
hb_set_t *out)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
face->table.cmap->collect_unicodes (out);
}
@@ -568,7 +567,6 @@ void
hb_face_collect_variation_selectors (hb_face_t *face,
hb_set_t *out)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
face->table.cmap->collect_variation_selectors (out);
}
@@ -586,7 +584,6 @@ hb_face_collect_variation_unicodes (hb_face_t *face,
hb_codepoint_t variation_selector,
hb_set_t *out)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
face->table.cmap->collect_variation_unicodes (variation_selector, out);
}
commit 0fe7a745c9a323a3fc76beb011b6ab8919cf905b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 23:08:33 2018 -0500
[ot-face] Simplify more table access
diff --git a/src/hb-face.cc b/src/hb-face.cc
index 921eed28..b3ded6f7 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -552,7 +552,7 @@ hb_face_collect_unicodes (hb_face_t *face,
hb_set_t *out)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
- hb_ot_face_data (face)->cmap->collect_unicodes (out);
+ face->table.cmap->collect_unicodes (out);
}
/**
@@ -569,7 +569,7 @@ hb_face_collect_variation_selectors (hb_face_t *face,
hb_set_t *out)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
- hb_ot_face_data (face)->cmap->collect_variation_selectors (out);
+ face->table.cmap->collect_variation_selectors (out);
}
/**
@@ -587,7 +587,7 @@ hb_face_collect_variation_unicodes (hb_face_t *face,
hb_set_t *out)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
- hb_ot_face_data (face)->cmap->collect_variation_unicodes (variation_selector, out);
+ face->table.cmap->collect_variation_unicodes (variation_selector, out);
}
diff --git a/src/hb-ot-face.hh b/src/hb-ot-face.hh
index 46d5db75..f393d4b1 100644
--- a/src/hb-ot-face.hh
+++ b/src/hb-ot-face.hh
@@ -34,9 +34,6 @@
#include "hb-machinery.hh"
-#define hb_ot_face_data(face) (&face->table)
-
-
/*
* hb_ot_face_t
*/
diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc
index 54095c17..2f88f3ad 100644
--- a/src/hb-ot-font.cc
+++ b/src/hb-ot-font.cc
@@ -299,10 +299,8 @@ void
hb_ot_font_set_funcs (hb_font_t *font)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return;
- hb_ot_face_t *ot_face = hb_ot_face_data (font->face);
-
hb_font_set_funcs (font,
_hb_ot_get_font_funcs (),
- ot_face,
+ &font->face->table,
nullptr);
}
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index b3c63538..1a6cf148 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -56,35 +56,35 @@
const OT::GDEF& _get_gdef (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF);
- return *hb_ot_face_data (face)->GDEF->table;
+ return *face->table.GDEF->table;
}
static hb_blob_t * _get_gsub_blob (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return hb_blob_get_empty ();
- return hb_ot_face_data (face)->GSUB->blob;
+ return face->table.GSUB->blob;
}
static inline const OT::GSUB& _get_gsub (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
- return *hb_ot_face_data (face)->GSUB->table;
+ return *face->table.GSUB->table;
}
const OT::GSUB& _get_gsub_relaxed (hb_face_t *face)
{
- return *hb_ot_face_data (face)->GSUB.get_relaxed ()->table;
+ return *face->table.GSUB.get_relaxed ()->table;
}
static hb_blob_t * _get_gpos_blob (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return hb_blob_get_empty ();
- return hb_ot_face_data (face)->GPOS->blob;
+ return face->table.GPOS->blob;
}
static inline const OT::GPOS& _get_gpos (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
- return *hb_ot_face_data (face)->GPOS->table;
+ return *face->table.GPOS->table;
}
const OT::GPOS& _get_gpos_relaxed (hb_face_t *face)
{
- return *hb_ot_face_data (face)->GPOS.get_relaxed ()->table;
+ return *face->table.GPOS.get_relaxed ()->table;
}
@@ -877,13 +877,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
{
case HB_OT_TAG_GSUB:
{
- const OT::SubstLookup& l = hb_ot_face_data (face)->GSUB->table->get_lookup (lookup_index);
+ const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index);
l.collect_glyphs (&c);
return;
}
case HB_OT_TAG_GPOS:
{
- const OT::PosLookup& l = hb_ot_face_data (face)->GPOS->table->get_lookup (lookup_index);
+ const OT::PosLookup& l = face->table.GPOS->table->get_lookup (lookup_index);
l.collect_glyphs (&c);
return;
}
@@ -956,12 +956,12 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face,
unsigned int glyphs_length,
hb_bool_t zero_context)
{
- if (unlikely (lookup_index >= hb_ot_face_data (face)->GSUB->lookup_count)) return false;
+ if (unlikely (lookup_index >= face->table.GSUB->lookup_count)) return false;
OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context);
- const OT::SubstLookup& l = hb_ot_face_data (face)->GSUB->table->get_lookup (lookup_index);
+ const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index);
- return l.would_apply (&c, &hb_ot_face_data (face)->GSUB->accels[lookup_index]);
+ return l.would_apply (&c, &face->table.GSUB->accels[lookup_index]);
}
void
@@ -1240,8 +1240,8 @@ struct GSUBProxy
typedef OT::SubstLookup Lookup;
GSUBProxy (hb_face_t *face) :
- table (*hb_ot_face_data (face)->GSUB->table),
- accels (hb_ot_face_data (face)->GSUB->accels) {}
+ table (*face->table.GSUB->table),
+ accels (face->table.GSUB->accels) {}
const OT::GSUB &table;
const OT::hb_ot_layout_lookup_accelerator_t *accels;
@@ -1254,8 +1254,8 @@ struct GPOSProxy
typedef OT::PosLookup Lookup;
GPOSProxy (hb_face_t *face) :
- table (*hb_ot_face_data (face)->GPOS->table),
- accels (hb_ot_face_data (face)->GPOS->accels) {}
+ table (*face->table.GPOS->table),
+ accels (face->table.GPOS->accels) {}
const OT::GPOS &table;
const OT::hb_ot_layout_lookup_accelerator_t *accels;
@@ -1414,7 +1414,7 @@ hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c,
static const OT::BASE& _get_base (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::BASE);
- return *hb_ot_face_data (face)->BASE;
+ return *face->table.BASE;
}
hb_bool_t
commit a35c92cbe771a75df40412fd248ad06f6a0cfebf
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 22:58:43 2018 -0500
[ot-face] Simplify table access
Yoohoo!
diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index 9e0eb92f..4c4e2945 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -172,88 +172,19 @@ AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_,
* mort/morx/kerx/trak
*/
-static inline const AAT::mort&
-_get_mort (hb_face_t *face, hb_blob_t **blob = nullptr)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
- {
- if (blob)
- *blob = hb_blob_get_empty ();
- return Null(AAT::mort);
- }
- const AAT::mort& mort = *(hb_ot_face_data (face)->mort);
- if (blob)
- *blob = hb_ot_face_data (face)->mort.get_blob ();
- return mort;
-}
-static inline const AAT::morx&
-_get_morx (hb_face_t *face, hb_blob_t **blob = nullptr)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
- {
- if (blob)
- *blob = hb_blob_get_empty ();
- return Null(AAT::morx);
- }
- const AAT::morx& morx = *(hb_ot_face_data (face)->morx);
- if (blob)
- *blob = hb_ot_face_data (face)->morx.get_blob ();
- return morx;
-}
-static inline const AAT::kerx&
-_get_kerx (hb_face_t *face, hb_blob_t **blob = nullptr)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
- {
- if (blob)
- *blob = hb_blob_get_empty ();
- return Null(AAT::kerx);
- }
- const AAT::kerx& kerx = *(hb_ot_face_data (face)->kerx);
- if (blob)
- *blob = hb_ot_face_data (face)->kerx.get_blob ();
- return kerx;
-}
-static inline const AAT::ankr&
-_get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
- {
- if (blob)
- *blob = hb_blob_get_empty ();
- return Null(AAT::ankr);
- }
- const AAT::ankr& ankr = *(hb_ot_face_data (face)->ankr);
- if (blob)
- *blob = hb_ot_face_data (face)->ankr.get_blob ();
- return ankr;
-}
-static inline const AAT::trak&
-_get_trak (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::trak);
- return *(hb_ot_face_data (face)->trak);
-}
-static inline const AAT::ltag&
-_get_ltag (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::ltag);
- return *(hb_ot_face_data (face)->ltag);
-}
-
void
hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
hb_aat_map_t *map)
{
- const AAT::morx& morx = _get_morx (mapper->face, nullptr);
+ const AAT::morx& morx = *mapper->face->table.morx;
if (morx.has_data ())
{
morx.compile_flags (mapper, map);
return;
}
- const AAT::mort& mort = _get_mort (mapper->face, nullptr);
+ const AAT::mort& mort = *mapper->face->table.mort;
if (mort.has_data ())
{
mort.compile_flags (mapper, map);
@@ -265,8 +196,8 @@ hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
hb_bool_t
hb_aat_layout_has_substitution (hb_face_t *face)
{
- return _get_morx (face).has_data () ||
- _get_mort (face).has_data ();
+ return face->table.morx->has_data ();
+ face->table.mort->has_data ();
}
void
@@ -274,20 +205,20 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
- hb_blob_t *blob;
-
- const AAT::morx& morx = _get_morx (font->face, &blob);
+ hb_blob_t *morx_blob = font->face->table.morx.get_blob ();
+ const AAT::morx& morx = *font->face->table.morx;
if (morx.has_data ())
{
- AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
+ AAT::hb_aat_apply_context_t c (plan, font, buffer, morx_blob);
morx.apply (&c);
return;
}
- const AAT::mort& mort = _get_mort (font->face, &blob);
+ hb_blob_t *mort_blob = font->face->table.morx.get_blob ();
+ const AAT::mort& mort = *font->face->table.mort;
if (mort.has_data ())
{
- AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
+ AAT::hb_aat_apply_context_t c (plan, font, buffer, mort_blob);
mort.apply (&c);
return;
}
@@ -297,7 +228,7 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
hb_bool_t
hb_aat_layout_has_positioning (hb_face_t *face)
{
- return _get_kerx (face).has_data ();
+ return face->table.kerx->has_data ();
}
void
@@ -305,21 +236,22 @@ hb_aat_layout_position (hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
- hb_blob_t *blob;
- const AAT::kerx& kerx = _get_kerx (font->face, &blob);
+ hb_blob_t *blob = font->face->table.kerx.get_blob ();
+ const AAT::kerx& kerx = *font->face->table.kerx;
- hb_blob_t *ankr_blob;
- const AAT::ankr& ankr = _get_ankr (font->face, &ankr_blob);
+ hb_blob_t *ankr_blob = font->face->table.ankr.get_blob ();;
+ const AAT::ankr& ankr = *font->face->table.ankr;
AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
c.set_ankr_table (&ankr, ankr_blob->data + ankr_blob->length);
kerx.apply (&c);
}
+
hb_bool_t
hb_aat_layout_has_tracking (hb_face_t *face)
{
- return _get_trak (face).has_data ();
+ return face->table.trak->has_data ();
}
void
@@ -327,15 +259,16 @@ hb_aat_layout_track (hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
- const AAT::trak& trak = _get_trak (font->face);
+ const AAT::trak& trak = *font->face->table.trak;
AAT::hb_aat_apply_context_t c (plan, font, buffer);
trak.apply (&c);
}
+
hb_language_t
_hb_aat_language_get (hb_face_t *face,
unsigned int i)
{
- return _get_ltag (face).get_language (i);
+ return face->table.ltag->get_language (i);
}
diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc
index 853f65dc..cac289b2 100644
--- a/src/hb-ot-color.cc
+++ b/src/hb-ot-color.cc
@@ -50,42 +50,6 @@
**/
-static inline const OT::COLR&
-_get_colr (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::COLR);
- return *(hb_ot_face_data (face)->COLR);
-}
-
-static inline const OT::CBDT_accelerator_t&
-_get_cbdt (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CBDT_accelerator_t);
- return *(hb_ot_face_data (face)->CBDT);
-}
-
-static inline const OT::CPAL&
-_get_cpal (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CPAL);
- return *(hb_ot_face_data (face)->CPAL);
-}
-
-static inline const OT::sbix_accelerator_t&
-_get_sbix (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::sbix_accelerator_t);
- return *(hb_ot_face_data (face)->sbix);
-}
-
-static inline const OT::SVG_accelerator_t&
-_get_svg (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::SVG_accelerator_t);
- return *(hb_ot_face_data (face)->SVG);
-}
-
-
/*
* CPAL
*/
@@ -102,7 +66,7 @@ _get_svg (hb_face_t *face)
hb_bool_t
hb_ot_color_has_palettes (hb_face_t *face)
{
- return _get_cpal (face).has_data ();
+ return face->table.CPAL->has_data ();
}
/**
@@ -117,7 +81,7 @@ hb_ot_color_has_palettes (hb_face_t *face)
unsigned int
hb_ot_color_palette_get_count (hb_face_t *face)
{
- return _get_cpal (face).get_palette_count ();
+ return face->table.CPAL->get_palette_count ();
}
/**
@@ -137,7 +101,7 @@ hb_ot_name_id_t
hb_ot_color_palette_get_name_id (hb_face_t *face,
unsigned int palette_index)
{
- return _get_cpal (face).get_palette_name_id (palette_index);
+ return face->table.CPAL->get_palette_name_id (palette_index);
}
/**
@@ -153,7 +117,7 @@ hb_ot_name_id_t
hb_ot_color_palette_color_get_name_id (hb_face_t *face,
unsigned int color_index)
{
- return _get_cpal (face).get_color_name_id (color_index);
+ return face->table.CPAL->get_color_name_id (color_index);
}
/**
@@ -169,7 +133,7 @@ hb_ot_color_palette_flags_t
hb_ot_color_palette_get_flags (hb_face_t *face,
unsigned int palette_index)
{
- return _get_cpal(face).get_palette_flags (palette_index);
+ return face->table.CPAL->get_palette_flags (palette_index);
}
/**
@@ -203,7 +167,7 @@ hb_ot_color_palette_get_colors (hb_face_t *face,
unsigned int *colors_count /* IN/OUT. May be NULL. */,
hb_color_t *colors /* OUT. May be NULL. */)
{
- return _get_cpal (face).get_palette_colors (palette_index, start_offset, colors_count, colors);
+ return face->table.CPAL->get_palette_colors (palette_index, start_offset, colors_count, colors);
}
@@ -222,7 +186,7 @@ hb_ot_color_palette_get_colors (hb_face_t *face,
hb_bool_t
hb_ot_color_has_layers (hb_face_t *face)
{
- return _get_colr (face).has_data ();
+ return face->table.COLR->has_data ();
}
/**
@@ -245,7 +209,7 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
unsigned int *count, /* IN/OUT. May be NULL. */
hb_ot_color_layer_t *layers /* OUT. May be NULL. */)
{
- return _get_colr (face).get_glyph_layers (glyph, start_offset, count, layers);
+ return face->table.COLR->get_glyph_layers (glyph, start_offset, count, layers);
}
@@ -266,7 +230,7 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
hb_bool_t
hb_ot_color_has_svg (hb_face_t *face)
{
- return _get_svg (face).has_data ();
+ return face->table.SVG->has_data ();
}
/**
@@ -283,7 +247,7 @@ hb_ot_color_has_svg (hb_face_t *face)
hb_blob_t *
hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph)
{
- return _get_svg (face).reference_blob_for_glyph (glyph);
+ return face->table.SVG->reference_blob_for_glyph (glyph);
}
@@ -304,7 +268,7 @@ hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph)
hb_bool_t
hb_ot_color_has_png (hb_face_t *face)
{
- return _get_cbdt (face).has_data () || _get_sbix (face).has_data ();
+ return face->table.CBDT->has_data () || face->table.sbix->has_data ();
}
/**
@@ -325,11 +289,11 @@ hb_ot_color_glyph_reference_png (hb_font_t *font, hb_codepoint_t glyph)
{
hb_blob_t *blob = hb_blob_get_empty ();
- if (_get_sbix (font->face).has_data ())
- blob = _get_sbix (font->face).reference_png (font, glyph, nullptr, nullptr, nullptr);
+ if (font->face->table.sbix->has_data ())
+ blob = font->face->table.sbix->reference_png (font, glyph, nullptr, nullptr, nullptr);
- if (!blob->length && _get_cbdt (font->face).has_data ())
- blob = _get_cbdt (font->face).reference_png (font, glyph);
+ if (!blob->length && font->face->table.CBDT->has_data ())
+ blob = font->face->table.CBDT->reference_png (font, glyph);
return blob;
}
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index fcdc79ee..b3c63538 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -53,20 +53,6 @@
**/
-static inline const OT::kern&
-_get_kern (hb_face_t *face, hb_blob_t **blob = nullptr)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
- {
- if (blob)
- *blob = hb_blob_get_empty ();
- return Null(OT::kern);
- }
- const OT::kern& kern = *(hb_ot_face_data (face)->kern);
- if (blob)
- *blob = hb_ot_face_data (face)->kern.get_blob ();
- return kern;
-}
const OT::GDEF& _get_gdef (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF);
@@ -109,7 +95,7 @@ const OT::GPOS& _get_gpos_relaxed (hb_face_t *face)
hb_bool_t
hb_ot_layout_has_kerning (hb_face_t *face)
{
- return _get_kern (face).has_data ();
+ return face->table.kern->has_data ();
}
void
@@ -117,8 +103,8 @@ hb_ot_layout_kern (hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
- hb_blob_t *blob;
- const AAT::kern& kern = _get_kern (font->face, &blob);
+ hb_blob_t *blob = font->face->table.kern.get_blob ();
+ const AAT::kern& kern = *font->face->table.kern;
AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc
index 594f63ca..e1d26d30 100644
--- a/src/hb-ot-math.cc
+++ b/src/hb-ot-math.cc
@@ -40,13 +40,6 @@
**/
-static inline const OT::MATH&
-_get_math (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH);
- return *(hb_ot_face_data (face)->MATH);
-}
-
/*
* OT::MATH
*/
@@ -65,7 +58,7 @@ _get_math (hb_face_t *face)
hb_bool_t
hb_ot_math_has_data (hb_face_t *face)
{
- return _get_math (face).has_data ();
+ return face->table.MATH->has_data ();
}
/**
@@ -87,8 +80,7 @@ hb_position_t
hb_ot_math_get_constant (hb_font_t *font,
hb_ot_math_constant_t constant)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_constant(constant, font);
+ return font->face->table.MATH->get_constant(constant, font);
}
/**
@@ -104,8 +96,7 @@ hb_position_t
hb_ot_math_get_glyph_italics_correction (hb_font_t *font,
hb_codepoint_t glyph)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_glyph_info().get_italics_correction (glyph, font);
+ return font->face->table.MATH->get_math_glyph_info().get_italics_correction (glyph, font);
}
/**
@@ -121,8 +112,7 @@ hb_position_t
hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font,
hb_codepoint_t glyph)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_glyph_info().get_top_accent_attachment (glyph, font);
+ return font->face->table.MATH->get_math_glyph_info().get_top_accent_attachment (glyph, font);
}
/**
@@ -138,8 +128,7 @@ hb_bool_t
hb_ot_math_is_glyph_extended_shape (hb_face_t *face,
hb_codepoint_t glyph)
{
- const OT::MATH &math = _get_math (face);
- return math.get_math_glyph_info().is_extended_shape (glyph);
+ return face->table.MATH->get_math_glyph_info().is_extended_shape (glyph);
}
/**
@@ -165,8 +154,7 @@ hb_ot_math_get_glyph_kerning (hb_font_t *font,
hb_ot_math_kern_t kern,
hb_position_t correction_height)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_glyph_info().get_kerning (glyph, kern, correction_height, font);
+ return font->face->table.MATH->get_math_glyph_info().get_kerning (glyph, kern, correction_height, font);
}
/**
@@ -196,11 +184,10 @@ hb_ot_math_get_glyph_variants (hb_font_t *font,
unsigned int *variants_count, /* IN/OUT */
hb_ot_math_glyph_variant_t *variants /* OUT */)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_variants().get_glyph_variants (glyph, direction, font,
- start_offset,
- variants_count,
- variants);
+ return font->face->table.MATH->get_math_variants().get_glyph_variants (glyph, direction, font,
+ start_offset,
+ variants_count,
+ variants);
}
/**
@@ -221,8 +208,7 @@ hb_position_t
hb_ot_math_get_min_connector_overlap (hb_font_t *font,
hb_direction_t direction)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_variants().get_min_connector_overlap (direction, font);
+ return font->face->table.MATH->get_math_variants().get_min_connector_overlap (direction, font);
}
/**
@@ -254,10 +240,9 @@ hb_ot_math_get_glyph_assembly (hb_font_t *font,
hb_ot_math_glyph_part_t *parts, /* OUT */
hb_position_t *italics_correction /* OUT */)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_variants().get_glyph_parts (glyph, direction, font,
- start_offset,
- parts_count,
- parts,
- italics_correction);
+ return font->face->table.MATH->get_math_variants().get_glyph_parts (glyph, direction, font,
+ start_offset,
+ parts_count,
+ parts,
+ italics_correction);
}
diff --git a/src/hb-ot-name.cc b/src/hb-ot-name.cc
index f2d1f0c2..4c886609 100644
--- a/src/hb-ot-name.cc
+++ b/src/hb-ot-name.cc
@@ -42,13 +42,6 @@
**/
-static inline const OT::name_accelerator_t&
-_get_name (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::name_accelerator_t);
- return *(hb_ot_face_data (face)->name);
-}
-
/**
* hb_ot_name_list_names:
* @face: font face.
@@ -65,7 +58,7 @@ const hb_ot_name_entry_t *
hb_ot_name_list_names (hb_face_t *face,
unsigned int *num_entries /* OUT */)
{
- const OT::name_accelerator_t &name = _get_name (face);
+ const OT::name_accelerator_t &name = *face->table.name;
if (num_entries) *num_entries = name.names.len;
return name.names.arrayZ();
}
@@ -124,7 +117,7 @@ hb_ot_name_get_utf (hb_face_t *face,
unsigned int *text_size /* IN/OUT */,
typename utf_t::codepoint_t *text /* OUT */)
{
- const OT::name_accelerator_t &name = _get_name (face);
+ const OT::name_accelerator_t &name = *face->table.name;
if (!language)
language = hb_language_from_string ("en", 2);
diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc
index 4363f85e..c97e9c49 100644
--- a/src/hb-ot-var.cc
+++ b/src/hb-ot-var.cc
@@ -47,18 +47,6 @@
* fvar/avar
*/
-static inline const OT::fvar&
-_get_fvar (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::fvar);
- return *(hb_ot_face_data (face)->fvar);
-}
-static inline const OT::avar&
-_get_avar (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::avar);
- return *(hb_ot_face_data (face)->avar);
-}
/**
* hb_ot_var_has_data:
@@ -74,7 +62,7 @@ _get_avar (hb_face_t *face)
hb_bool_t
hb_ot_var_has_data (hb_face_t *face)
{
- return _get_fvar (face).has_data ();
+ return face->table.fvar->has_data ();
}
/**
@@ -85,8 +73,7 @@ hb_ot_var_has_data (hb_face_t *face)
unsigned int
hb_ot_var_get_axis_count (hb_face_t *face)
{
- const OT::fvar &fvar = _get_fvar (face);
- return fvar.get_axis_count ();
+ return face->table.fvar->get_axis_count ();
}
/**
@@ -100,8 +87,7 @@ hb_ot_var_get_axes (hb_face_t *face,
unsigned int *axes_count /* IN/OUT */,
hb_ot_var_axis_t *axes_array /* OUT */)
{
- const OT::fvar &fvar = _get_fvar (face);
- return fvar.get_axis_infos (start_offset, axes_count, axes_array);
+ return face->table.fvar->get_axis_infos (start_offset, axes_count, axes_array);
}
/**
@@ -115,8 +101,7 @@ hb_ot_var_find_axis (hb_face_t *face,
unsigned int *axis_index,
hb_ot_var_axis_t *axis_info)
{
- const OT::fvar &fvar = _get_fvar (face);
- return fvar.find_axis (axis_tag, axis_index, axis_info);
+ return face->table.fvar->find_axis (axis_tag, axis_index, axis_info);
}
@@ -135,7 +120,7 @@ hb_ot_var_normalize_variations (hb_face_t *face,
for (unsigned int i = 0; i < coords_length; i++)
coords[i] = 0;
- const OT::fvar &fvar = _get_fvar (face);
+ const OT::fvar &fvar = *face->table.fvar;
for (unsigned int i = 0; i < variations_length; i++)
{
unsigned int axis_index;
@@ -144,8 +129,7 @@ hb_ot_var_normalize_variations (hb_face_t *face,
coords[axis_index] = fvar.normalize_axis_value (axis_index, variations[i].value);
}
- const OT::avar &avar = _get_avar (face);
- avar.map_coords (coords, coords_length);
+ face->table.avar->map_coords (coords, coords_length);
}
/**
@@ -159,10 +143,9 @@ hb_ot_var_normalize_coords (hb_face_t *face,
const float *design_coords, /* IN */
int *normalized_coords /* OUT */)
{
- const OT::fvar &fvar = _get_fvar (face);
+ const OT::fvar &fvar = *face->table.fvar;
for (unsigned int i = 0; i < coords_length; i++)
normalized_coords[i] = fvar.normalize_axis_value (i, design_coords[i]);
- const OT::avar &avar = _get_avar (face);
- avar.map_coords (normalized_coords, coords_length);
+ face->table.avar->map_coords (normalized_coords, coords_length);
}
commit 914b595f2598d5bdb2c750832d567a57d45db84e
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 5 22:39:50 2018 -0500
[ot-face] Include hb-ot-face directly in hb_face_t
Simplifying access coming next.
diff --git a/src/hb-face.cc b/src/hb-face.cc
index a0f8047f..921eed28 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -132,6 +132,8 @@ hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
face->upem = 0;
face->num_glyphs = (unsigned int) -1;
+ face->table.init0 (face);
+
return face;
}
@@ -275,6 +277,8 @@ hb_face_destroy (hb_face_t *face)
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
+ face->table.fini ();
+
if (face->destroy)
face->destroy (face->user_data);
diff --git a/src/hb-face.hh b/src/hb-face.hh
index 520bdfdf..726f6883 100644
--- a/src/hb-face.hh
+++ b/src/hb-face.hh
@@ -33,6 +33,7 @@
#include "hb-shaper.hh"
#include "hb-shape-plan.hh"
+#include "hb-ot-face.hh"
/*
@@ -53,6 +54,8 @@ struct hb_face_t
struct hb_shaper_data_t shaper_data; /* Various shaper data. */
+ hb_ot_face_t table;
+
/* Cache */
struct plan_node_t
{
diff --git a/src/hb-ot-face.cc b/src/hb-ot-face.cc
index cbceea9b..c7dafdd4 100644
--- a/src/hb-ot-face.cc
+++ b/src/hb-ot-face.cc
@@ -40,7 +40,7 @@
#include "hb-ot-layout-gpos-table.hh"
-void hb_ot_face_data_t::init0 (hb_face_t *face)
+void hb_ot_face_t::init0 (hb_face_t *face)
{
this->face = face;
#define HB_OT_TABLE(Namespace, Type) Type.init0 ();
@@ -49,7 +49,7 @@ void hb_ot_face_data_t::init0 (hb_face_t *face)
#undef HB_OT_ACCELERATOR
#undef HB_OT_TABLE
}
-void hb_ot_face_data_t::fini (void)
+void hb_ot_face_t::fini (void)
{
#define HB_OT_TABLE(Namespace, Type) Type.fini ();
#define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type)
@@ -57,23 +57,3 @@ void hb_ot_face_data_t::fini (void)
#undef HB_OT_ACCELERATOR
#undef HB_OT_TABLE
}
-
-hb_ot_face_data_t *
-_hb_ot_face_data_create (hb_face_t *face)
-{
- hb_ot_face_data_t *data = (hb_ot_face_data_t *) calloc (1, sizeof (hb_ot_face_data_t));
- if (unlikely (!data))
- return nullptr;
-
- data->init0 (face);
-
- return data;
-}
-
-void
-_hb_ot_face_data_destroy (hb_ot_face_data_t *data)
-{
- data->fini ();
- free (data);
-}
-
diff --git a/src/hb-ot-face.hh b/src/hb-ot-face.hh
index caa1d97e..46d5db75 100644
--- a/src/hb-ot-face.hh
+++ b/src/hb-ot-face.hh
@@ -34,44 +34,42 @@
#include "hb-machinery.hh"
-#define hb_ot_face_data(face) ((hb_ot_face_data_t *) face->shaper_data.ot.get_relaxed ())
+#define hb_ot_face_data(face) (&face->table)
/*
- * hb_ot_face_data_t
+ * hb_ot_face_t
*/
-/* Most of these tables are NOT needed for shaping. But we need to hook them *somewhere*.
- * This is as good as any place. */
#define HB_OT_TABLES \
+ /* OpenType fundamentals. */ \
+ HB_OT_ACCELERATOR(OT, cmap) \
+ HB_OT_ACCELERATOR(OT, hmtx) \
+ HB_OT_ACCELERATOR(OT, vmtx) \
+ HB_OT_ACCELERATOR(OT, post) \
+ HB_OT_TABLE(OT, kern) \
+ HB_OT_ACCELERATOR(OT, glyf) \
+ HB_OT_TABLE(OT, VORG) \
+ HB_OT_ACCELERATOR(OT, name) \
/* OpenType shaping. */ \
HB_OT_ACCELERATOR(OT, GDEF) \
HB_OT_ACCELERATOR(OT, GSUB) \
HB_OT_ACCELERATOR(OT, GPOS) \
- HB_OT_TABLE(OT, JSTF) \
HB_OT_TABLE(OT, BASE) \
+ HB_OT_TABLE(OT, JSTF) \
/* AAT shaping. */ \
- HB_OT_TABLE(AAT, morx) \
HB_OT_TABLE(AAT, mort) \
+ HB_OT_TABLE(AAT, morx) \
HB_OT_TABLE(AAT, kerx) \
HB_OT_TABLE(AAT, ankr) \
HB_OT_TABLE(AAT, trak) \
+ HB_OT_TABLE(AAT, ltag) \
/* OpenType variations. */ \
HB_OT_TABLE(OT, fvar) \
HB_OT_TABLE(OT, avar) \
HB_OT_TABLE(OT, MVAR) \
/* OpenType math. */ \
HB_OT_TABLE(OT, MATH) \
- /* OpenType fundamentals. */ \
- HB_OT_ACCELERATOR(OT, cmap) \
- HB_OT_ACCELERATOR(OT, hmtx) \
- HB_OT_ACCELERATOR(OT, vmtx) \
- HB_OT_ACCELERATOR(OT, post) \
- HB_OT_TABLE(OT, kern) \
- HB_OT_ACCELERATOR(OT, glyf) \
- HB_OT_TABLE(OT, VORG) \
- HB_OT_ACCELERATOR(OT, name) \
- HB_OT_TABLE(AAT, ltag) \
/* OpenType color fonts. */ \
HB_OT_TABLE(OT, COLR) \
HB_OT_TABLE(OT, CPAL) \
@@ -87,7 +85,7 @@ HB_OT_TABLES
#undef HB_OT_ACCELERATOR
#undef HB_OT_TABLE
-struct hb_ot_face_data_t
+struct hb_ot_face_t
{
HB_INTERNAL void init0 (hb_face_t *face);
HB_INTERNAL void fini (void);
@@ -115,11 +113,4 @@ struct hb_ot_face_data_t
};
-HB_INTERNAL hb_ot_face_data_t *
-_hb_ot_face_data_create (hb_face_t *face);
-
-HB_INTERNAL void
-_hb_ot_face_data_destroy (hb_ot_face_data_t *data);
-
-
#endif /* HB_OT_FACE_HH */
diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc
index 3e2f1f65..54095c17 100644
--- a/src/hb-ot-font.cc
+++ b/src/hb-ot-font.cc
@@ -61,7 +61,7 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->cmap->get_nominal_glyph (unicode, glyph);
}
@@ -75,7 +75,7 @@ hb_ot_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
unsigned int glyph_stride,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->cmap->get_nominal_glyphs (count,
first_unicode, unicode_stride,
first_glyph, glyph_stride);
@@ -89,7 +89,7 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->cmap->get_variation_glyph (unicode, variation_selector, glyph);
}
@@ -102,7 +102,7 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data,
unsigned advance_stride,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx;
for (unsigned int i = 0; i < count; i++)
@@ -122,7 +122,7 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data,
unsigned advance_stride,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
for (unsigned int i = 0; i < count; i++)
@@ -141,7 +141,7 @@ hb_ot_get_glyph_v_origin (hb_font_t *font,
hb_position_t *y,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
*x = font->get_glyph_h_advance (glyph) / 2;
@@ -175,7 +175,7 @@ hb_ot_get_glyph_extents (hb_font_t *font,
hb_glyph_extents_t *extents,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
bool ret = ot_face->sbix->get_extents (font, glyph, extents);
if (!ret)
ret = ot_face->glyf->get_extents (glyph, extents);
@@ -196,7 +196,7 @@ hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED,
char *name, unsigned int size,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->post->get_glyph_name (glyph, name, size);
}
@@ -207,7 +207,7 @@ hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->post->get_glyph_from_name (name, len, glyph);
}
@@ -217,7 +217,7 @@ hb_ot_get_font_h_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx;
metrics->ascender = font->em_scale_y (hmtx.ascender);
metrics->descender = font->em_scale_y (hmtx.descender);
@@ -232,7 +232,7 @@ hb_ot_get_font_v_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
metrics->ascender = font->em_scale_x (vmtx.ascender);
metrics->descender = font->em_scale_x (vmtx.descender);
@@ -299,7 +299,7 @@ void
hb_ot_font_set_funcs (hb_font_t *font)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return;
- hb_ot_face_data_t *ot_face = hb_ot_face_data (font->face);
+ hb_ot_face_t *ot_face = hb_ot_face_data (font->face);
hb_font_set_funcs (font,
_hb_ot_get_font_funcs (),
diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc
index 3fb720b2..594f63ca 100644
--- a/src/hb-ot-math.cc
+++ b/src/hb-ot-math.cc
@@ -44,8 +44,7 @@ static inline const OT::MATH&
_get_math (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH);
- hb_ot_face_data_t * data = hb_ot_face_data (face);
- return *(data->MATH);
+ return *(hb_ot_face_data (face)->MATH);
}
/*
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 8c5e38e0..98c29a48 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -258,16 +258,17 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
HB_SHAPER_DATA_ENSURE_DEFINE(ot, face)
+struct hb_ot_face_data_t {};
+
hb_ot_face_data_t *
_hb_ot_shaper_face_data_create (hb_face_t *face)
{
- return _hb_ot_face_data_create (face);
+ return (hb_ot_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
}
void
_hb_ot_shaper_face_data_destroy (hb_ot_face_data_t *data)
{
- _hb_ot_face_data_destroy (data);
}
More information about the HarfBuzz
mailing list