diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 2eaa609f9..9dfac6749 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -571,6 +571,17 @@ struct Lookup { inline unsigned int get_subtable_count (void) const { return subTable.len; } + template + inline const SubTableType& get_subtable (unsigned int i) const + { return this+CastR > (subTable)[i]; } + + template + inline const OffsetArrayOf& get_subtables (void) const + { return CastR > (subTable); } + template + inline OffsetArrayOf& get_subtables (void) + { return CastR > (subTable); } + inline unsigned int get_type (void) const { return lookupType; } /* lookup_props is a 32-bit integer where the lower 16-bit is LookupFlag and @@ -618,6 +629,7 @@ struct Lookup return TRACE_RETURN (true); } + private: USHORT lookupType; /* Different enumerations for GSUB and GPOS */ USHORT lookupFlag; /* Lookup qualifiers */ ArrayOf > diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index ae89f7adc..63302e252 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1489,7 +1489,7 @@ struct PosLookupSubTable struct PosLookup : Lookup { inline const PosLookupSubTable& get_subtable (unsigned int i) const - { return this+CastR > (subTable)[i]; } + { return Lookup::get_subtable (i); } inline bool is_reverse (void) const { @@ -1540,7 +1540,7 @@ struct PosLookup : Lookup { TRACE_SANITIZE (this); if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); - const OffsetArrayOf &list = CastR > (subTable); + const OffsetArrayOf &list = get_subtables (); return TRACE_RETURN (list.sanitize (c, this, get_type ())); } }; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index ed8604f29..ca79f81fb 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1170,7 +1170,7 @@ struct SubstLookupSubTable struct SubstLookup : Lookup { inline const SubstLookupSubTable& get_subtable (unsigned int i) const - { return this+CastR > (subTable)[i]; } + { return Lookup::get_subtable (i); } inline static bool lookup_type_is_reverse (unsigned int lookup_type) { return lookup_type == SubstLookupSubTable::ReverseChainSingle; } @@ -1225,7 +1225,7 @@ struct SubstLookup : Lookup inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c, unsigned int i) - { return CastR > (subTable)[i].serialize (c, this); } + { return get_subtables ()[i].serialize (c, this); } inline bool serialize_single (hb_serialize_context_t *c, uint32_t lookup_props, @@ -1300,7 +1300,7 @@ struct SubstLookup : Lookup { TRACE_SANITIZE (this); if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); - const OffsetArrayOf &list = CastR > (subTable); + const OffsetArrayOf &list = get_subtables (); if (unlikely (!list.sanitize (c, this, get_type ()))) return TRACE_RETURN (false); if (unlikely (get_type () == SubstLookupSubTable::Extension))