From b05941e12b2891d9064c4a7717a155d8b622aa6c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 16 May 2009 19:59:15 -0400 Subject: [PATCH] [GSUB] Start ChainContextSubst --- pango/opentype/hb-ot-layout-gsub-private.h | 50 +++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/pango/opentype/hb-ot-layout-gsub-private.h b/pango/opentype/hb-ot-layout-gsub-private.h index 1090650..1f44fb9 100644 --- a/pango/opentype/hb-ot-layout-gsub-private.h +++ b/pango/opentype/hb-ot-layout-gsub-private.h @@ -127,9 +127,6 @@ struct SingleSubst { inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const { - if (HB_UNLIKELY (context_length < 1)) - return false; - unsigned int property; if (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM (), lookup_flag, &property)) return false; @@ -217,9 +214,6 @@ struct MultipleSubstFormat1 { inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const { - if (HB_UNLIKELY (context_length < 1)) - return false; - unsigned int property; if (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM (), lookup_flag, &property)) return false; @@ -292,9 +286,6 @@ struct AlternateSubstFormat1 { inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const { - if (HB_UNLIKELY (context_length < 1)) - return false; - unsigned int property; if (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM (), lookup_flag, &property)) return false; @@ -983,6 +974,9 @@ DEFINE_NULL_ASSERT_SIZE (ChainSubRuleSet, 2); struct ChainContextSubstFormat1 { /* TODO */ + inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const { + return false; + } private: USHORT substFormat; /* Format identifier--format = 1 */ @@ -1006,7 +1000,7 @@ struct ChainSubClassRule { * backtrack sequence (number of * glyphs to be matched before the * first glyph) */ - USHORT backtrack[]; /* Array of backtracking classes(to be + USHORT backtrack[]; /* Array of backtracking classes (to be * matched before the input sequence) */ USHORT inputGlyphCount; /* Total number of classes in the input * sequence (includes the first class) */ @@ -1017,7 +1011,7 @@ struct ChainSubClassRule { * look ahead sequence (number of * classes to be matched after the * input sequence) */ - USHORT lookAhead[]; /* Array of lookahead classes(to be + USHORT lookAhead[]; /* Array of lookahead classes (to be * matched after the input sequence) */ USHORT substCount; /* Number of SubstLookupRecords */ SubstLookupRecord substLookupRecord[];/* Array of SubstLookupRecords--in @@ -1040,6 +1034,9 @@ DEFINE_NULL_ASSERT_SIZE (ChainSubClassSet, 2); struct ChainContextSubstFormat2 { /* TODO */ + inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const { + return false; + } private: USHORT substFormat; /* Format identifier--format = 2 */ @@ -1067,6 +1064,9 @@ ASSERT_SIZE (ChainContextSubstFormat2, 12); struct ChainContextSubstFormat3 { /* TODO */ + inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const { + return false; + } private: USHORT substFormat; /* Format identifier--format = 3 */ @@ -1090,6 +1090,31 @@ struct ChainContextSubstFormat3 { }; ASSERT_SIZE (ChainContextSubstFormat3, 10); +struct ChainContextSubst { + + friend struct SubstLookupSubTable; + + private: + + inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const { + switch (u.substFormat) { + case 1: return u.format1.substitute (SUBTABLE_SUBSTITUTE_ARGS); + case 2: return u.format2.substitute (SUBTABLE_SUBSTITUTE_ARGS); + case 3: return u.format3.substitute (SUBTABLE_SUBSTITUTE_ARGS); + default:return false; + } + } + + private: + union { + USHORT substFormat; /* Format identifier */ + ChainContextSubstFormat1 format1; + ChainContextSubstFormat2 format2; + ChainContextSubstFormat3 format3; + } u; +}; +DEFINE_NULL (ChainContextSubst, 2); + struct ExtensionSubstFormat1 { @@ -1261,6 +1286,9 @@ struct SubstLookup : Lookup { return false; nesting_level_left--; + if (HB_UNLIKELY (context_length < 1)) + return false; + for (unsigned int i = 0; i < get_subtable_count (); i++) if (get_subtable (i).substitute (SUBTABLE_SUBSTITUTE_ARGS, lookup_type)) -- 2.7.4