diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index c8020d87ca77da66b94ca3032a1fb0c9e5dbff81..fa229348a9c25948be101afaee864a0eff3f4416 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1268,7 +1268,7 @@ struct ChainContextPos : ChainContext }; -struct ExtensionPos : Extension +struct ExtensionPos : Extension { friend struct PosLookupSubTable; @@ -1382,8 +1382,10 @@ struct PosLookupSubTable struct PosLookup : Lookup { - inline const PosLookupSubTable& get_subtable (unsigned int i) const - { return this+CastR > (subTable)[i]; } + typedef struct PosLookupSubTable SubTable; + + inline const SubTable& get_subtable (unsigned int i) const + { return this+CastR > (subTable)[i]; } inline bool apply_once (hb_apply_context_t *c) const { @@ -1424,7 +1426,7 @@ struct PosLookup : Lookup inline bool sanitize (hb_sanitize_context_t *c) { TRACE_SANITIZE (); if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); - OffsetArrayOf &list = CastR > (subTable); + OffsetArrayOf &list = CastR > (subTable); return TRACE_RETURN (list.sanitize (c, this, get_type ())); } }; @@ -1437,6 +1439,8 @@ typedef OffsetListOf PosLookupList; struct GPOS : GSUBGPOS { + typedef struct PosLookup Lookup; + static const hb_tag_t Tag = HB_OT_TAG_GPOS; inline const PosLookup& get_lookup (unsigned int i) const @@ -1545,10 +1549,10 @@ inline bool ExtensionPos::apply (hb_apply_context_t *c) const inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c) { TRACE_SANITIZE (); - if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false); + if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false); unsigned int offset = get_offset (); if (unlikely (!offset)) return TRACE_RETURN (true); - return TRACE_RETURN (StructAtOffset (this, offset).sanitize (c, get_type ())); + return TRACE_RETURN (StructAtOffset (this, offset).sanitize (c, get_type ())); } static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index f5f38cc41de0e842666885e5ef5cdb03cb333a07..06a84889771c4a9487e4460b393304f08b70e117 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -750,7 +750,7 @@ struct ChainContextSubst : ChainContext }; -struct ExtensionSubst : Extension +struct ExtensionSubst : Extension { friend struct SubstLookupSubTable; friend struct SubstLookup; @@ -1037,16 +1037,18 @@ struct SubstLookupSubTable struct SubstLookup : Lookup { - inline const SubstLookupSubTable& get_subtable (unsigned int i) const - { return this+CastR > (subTable)[i]; } + typedef struct SubstLookupSubTable SubTable; + + inline const SubTable& get_subtable (unsigned int i) const + { return this+CastR > (subTable)[i]; } inline static bool lookup_type_is_reverse (unsigned int lookup_type) - { return lookup_type == SubstLookupSubTable::ReverseChainSingle; } + { return lookup_type == SubTable::ReverseChainSingle; } inline bool is_reverse (void) const { unsigned int type = get_type (); - if (unlikely (type == SubstLookupSubTable::Extension)) + if (unlikely (type == SubTable::Extension)) return CastR (get_subtable(0)).is_reverse (); return lookup_type_is_reverse (type); } @@ -1087,7 +1089,7 @@ struct SubstLookup : Lookup /* TODO: For the most common case this can move out of the main * loop, but it's not a big deal for now. */ - if (unlikely (lookup_type == SubstLookupSubTable::Extension)) + if (unlikely (lookup_type == SubTable::Extension)) { /* The spec says all subtables should have the same type. * This is specially important if one has a reverse type! @@ -1155,7 +1157,7 @@ struct SubstLookup : Lookup inline bool sanitize (hb_sanitize_context_t *c) { TRACE_SANITIZE (); if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); - OffsetArrayOf &list = CastR > (subTable); + OffsetArrayOf &list = CastR > (subTable); return TRACE_RETURN (list.sanitize (c, this, get_type ())); } }; @@ -1168,6 +1170,8 @@ typedef OffsetListOf SubstLookupList; struct GSUB : GSUBGPOS { + typedef struct SubstLookup Lookup; + static const hb_tag_t Tag = HB_OT_TAG_GSUB; inline const SubstLookup& get_lookup (unsigned int i) const @@ -1238,16 +1242,16 @@ inline bool ExtensionSubst::apply (hb_apply_context_t *c) const inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *c) { TRACE_SANITIZE (); - if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false); + if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false); unsigned int offset = get_offset (); if (unlikely (!offset)) return TRACE_RETURN (true); - return TRACE_RETURN (StructAtOffset (this, offset).sanitize (c, get_type ())); + return TRACE_RETURN (StructAtOffset (this, offset).sanitize (c, get_type ())); } inline bool ExtensionSubst::is_reverse (void) const { unsigned int type = get_type (); - if (unlikely (type == SubstLookupSubTable::Extension)) + if (unlikely (type == SubstLookup::SubTable::Extension)) return CastR (get_subtable()).is_reverse (); return SubstLookup::lookup_type_is_reverse (type); } diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 98d4e0a494c5b71cb41dbc7b4e7087cad4656da1..0e9d08a0c435681ebc9c981fe30e70047e50403a 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -298,6 +298,27 @@ static inline bool intersects_array (hb_closure_context_t *c, } +struct match_glyph_t { + inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data) + { + return glyph_id == value; + } +}; +struct match_class_t { + inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data) + { + const ClassDef &class_def = *reinterpret_cast(data); + return class_def.get_class (glyph_id) == value; + } +}; +struct match_coverage_t { + inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data) + { + const OffsetTo &coverage = (const OffsetTo&)value; + return (data+coverage).get_coverage (glyph_id) != NOT_COVERED; + } +}; + static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED) { return glyph_id == value; @@ -314,6 +335,7 @@ static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, } +template static inline bool match_input (hb_apply_context_t *c, unsigned int count, /* Including the first glyph (not matched) */ const USHORT input[], /* Array of input values--start with second glyph */ @@ -340,6 +362,7 @@ static inline bool match_input (hb_apply_context_t *c, return true; } +template static inline bool match_backtrack (hb_apply_context_t *c, unsigned int count, const USHORT backtrack[], @@ -362,6 +385,7 @@ static inline bool match_backtrack (hb_apply_context_t *c, return true; } +template static inline bool match_lookahead (hb_apply_context_t *c, unsigned int count, const USHORT lookahead[], @@ -1262,9 +1286,12 @@ struct ChainContext }; +template struct Extension; + +template struct ExtensionFormat1 { - friend struct Extension; + friend struct Extension; protected: inline unsigned int get_type (void) const { return extensionLookupType; } @@ -1286,6 +1313,7 @@ struct ExtensionFormat1 DEFINE_SIZE_STATIC (8); }; +template struct Extension { inline unsigned int get_type (void) const @@ -1315,7 +1343,8 @@ struct Extension private: union { USHORT format; /* Format identifier */ - ExtensionFormat1 format1; + ExtensionFormat1
+ format1; } u; };