1 /* 2 * 3 * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved 4 * 5 */ 6 7 #ifndef __CONTEXTUALSUBSTITUTIONSUBTABLES_H 8 #define __CONTEXTUALSUBSTITUTIONSUBTABLES_H 9 10 /** 11 * \file 12 * \internal 13 */ 14 15 #include "LETypes.h" 16 #include "LEFontInstance.h" 17 #include "OpenTypeTables.h" 18 #include "GlyphSubstitutionTables.h" 19 #include "GlyphIterator.h" 20 #include "LookupProcessor.h" 21 22 U_NAMESPACE_BEGIN 23 24 struct SubstitutionLookupRecord 25 { 26 le_uint16 sequenceIndex; 27 le_uint16 lookupListIndex; 28 }; 29 30 struct ContextualSubstitutionBase : GlyphSubstitutionSubtable 31 { 32 static le_bool matchGlyphIDs( 33 const TTGlyphID *glyphArray, le_uint16 glyphCount, GlyphIterator *glyphIterator, 34 le_bool backtrack = FALSE); 35 36 static le_bool matchGlyphClasses( 37 const le_uint16 *classArray, le_uint16 glyphCount, GlyphIterator *glyphIterator, 38 const ClassDefinitionTable *classDefinitionTable, le_bool backtrack = FALSE); 39 40 static le_bool matchGlyphCoverages( 41 const Offset *coverageTableOffsetArray, le_uint16 glyphCount, 42 GlyphIterator *glyphIterator, const char *offsetBase, le_bool backtrack = FALSE); 43 44 static void applySubstitutionLookups( 45 const LookupProcessor *lookupProcessor, 46 const SubstitutionLookupRecord *substLookupRecordArray, 47 le_uint16 substCount, 48 GlyphIterator *glyphIterator, 49 const LEFontInstance *fontInstance, 50 le_int32 position, 51 LEErrorCode& success); 52 }; 53 54 struct ContextualSubstitutionSubtable : ContextualSubstitutionBase 55 { 56 le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const; 57 }; 58 59 struct ContextualSubstitutionFormat1Subtable : ContextualSubstitutionSubtable 60 { 61 le_uint16 subRuleSetCount; 62 Offset subRuleSetTableOffsetArray[ANY_NUMBER]; 63 64 le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const; 65 }; 66 67 struct SubRuleSetTable 68 { 69 le_uint16 subRuleCount; 70 Offset subRuleTableOffsetArray[ANY_NUMBER]; 71 72 }; 73 74 // NOTE: Multiple variable size arrays!! 75 struct SubRuleTable 76 { 77 le_uint16 glyphCount; 78 le_uint16 substCount; 79 TTGlyphID inputGlyphArray[ANY_NUMBER]; 80 //SubstitutionLookupRecord substLookupRecordArray[ANY_NUMBER]; 81 }; 82 83 struct ContextualSubstitutionFormat2Subtable : ContextualSubstitutionSubtable 84 { 85 Offset classDefTableOffset; 86 le_uint16 subClassSetCount; 87 Offset subClassSetTableOffsetArray[ANY_NUMBER]; 88 89 le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const; 90 }; 91 92 struct SubClassSetTable 93 { 94 le_uint16 subClassRuleCount; 95 Offset subClassRuleTableOffsetArray[ANY_NUMBER]; 96 }; 97 98 // NOTE: Multiple variable size arrays!! 99 struct SubClassRuleTable 100 { 101 le_uint16 glyphCount; 102 le_uint16 substCount; 103 le_uint16 classArray[ANY_NUMBER]; 104 //SubstitutionLookupRecord substLookupRecordArray[ANY_NUMBER]; 105 }; 106 107 // NOTE: This isn't a subclass of GlyphSubstitutionSubtable 'cause 108 // it has an array of coverage tables instead of a single coverage table... 109 // 110 // NOTE: Multiple variable size arrays!! 111 struct ContextualSubstitutionFormat3Subtable 112 { 113 le_uint16 substFormat; 114 le_uint16 glyphCount; 115 le_uint16 substCount; 116 Offset coverageTableOffsetArray[ANY_NUMBER]; 117 //SubstitutionLookupRecord substLookupRecord[ANY_NUMBER]; 118 119 le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const; 120 }; 121 122 struct ChainingContextualSubstitutionSubtable : ContextualSubstitutionBase 123 { 124 le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const; 125 }; 126 127 struct ChainingContextualSubstitutionFormat1Subtable : ChainingContextualSubstitutionSubtable 128 { 129 le_uint16 chainSubRuleSetCount; 130 Offset chainSubRuleSetTableOffsetArray[ANY_NUMBER]; 131 132 le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const; 133 }; 134 135 struct ChainSubRuleSetTable 136 { 137 le_uint16 chainSubRuleCount; 138 Offset chainSubRuleTableOffsetArray[ANY_NUMBER]; 139 140 }; 141 142 // NOTE: Multiple variable size arrays!! 143 struct ChainSubRuleTable 144 { 145 le_uint16 backtrackGlyphCount; 146 TTGlyphID backtrackGlyphArray[ANY_NUMBER]; 147 //le_uint16 inputGlyphCount; 148 //TTGlyphID inputGlyphArray[ANY_NUMBER]; 149 //le_uint16 lookaheadGlyphCount; 150 //TTGlyphID lookaheadGlyphArray[ANY_NUMBER]; 151 //le_uint16 substCount; 152 //SubstitutionLookupRecord substLookupRecordArray[ANY_NUMBER]; 153 }; 154 155 struct ChainingContextualSubstitutionFormat2Subtable : ChainingContextualSubstitutionSubtable 156 { 157 Offset backtrackClassDefTableOffset; 158 Offset inputClassDefTableOffset; 159 Offset lookaheadClassDefTableOffset; 160 le_uint16 chainSubClassSetCount; 161 Offset chainSubClassSetTableOffsetArray[ANY_NUMBER]; 162 163 le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const; 164 }; 165 166 struct ChainSubClassSetTable 167 { 168 le_uint16 chainSubClassRuleCount; 169 Offset chainSubClassRuleTableOffsetArray[ANY_NUMBER]; 170 }; 171 172 // NOTE: Multiple variable size arrays!! 173 struct ChainSubClassRuleTable 174 { 175 le_uint16 backtrackGlyphCount; 176 le_uint16 backtrackClassArray[ANY_NUMBER]; 177 //le_uint16 inputGlyphCount; 178 //le_uint16 inputClassArray[ANY_NUMBER]; 179 //le_uint16 lookaheadGlyphCount; 180 //le_uint16 lookaheadClassArray[ANY_NUMBER]; 181 //le_uint16 substCount; 182 //SubstitutionLookupRecord substLookupRecordArray[ANY_NUMBER]; 183 }; 184 185 // NOTE: This isn't a subclass of GlyphSubstitutionSubtable 'cause 186 // it has arrays of coverage tables instead of a single coverage table... 187 // 188 // NOTE: Multiple variable size arrays!! 189 struct ChainingContextualSubstitutionFormat3Subtable 190 { 191 le_uint16 substFormat; 192 le_uint16 backtrackGlyphCount; 193 Offset backtrackCoverageTableOffsetArray[ANY_NUMBER]; 194 //le_uint16 inputGlyphCount; 195 //Offset inputCoverageTableOffsetArray[ANY_NUMBER]; 196 //le_uint16 lookaheadGlyphCount; 197 //le_uint16 lookaheadCoverageTableOffsetArray[ANY_NUMBER]; 198 //le_uint16 substCount; 199 //SubstitutionLookupRecord substLookupRecord[ANY_NUMBER]; 200 201 le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const; 202 }; 203 204 U_NAMESPACE_END 205 #endif 206