2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg
3 * Copyright (C) 2006 Behdad Esfahbod
5 * This is part of HarfBuzz, an OpenType Layout engine library.
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
26 #ifndef HARFBUZZ_GSUB_PRIVATE_H
27 #define HARFBUZZ_GSUB_PRIVATE_H
29 #include "harfbuzz-impl.h"
30 #include "harfbuzz-stream-private.h"
31 #include "harfbuzz-gsub.h"
36 typedef union HB_GSUB_SubTable_ HB_GSUB_SubTable;
40 struct HB_SingleSubstFormat1_
42 HB_Short DeltaGlyphID; /* constant added to get
43 substitution glyph index */
46 typedef struct HB_SingleSubstFormat1_ HB_SingleSubstFormat1;
49 struct HB_SingleSubstFormat2_
51 HB_UShort GlyphCount; /* number of glyph IDs in
53 HB_UShort* Substitute; /* array of substitute glyph IDs */
56 typedef struct HB_SingleSubstFormat2_ HB_SingleSubstFormat2;
59 struct HB_SingleSubst_
61 HB_UShort SubstFormat; /* 1 or 2 */
62 HB_Coverage Coverage; /* Coverage table */
66 HB_SingleSubstFormat1 ssf1;
67 HB_SingleSubstFormat2 ssf2;
71 typedef struct HB_SingleSubst_ HB_SingleSubst;
78 HB_UShort GlyphCount; /* number of glyph IDs in the
80 HB_UShort* Substitute; /* string of glyph IDs to
84 typedef struct HB_Sequence_ HB_Sequence;
87 struct HB_MultipleSubst_
89 HB_UShort SubstFormat; /* always 1 */
90 HB_Coverage Coverage; /* Coverage table */
91 HB_UShort SequenceCount; /* number of Sequence tables */
92 HB_Sequence* Sequence; /* array of Sequence tables */
95 typedef struct HB_MultipleSubst_ HB_MultipleSubst;
100 struct HB_AlternateSet_
102 HB_UShort GlyphCount; /* number of glyph IDs in the
104 HB_UShort* Alternate; /* array of alternate glyph IDs */
107 typedef struct HB_AlternateSet_ HB_AlternateSet;
110 struct HB_AlternateSubst_
112 HB_UShort SubstFormat; /* always 1 */
113 HB_Coverage Coverage; /* Coverage table */
114 HB_UShort AlternateSetCount;
115 /* number of AlternateSet tables */
116 HB_AlternateSet* AlternateSet; /* array of AlternateSet tables */
119 typedef struct HB_AlternateSubst_ HB_AlternateSubst;
126 HB_UShort LigGlyph; /* glyphID of ligature
128 HB_UShort ComponentCount; /* number of components in ligature */
129 HB_UShort* Component; /* array of component glyph IDs */
132 typedef struct HB_Ligature_ HB_Ligature;
135 struct HB_LigatureSet_
137 HB_UShort LigatureCount; /* number of Ligature tables */
138 HB_Ligature* Ligature; /* array of Ligature tables */
141 typedef struct HB_LigatureSet_ HB_LigatureSet;
144 struct HB_LigatureSubst_
146 HB_UShort SubstFormat; /* always 1 */
147 HB_Coverage Coverage; /* Coverage table */
148 HB_UShort LigatureSetCount; /* number of LigatureSet tables */
149 HB_LigatureSet* LigatureSet; /* array of LigatureSet tables */
152 typedef struct HB_LigatureSubst_ HB_LigatureSubst;
155 /* needed by both lookup type 5 and 6 */
157 struct HB_SubstLookupRecord_
159 HB_UShort SequenceIndex; /* index into current
161 HB_UShort LookupListIndex; /* Lookup to apply to that pos. */
164 typedef struct HB_SubstLookupRecord_ HB_SubstLookupRecord;
171 HB_UShort GlyphCount; /* total number of input glyphs */
172 HB_UShort SubstCount; /* number of SubstLookupRecord
174 HB_UShort* Input; /* array of input glyph IDs */
175 HB_SubstLookupRecord* SubstLookupRecord;
176 /* array of SubstLookupRecord
180 typedef struct HB_SubRule_ HB_SubRule;
183 struct HB_SubRuleSet_
185 HB_UShort SubRuleCount; /* number of SubRule tables */
186 HB_SubRule* SubRule; /* array of SubRule tables */
189 typedef struct HB_SubRuleSet_ HB_SubRuleSet;
192 struct HB_ContextSubstFormat1_
194 HB_Coverage Coverage; /* Coverage table */
195 HB_UShort SubRuleSetCount; /* number of SubRuleSet tables */
196 HB_SubRuleSet* SubRuleSet; /* array of SubRuleSet tables */
199 typedef struct HB_ContextSubstFormat1_ HB_ContextSubstFormat1;
202 struct HB_SubClassRule_
204 HB_UShort GlyphCount; /* total number of context classes */
205 HB_UShort SubstCount; /* number of SubstLookupRecord
207 HB_UShort* Class; /* array of classes */
208 HB_SubstLookupRecord* SubstLookupRecord;
209 /* array of SubstLookupRecord
213 typedef struct HB_SubClassRule_ HB_SubClassRule;
216 struct HB_SubClassSet_
218 HB_UShort SubClassRuleCount;
219 /* number of SubClassRule tables */
220 HB_SubClassRule* SubClassRule; /* array of SubClassRule tables */
223 typedef struct HB_SubClassSet_ HB_SubClassSet;
226 /* The `MaxContextLength' field is not defined in the TTO specification
227 but simplifies the implementation of this format. It holds the
228 maximal context length used in the context rules. */
230 struct HB_ContextSubstFormat2_
232 HB_UShort MaxContextLength;
233 /* maximal context length */
234 HB_Coverage Coverage; /* Coverage table */
235 HB_ClassDefinition ClassDef; /* ClassDef table */
236 HB_UShort SubClassSetCount;
237 /* number of SubClassSet tables */
238 HB_SubClassSet* SubClassSet; /* array of SubClassSet tables */
241 typedef struct HB_ContextSubstFormat2_ HB_ContextSubstFormat2;
244 struct HB_ContextSubstFormat3_
246 HB_UShort GlyphCount; /* number of input glyphs */
247 HB_UShort SubstCount; /* number of SubstLookupRecords */
248 HB_Coverage* Coverage; /* array of Coverage tables */
249 HB_SubstLookupRecord* SubstLookupRecord;
250 /* array of substitution lookups */
253 typedef struct HB_ContextSubstFormat3_ HB_ContextSubstFormat3;
256 struct HB_ContextSubst_
258 HB_UShort SubstFormat; /* 1, 2, or 3 */
262 HB_ContextSubstFormat1 csf1;
263 HB_ContextSubstFormat2 csf2;
264 HB_ContextSubstFormat3 csf3;
268 typedef struct HB_ContextSubst_ HB_ContextSubst;
273 struct HB_ChainSubRule_
275 HB_UShort BacktrackGlyphCount;
276 /* total number of backtrack glyphs */
277 HB_UShort* Backtrack; /* array of backtrack glyph IDs */
278 HB_UShort InputGlyphCount;
279 /* total number of input glyphs */
280 HB_UShort* Input; /* array of input glyph IDs */
281 HB_UShort LookaheadGlyphCount;
282 /* total number of lookahead glyphs */
283 HB_UShort* Lookahead; /* array of lookahead glyph IDs */
284 HB_UShort SubstCount; /* number of SubstLookupRecords */
285 HB_SubstLookupRecord* SubstLookupRecord;
286 /* array of SubstLookupRecords */
289 typedef struct HB_ChainSubRule_ HB_ChainSubRule;
292 struct HB_ChainSubRuleSet_
294 HB_UShort ChainSubRuleCount;
295 /* number of ChainSubRule tables */
296 HB_ChainSubRule* ChainSubRule; /* array of ChainSubRule tables */
299 typedef struct HB_ChainSubRuleSet_ HB_ChainSubRuleSet;
302 struct HB_ChainContextSubstFormat1_
304 HB_Coverage Coverage; /* Coverage table */
305 HB_UShort ChainSubRuleSetCount;
306 /* number of ChainSubRuleSet tables */
307 HB_ChainSubRuleSet* ChainSubRuleSet;
308 /* array of ChainSubRuleSet tables */
311 typedef struct HB_ChainContextSubstFormat1_ HB_ChainContextSubstFormat1;
314 struct HB_ChainSubClassRule_
316 HB_UShort BacktrackGlyphCount;
317 /* total number of backtrack
319 HB_UShort* Backtrack; /* array of backtrack classes */
320 HB_UShort InputGlyphCount;
321 /* total number of context classes */
322 HB_UShort* Input; /* array of context classes */
323 HB_UShort LookaheadGlyphCount;
324 /* total number of lookahead
326 HB_UShort* Lookahead; /* array of lookahead classes */
327 HB_UShort SubstCount; /* number of SubstLookupRecords */
328 HB_SubstLookupRecord* SubstLookupRecord;
329 /* array of substitution lookups */
332 typedef struct HB_ChainSubClassRule_ HB_ChainSubClassRule;
335 struct HB_ChainSubClassSet_
337 HB_UShort ChainSubClassRuleCount;
338 /* number of ChainSubClassRule
340 HB_ChainSubClassRule* ChainSubClassRule;
341 /* array of ChainSubClassRule
345 typedef struct HB_ChainSubClassSet_ HB_ChainSubClassSet;
348 /* The `MaxXXXLength' fields are not defined in the TTO specification
349 but simplifies the implementation of this format. It holds the
350 maximal context length used in the specific context rules. */
352 struct HB_ChainContextSubstFormat2_
354 HB_Coverage Coverage; /* Coverage table */
356 HB_UShort MaxBacktrackLength;
357 /* maximal backtrack length */
358 HB_ClassDefinition BacktrackClassDef;
359 /* BacktrackClassDef table */
360 HB_UShort MaxInputLength;
361 /* maximal input length */
362 HB_ClassDefinition InputClassDef;
363 /* InputClassDef table */
364 HB_UShort MaxLookaheadLength;
365 /* maximal lookahead length */
366 HB_ClassDefinition LookaheadClassDef;
367 /* LookaheadClassDef table */
369 HB_UShort ChainSubClassSetCount;
370 /* number of ChainSubClassSet
372 HB_ChainSubClassSet* ChainSubClassSet;
373 /* array of ChainSubClassSet
377 typedef struct HB_ChainContextSubstFormat2_ HB_ChainContextSubstFormat2;
380 struct HB_ChainContextSubstFormat3_
382 HB_UShort BacktrackGlyphCount;
383 /* number of backtrack glyphs */
384 HB_Coverage* BacktrackCoverage;
385 /* array of backtrack Coverage
387 HB_UShort InputGlyphCount;
388 /* number of input glyphs */
389 HB_Coverage* InputCoverage;
390 /* array of input coverage
392 HB_UShort LookaheadGlyphCount;
393 /* number of lookahead glyphs */
394 HB_Coverage* LookaheadCoverage;
395 /* array of lookahead coverage
397 HB_UShort SubstCount; /* number of SubstLookupRecords */
398 HB_SubstLookupRecord* SubstLookupRecord;
399 /* array of substitution lookups */
402 typedef struct HB_ChainContextSubstFormat3_ HB_ChainContextSubstFormat3;
405 struct HB_ChainContextSubst_
407 HB_UShort SubstFormat; /* 1, 2, or 3 */
411 HB_ChainContextSubstFormat1 ccsf1;
412 HB_ChainContextSubstFormat2 ccsf2;
413 HB_ChainContextSubstFormat3 ccsf3;
417 typedef struct HB_ChainContextSubst_ HB_ChainContextSubst;
422 struct HB_ExtensionSubst_
424 HB_UShort SubstFormat; /* always 1 */
425 HB_UShort LookuptType; /* lookup-type of referenced subtable */
426 HB_GSUB_SubTable *subtable; /* referenced subtable */
429 typedef struct HB_ExtensionSubst_ HB_ExtensionSubst;
434 struct HB_ReverseChainContextSubst_
436 HB_UShort SubstFormat; /* always 1 */
437 HB_Coverage Coverage; /* coverage table for input glyphs */
438 HB_UShort BacktrackGlyphCount; /* number of backtrack glyphs */
439 HB_Coverage* BacktrackCoverage; /* array of backtrack Coverage
441 HB_UShort LookaheadGlyphCount; /* number of lookahead glyphs */
442 HB_Coverage* LookaheadCoverage; /* array of lookahead Coverage
444 HB_UShort GlyphCount; /* number of Glyph IDs */
445 HB_UShort* Substitute; /* array of substitute Glyph ID */
448 typedef struct HB_ReverseChainContextSubst_ HB_ReverseChainContextSubst;
451 union HB_GSUB_SubTable_
453 HB_SingleSubst single;
454 HB_MultipleSubst multiple;
455 HB_AlternateSubst alternate;
456 HB_LigatureSubst ligature;
457 HB_ContextSubst context;
458 HB_ChainContextSubst chain;
459 HB_ReverseChainContextSubst reverse;
466 _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
468 HB_UShort lookup_type );
471 _HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
472 HB_UShort lookup_type );
476 #endif /* HARFBUZZ_GSUB_PRIVATE_H */