diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 8222a3fc3..c09464bbd 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -121,25 +121,6 @@ hb_ot_layout_position_finish_offsets (hb_font_t *font, * hb_ot_layout_t */ -namespace OT { - struct BASE; - struct COLR; - struct CPAL; - struct GDEF; - struct GSUB; - struct GPOS; - struct MATH; - struct fvar; - struct avar; -} - -namespace AAT { - struct ankr; - struct kerx; - struct morx; - struct trak; -} - struct hb_ot_layout_lookup_accelerator_t { template @@ -161,6 +142,32 @@ struct hb_ot_layout_lookup_accelerator_t hb_set_digest_t digest; }; +namespace OT { + struct BASE; + struct COLR; + struct CPAL; + struct GDEF; + struct GSUB; + struct GPOS; +} + +namespace AAT { + struct ankr; + struct kerx; + struct trak; +} + +#define HB_OT_LAYOUT_TABLES \ + HB_OT_LAYOUT_TABLE(OT, MATH) \ + HB_OT_LAYOUT_TABLE(OT, fvar) \ + HB_OT_LAYOUT_TABLE(OT, avar) \ + HB_OT_LAYOUT_TABLE(AAT, morx) \ + +/* Declare tables. */ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; } +HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + struct hb_ot_layout_t { hb_blob_t *gdef_blob; @@ -180,11 +187,25 @@ struct hb_ot_layout_t /* Various non-shaping tables. */ struct tables_t { + HB_INTERNAL void init0 (hb_face_t *face); + HB_INTERNAL void fini (void); + +#define HB_OT_LAYOUT_TABLE_ORDER(Namespace, Type) \ + HB_PASTE (TABLE_ORDER_, HB_PASTE (Namespace, HB_PASTE (_, Type))) + enum order_t + { + TABLE_ORDER_ZERO, +#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ + HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type), + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + }; + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ - hb_table_lazy_loader_t<1, struct OT::MATH> math; - hb_table_lazy_loader_t<2, struct OT::fvar> fvar; - hb_table_lazy_loader_t<3, struct OT::avar> avar; - hb_table_lazy_loader_t<4, struct AAT::morx> morx; +#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ + hb_table_lazy_loader_t Type; + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE } table; }; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 6af649529..d0adaeb32 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -149,6 +149,20 @@ _hb_ot_blacklist_gdef (unsigned int gdef_len, return false; } +void hb_ot_layout_t::tables_t::init0 (hb_face_t *face) +{ + this->face = face; +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.init0 (); + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE +} +void hb_ot_layout_t::tables_t::fini (void) +{ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.fini (); + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE +} + hb_ot_layout_t * _hb_ot_layout_create (hb_face_t *face) { @@ -165,11 +179,7 @@ _hb_ot_layout_create (hb_face_t *face) layout->gpos_blob = hb_sanitize_context_t ().reference_table (face); layout->gpos = layout->gpos_blob->as (); - layout->table.face = face; - layout->table.math.init0 (); - layout->table.fvar.init0 (); - layout->table.avar.init0 (); - layout->table.morx.init0 (); + layout->table.init0 (face); if (_hb_ot_blacklist_gdef (layout->gdef_blob->length, layout->gsub_blob->length, @@ -214,10 +224,7 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) hb_blob_destroy (layout->gsub_blob); hb_blob_destroy (layout->gpos_blob); - layout->table.math.fini (); - layout->table.fvar.fini (); - layout->table.avar.fini (); - layout->table.morx.fini (); + layout->table.fini (); free (layout); } diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc index 3e4ab7565..e7cb46524 100644 --- a/src/hb-ot-math.cc +++ b/src/hb-ot-math.cc @@ -34,7 +34,7 @@ _get_math (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->table.math.get ()); + return *(layout->table.MATH.get ()); } /*