diff --git a/src/hb-machinery-private.hh b/src/hb-machinery-private.hh index ec7a0da1a..cd608cfbb 100644 --- a/src/hb-machinery-private.hh +++ b/src/hb-machinery-private.hh @@ -613,10 +613,8 @@ struct hb_base_lazy_loader_t thiz ()->destroy (instance); } - inline const Returned * operator-> (void) const - { - return thiz ()->get (); - } + inline const Returned * operator -> (void) const { return thiz ()->get (); } + inline const Returned & operator * (void) const { return *thiz ()->get (); } inline Stored * get_stored (void) const { diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index b52c0144f..fe34a328b 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1628,14 +1628,14 @@ GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) template /*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { - const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS); const PosLookup &l = gpos.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 GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS); const PosLookup &l = gpos.get_lookup (lookup_index); unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_index = c->lookup_index; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index eef8dc546..b967bf6f1 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1359,14 +1359,14 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) template /*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB); const SubstLookup &l = gsub.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 GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB); const SubstLookup &l = gsub.get_lookup (lookup_index); unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_index = c->lookup_index; diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index c09464bbd..3c957f1e3 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -158,6 +158,8 @@ namespace AAT { } #define HB_OT_LAYOUT_TABLES \ + HB_OT_LAYOUT_TABLE(OT, GSUB) \ + HB_OT_LAYOUT_TABLE(OT, GPOS) \ HB_OT_LAYOUT_TABLE(OT, MATH) \ HB_OT_LAYOUT_TABLE(OT, fvar) \ HB_OT_LAYOUT_TABLE(OT, avar) \ @@ -171,12 +173,7 @@ HB_OT_LAYOUT_TABLES struct hb_ot_layout_t { hb_blob_t *gdef_blob; - hb_blob_t *gsub_blob; - hb_blob_t *gpos_blob; - const struct OT::GDEF *gdef; - const struct OT::GSUB *gsub; - const struct OT::GPOS *gpos; unsigned int gsub_lookup_count; unsigned int gpos_lookup_count; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index d0adaeb32..557800a63 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -173,36 +173,33 @@ _hb_ot_layout_create (hb_face_t *face) layout->gdef_blob = hb_sanitize_context_t ().reference_table (face); layout->gdef = layout->gdef_blob->as (); - layout->gsub_blob = hb_sanitize_context_t ().reference_table (face); - layout->gsub = layout->gsub_blob->as (); - - layout->gpos_blob = hb_sanitize_context_t ().reference_table (face); - layout->gpos = layout->gpos_blob->as (); - layout->table.init0 (face); + const OT::GSUB &gsub = *layout->table.GSUB; + const OT::GPOS &gpos = *layout->table.GPOS; + if (_hb_ot_blacklist_gdef (layout->gdef_blob->length, - layout->gsub_blob->length, - layout->gpos_blob->length)) + layout->table.GSUB.get_blob()->length, + layout->table.GPOS.get_blob()->length)) layout->gdef = &Null(OT::GDEF); - layout->gsub_lookup_count = layout->gsub->get_lookup_count (); - layout->gpos_lookup_count = layout->gpos->get_lookup_count (); + unsigned int gsub_lookup_count = layout->gsub_lookup_count = gsub.get_lookup_count (); + unsigned int gpos_lookup_count = layout->gpos_lookup_count = gpos.get_lookup_count (); - layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); - layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); + layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gsub_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); + layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gpos_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); - if (unlikely ((layout->gsub_lookup_count && !layout->gsub_accels) || - (layout->gpos_lookup_count && !layout->gpos_accels))) + if (unlikely ((gsub_lookup_count && !layout->gsub_accels) || + (gpos_lookup_count && !layout->gpos_accels))) { _hb_ot_layout_destroy (layout); return nullptr; } - for (unsigned int i = 0; i < layout->gsub_lookup_count; i++) - layout->gsub_accels[i].init (layout->gsub->get_lookup (i)); - for (unsigned int i = 0; i < layout->gpos_lookup_count; i++) - layout->gpos_accels[i].init (layout->gpos->get_lookup (i)); + for (unsigned int i = 0; i < gsub_lookup_count; i++) + layout->gsub_accels[i].init (gsub.get_lookup (i)); + for (unsigned int i = 0; i < gpos_lookup_count; i++) + layout->gpos_accels[i].init (gpos.get_lookup (i)); return layout; } @@ -221,8 +218,6 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) free (layout->gpos_accels); hb_blob_destroy (layout->gdef_blob); - hb_blob_destroy (layout->gsub_blob); - hb_blob_destroy (layout->gpos_blob); layout->table.fini (); @@ -247,13 +242,13 @@ 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_layout_from_face (face)->gsub; + return *hb_ot_layout_from_face (face)->table.GSUB; } 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_layout_from_face (face)->gpos; + return *hb_ot_layout_from_face (face)->table.GPOS; } /* @@ -861,13 +856,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, { case HB_OT_TAG_GSUB: { - const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index); + const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index); l.collect_glyphs (&c); return; } case HB_OT_TAG_GPOS: { - const OT::PosLookup& l = hb_ot_layout_from_face (face)->gpos->get_lookup (lookup_index); + const OT::PosLookup& l = hb_ot_layout_from_face (face)->table.GPOS->get_lookup (lookup_index); l.collect_glyphs (&c); return; } @@ -943,7 +938,7 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face, if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->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_layout_from_face (face)->gsub->get_lookup (lookup_index); + const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index); return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index]); } @@ -1101,7 +1096,7 @@ struct GSUBProxy typedef OT::SubstLookup Lookup; GSUBProxy (hb_face_t *face) : - table (*hb_ot_layout_from_face (face)->gsub), + table (*hb_ot_layout_from_face (face)->table.GSUB), accels (hb_ot_layout_from_face (face)->gsub_accels) {} const OT::GSUB &table; @@ -1115,7 +1110,7 @@ struct GPOSProxy typedef OT::PosLookup Lookup; GPOSProxy (hb_face_t *face) : - table (*hb_ot_layout_from_face (face)->gpos), + table (*hb_ot_layout_from_face (face)->table.GPOS), accels (hb_ot_layout_from_face (face)->gpos_accels) {} const OT::GPOS &table;