3 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
7 #ifndef __CONTEXTUALSUBSTITUTIONSUBTABLES_H
8 #define __CONTEXTUALSUBSTITUTIONSUBTABLES_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"
25 struct SubstitutionLookupRecord
27 le_uint16 sequenceIndex
;
28 le_uint16 lookupListIndex
;
31 struct ContextualSubstitutionBase
: GlyphSubstitutionSubtable
33 static le_bool
matchGlyphIDs(
34 const TTGlyphID
*glyphArray
, le_uint16 glyphCount
, GlyphIterator
*glyphIterator
,
35 le_bool backtrack
= FALSE
);
37 static le_bool
matchGlyphClasses(
38 const le_uint16
*classArray
, le_uint16 glyphCount
, GlyphIterator
*glyphIterator
,
39 const ClassDefinitionTable
*classDefinitionTable
, le_bool backtrack
= FALSE
);
41 static le_bool
matchGlyphCoverages(
42 const Offset
*coverageTableOffsetArray
, le_uint16 glyphCount
,
43 GlyphIterator
*glyphIterator
, const char *offsetBase
, le_bool backtrack
= FALSE
);
45 static void applySubstitutionLookups(
46 const LookupProcessor
*lookupProcessor
,
47 const SubstitutionLookupRecord
*substLookupRecordArray
,
49 GlyphIterator
*glyphIterator
,
50 const LEFontInstance
*fontInstance
,
52 LEErrorCode
& success
);
55 struct ContextualSubstitutionSubtable
: ContextualSubstitutionBase
57 le_uint32
process(const LookupProcessor
*lookupProcessor
, GlyphIterator
*glyphIterator
, const LEFontInstance
*fontInstance
, LEErrorCode
& success
) const;
60 struct ContextualSubstitutionFormat1Subtable
: ContextualSubstitutionSubtable
62 le_uint16 subRuleSetCount
;
63 Offset subRuleSetTableOffsetArray
[ANY_NUMBER
];
65 le_uint32
process(const LookupProcessor
*lookupProcessor
, GlyphIterator
*glyphIterator
, const LEFontInstance
*fontInstance
, LEErrorCode
& success
) const;
67 LE_VAR_ARRAY(ContextualSubstitutionFormat1Subtable
, subRuleSetTableOffsetArray
)
70 struct SubRuleSetTable
72 le_uint16 subRuleCount
;
73 Offset subRuleTableOffsetArray
[ANY_NUMBER
];
76 LE_VAR_ARRAY(SubRuleSetTable
, subRuleTableOffsetArray
)
78 // NOTE: Multiple variable size arrays!!
83 TTGlyphID inputGlyphArray
[ANY_NUMBER
];
84 //SubstitutionLookupRecord substLookupRecordArray[ANY_NUMBER];
86 LE_VAR_ARRAY(SubRuleTable
, inputGlyphArray
)
88 struct ContextualSubstitutionFormat2Subtable
: ContextualSubstitutionSubtable
90 Offset classDefTableOffset
;
91 le_uint16 subClassSetCount
;
92 Offset subClassSetTableOffsetArray
[ANY_NUMBER
];
94 le_uint32
process(const LookupProcessor
*lookupProcessor
, GlyphIterator
*glyphIterator
, const LEFontInstance
*fontInstance
, LEErrorCode
& success
) const;
96 LE_VAR_ARRAY(ContextualSubstitutionFormat2Subtable
, subClassSetTableOffsetArray
)
99 struct SubClassSetTable
101 le_uint16 subClassRuleCount
;
102 Offset subClassRuleTableOffsetArray
[ANY_NUMBER
];
104 LE_VAR_ARRAY(SubClassSetTable
, subClassRuleTableOffsetArray
)
107 // NOTE: Multiple variable size arrays!!
108 struct SubClassRuleTable
110 le_uint16 glyphCount
;
111 le_uint16 substCount
;
112 le_uint16 classArray
[ANY_NUMBER
];
113 //SubstitutionLookupRecord substLookupRecordArray[ANY_NUMBER];
115 LE_VAR_ARRAY(SubClassRuleTable
, classArray
)
118 // NOTE: This isn't a subclass of GlyphSubstitutionSubtable 'cause
119 // it has an array of coverage tables instead of a single coverage table...
121 // NOTE: Multiple variable size arrays!!
122 struct ContextualSubstitutionFormat3Subtable
124 le_uint16 substFormat
;
125 le_uint16 glyphCount
;
126 le_uint16 substCount
;
127 Offset coverageTableOffsetArray
[ANY_NUMBER
];
128 //SubstitutionLookupRecord substLookupRecord[ANY_NUMBER];
130 le_uint32
process(const LookupProcessor
*lookupProcessor
, GlyphIterator
*glyphIterator
, const LEFontInstance
*fontInstance
, LEErrorCode
& success
) const;
132 LE_VAR_ARRAY(ContextualSubstitutionFormat3Subtable
, coverageTableOffsetArray
)
134 struct ChainingContextualSubstitutionSubtable
: ContextualSubstitutionBase
136 le_uint32
process(const LookupProcessor
*lookupProcessor
, GlyphIterator
*glyphIterator
, const LEFontInstance
*fontInstance
, LEErrorCode
& success
) const;
139 struct ChainingContextualSubstitutionFormat1Subtable
: ChainingContextualSubstitutionSubtable
141 le_uint16 chainSubRuleSetCount
;
142 Offset chainSubRuleSetTableOffsetArray
[ANY_NUMBER
];
144 le_uint32
process(const LookupProcessor
*lookupProcessor
, GlyphIterator
*glyphIterator
, const LEFontInstance
*fontInstance
, LEErrorCode
& success
) const;
146 LE_VAR_ARRAY(ChainingContextualSubstitutionFormat1Subtable
, chainSubRuleSetTableOffsetArray
)
149 struct ChainSubRuleSetTable
151 le_uint16 chainSubRuleCount
;
152 Offset chainSubRuleTableOffsetArray
[ANY_NUMBER
];
155 LE_VAR_ARRAY(ChainSubRuleSetTable
, chainSubRuleTableOffsetArray
)
157 // NOTE: Multiple variable size arrays!!
158 struct ChainSubRuleTable
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];
169 LE_VAR_ARRAY(ChainSubRuleTable
, backtrackGlyphArray
)
171 struct ChainingContextualSubstitutionFormat2Subtable
: ChainingContextualSubstitutionSubtable
173 Offset backtrackClassDefTableOffset
;
174 Offset inputClassDefTableOffset
;
175 Offset lookaheadClassDefTableOffset
;
176 le_uint16 chainSubClassSetCount
;
177 Offset chainSubClassSetTableOffsetArray
[ANY_NUMBER
];
179 le_uint32
process(const LookupProcessor
*lookupProcessor
, GlyphIterator
*glyphIterator
, const LEFontInstance
*fontInstance
, LEErrorCode
& success
) const;
181 LE_VAR_ARRAY(ChainingContextualSubstitutionFormat2Subtable
, chainSubClassSetTableOffsetArray
)
183 struct ChainSubClassSetTable
185 le_uint16 chainSubClassRuleCount
;
186 Offset chainSubClassRuleTableOffsetArray
[ANY_NUMBER
];
188 LE_VAR_ARRAY(ChainSubClassSetTable
, chainSubClassRuleTableOffsetArray
)
191 // NOTE: Multiple variable size arrays!!
192 struct ChainSubClassRuleTable
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];
203 LE_VAR_ARRAY(ChainSubClassRuleTable
, backtrackClassArray
)
205 // NOTE: This isn't a subclass of GlyphSubstitutionSubtable 'cause
206 // it has arrays of coverage tables instead of a single coverage table...
208 // NOTE: Multiple variable size arrays!!
209 struct ChainingContextualSubstitutionFormat3Subtable
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];
221 le_uint32
process(const LookupProcessor
*lookupProcessor
, GlyphIterator
*glyphIterator
, const LEFontInstance
*fontInstance
, LEErrorCode
& success
) const;
223 LE_VAR_ARRAY(ChainingContextualSubstitutionFormat3Subtable
, backtrackCoverageTableOffsetArray
)