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