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_GPOS_PRIVATE_H
27 #define HARFBUZZ_GPOS_PRIVATE_H
29 #include "harfbuzz-impl.h"
30 #include "harfbuzz-stream-private.h"
31 #include "harfbuzz-gpos.h"
37 #define VR_X_PLACEMENT_DEVICE 0
38 #define VR_Y_PLACEMENT_DEVICE 1
39 #define VR_X_ADVANCE_DEVICE 2
40 #define VR_Y_ADVANCE_DEVICE 3
42 struct HB_ValueRecord_
44 HB_Short XPlacement; /* horizontal adjustment for
46 HB_Short YPlacement; /* vertical adjustment for
48 HB_Short XAdvance; /* horizontal adjustment for
50 HB_Short YAdvance; /* vertical adjustment for
53 HB_Device** DeviceTables; /* device tables for placement
56 #ifdef HB_SUPPORT_MULTIPLE_MASTER
57 HB_UShort XIdPlacement; /* horizontal placement metric ID */
58 HB_UShort YIdPlacement; /* vertical placement metric ID */
59 HB_UShort XIdAdvance; /* horizontal advance metric ID */
60 HB_UShort YIdAdvance; /* vertical advance metric ID */
64 typedef struct HB_ValueRecord_ HB_ValueRecord;
67 /* Mask values to scan the value format of the ValueRecord structure.
68 We always expand compressed ValueRecords of the font. */
70 #define HB_GPOS_FORMAT_HAVE_DEVICE_TABLES 0x00F0
72 #define HB_GPOS_FORMAT_HAVE_X_PLACEMENT 0x0001
73 #define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT 0x0002
74 #define HB_GPOS_FORMAT_HAVE_X_ADVANCE 0x0004
75 #define HB_GPOS_FORMAT_HAVE_Y_ADVANCE 0x0008
76 #define HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE 0x0010
77 #define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE 0x0020
78 #define HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE 0x0040
79 #define HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE 0x0080
80 #define HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT 0x0100
81 #define HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT 0x0200
82 #define HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE 0x0400
83 #define HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE 0x0800
86 struct HB_AnchorFormat1_
88 HB_Short XCoordinate; /* horizontal value */
89 HB_Short YCoordinate; /* vertical value */
92 typedef struct HB_AnchorFormat1_ HB_AnchorFormat1;
95 struct HB_AnchorFormat2_
97 HB_Short XCoordinate; /* horizontal value */
98 HB_Short YCoordinate; /* vertical value */
99 HB_UShort AnchorPoint; /* index to glyph contour point */
102 typedef struct HB_AnchorFormat2_ HB_AnchorFormat2;
104 #define AF3_X_DEVICE_TABLE 0
105 #define AF3_Y_DEVICE_TABLE 1
107 struct HB_AnchorFormat3_
109 HB_Short XCoordinate; /* horizontal value */
110 HB_Short YCoordinate; /* vertical value */
111 HB_Device** DeviceTables; /* device tables for coordinates */
114 typedef struct HB_AnchorFormat3_ HB_AnchorFormat3;
117 #ifdef HB_SUPPORT_MULTIPLE_MASTER
118 struct HB_AnchorFormat4_
120 HB_UShort XIdAnchor; /* horizontal metric ID */
121 HB_UShort YIdAnchor; /* vertical metric ID */
124 typedef struct HB_AnchorFormat4_ HB_AnchorFormat4;
130 HB_Byte PosFormat; /* 1, 2, 3, or 4 -- 0 indicates
131 that there is no Anchor table */
135 HB_AnchorFormat1 af1;
136 HB_AnchorFormat2 af2;
137 HB_AnchorFormat3 af3;
138 #ifdef HB_SUPPORT_MULTIPLE_MASTER
139 HB_AnchorFormat4 af4;
144 typedef struct HB_Anchor_ HB_Anchor;
147 struct HB_MarkRecord_
149 HB_UShort Class; /* mark class */
150 HB_Anchor MarkAnchor; /* anchor table */
153 typedef struct HB_MarkRecord_ HB_MarkRecord;
158 HB_UShort MarkCount; /* number of MarkRecord tables */
159 HB_MarkRecord* MarkRecord; /* array of MarkRecord tables */
162 typedef struct HB_MarkArray_ HB_MarkArray;
167 struct HB_SinglePosFormat1_
169 HB_ValueRecord Value; /* ValueRecord for all covered
173 typedef struct HB_SinglePosFormat1_ HB_SinglePosFormat1;
176 struct HB_SinglePosFormat2_
178 HB_UShort ValueCount; /* number of ValueRecord tables */
179 HB_ValueRecord* Value; /* array of ValueRecord tables */
182 typedef struct HB_SinglePosFormat2_ HB_SinglePosFormat2;
187 HB_Byte PosFormat; /* 1 or 2 */
188 HB_Coverage Coverage; /* Coverage table */
190 HB_UShort ValueFormat; /* format of ValueRecord table */
194 HB_SinglePosFormat1 spf1;
195 HB_SinglePosFormat2 spf2;
199 typedef struct HB_SinglePos_ HB_SinglePos;
204 struct HB_PairValueRecord_
206 HB_UShort SecondGlyph; /* glyph ID for second glyph */
207 HB_ValueRecord Value1; /* pos. data for first glyph */
208 HB_ValueRecord Value2; /* pos. data for second glyph */
211 typedef struct HB_PairValueRecord_ HB_PairValueRecord;
216 HB_UShort PairValueCount;
217 /* number of PairValueRecord tables */
218 HB_PairValueRecord* PairValueRecord;
219 /* array of PairValueRecord tables */
222 typedef struct HB_PairSet_ HB_PairSet;
225 struct HB_PairPosFormat1_
227 HB_UShort PairSetCount; /* number of PairSet tables */
228 HB_PairSet* PairSet; /* array of PairSet tables */
231 typedef struct HB_PairPosFormat1_ HB_PairPosFormat1;
234 struct HB_Class2Record_
236 HB_ValueRecord Value1; /* pos. data for first glyph */
237 HB_ValueRecord Value2; /* pos. data for second glyph */
240 typedef struct HB_Class2Record_ HB_Class2Record;
243 struct HB_Class1Record_
245 HB_Class2Record* Class2Record; /* array of Class2Record tables */
248 typedef struct HB_Class1Record_ HB_Class1Record;
251 struct HB_PairPosFormat2_
253 HB_ClassDefinition ClassDef1; /* class def. for first glyph */
254 HB_ClassDefinition ClassDef2; /* class def. for second glyph */
255 HB_UShort Class1Count; /* number of classes in ClassDef1
257 HB_UShort Class2Count; /* number of classes in ClassDef2
259 HB_Class1Record* Class1Record; /* array of Class1Record tables */
262 typedef struct HB_PairPosFormat2_ HB_PairPosFormat2;
267 HB_Byte PosFormat; /* 1 or 2 */
268 HB_Coverage Coverage; /* Coverage table */
269 HB_UShort ValueFormat1; /* format of ValueRecord table
271 HB_UShort ValueFormat2; /* format of ValueRecord table
276 HB_PairPosFormat1 ppf1;
277 HB_PairPosFormat2 ppf2;
281 typedef struct HB_PairPos_ HB_PairPos;
286 struct HB_EntryExitRecord_
288 HB_Anchor EntryAnchor; /* entry Anchor table */
289 HB_Anchor ExitAnchor; /* exit Anchor table */
293 typedef struct HB_EntryExitRecord_ HB_EntryExitRecord;
295 struct HB_CursivePos_
297 HB_UShort PosFormat; /* always 1 */
298 HB_Coverage Coverage; /* Coverage table */
299 HB_UShort EntryExitCount;
300 /* number of EntryExitRecord tables */
301 HB_EntryExitRecord* EntryExitRecord;
302 /* array of EntryExitRecord tables */
305 typedef struct HB_CursivePos_ HB_CursivePos;
310 struct HB_BaseRecord_
312 HB_Anchor* BaseAnchor; /* array of base glyph anchor
316 typedef struct HB_BaseRecord_ HB_BaseRecord;
321 HB_UShort BaseCount; /* number of BaseRecord tables */
322 HB_BaseRecord* BaseRecord; /* array of BaseRecord tables */
325 typedef struct HB_BaseArray_ HB_BaseArray;
328 struct HB_MarkBasePos_
330 HB_UShort PosFormat; /* always 1 */
331 HB_Coverage MarkCoverage; /* mark glyph coverage table */
332 HB_Coverage BaseCoverage; /* base glyph coverage table */
333 HB_UShort ClassCount; /* number of mark classes */
334 HB_MarkArray MarkArray; /* mark array table */
335 HB_BaseArray BaseArray; /* base array table */
338 typedef struct HB_MarkBasePos_ HB_MarkBasePos;
343 struct HB_ComponentRecord_
345 HB_Anchor* LigatureAnchor; /* array of ligature glyph anchor
349 typedef struct HB_ComponentRecord_ HB_ComponentRecord;
352 struct HB_LigatureAttach_
354 HB_UShort ComponentCount;
355 /* number of ComponentRecord tables */
356 HB_ComponentRecord* ComponentRecord;
357 /* array of ComponentRecord tables */
360 typedef struct HB_LigatureAttach_ HB_LigatureAttach;
363 struct HB_LigatureArray_
365 HB_UShort LigatureCount; /* number of LigatureAttach tables */
366 HB_LigatureAttach* LigatureAttach;
367 /* array of LigatureAttach tables */
370 typedef struct HB_LigatureArray_ HB_LigatureArray;
373 struct HB_MarkLigPos_
375 HB_UShort PosFormat; /* always 1 */
376 HB_Coverage MarkCoverage; /* mark glyph coverage table */
377 HB_Coverage LigatureCoverage;
378 /* ligature glyph coverage table */
379 HB_UShort ClassCount; /* number of mark classes */
380 HB_MarkArray MarkArray; /* mark array table */
381 HB_LigatureArray LigatureArray; /* ligature array table */
384 typedef struct HB_MarkLigPos_ HB_MarkLigPos;
389 struct HB_Mark2Record_
391 HB_Anchor* Mark2Anchor; /* array of mark glyph anchor
395 typedef struct HB_Mark2Record_ HB_Mark2Record;
398 struct HB_Mark2Array_
400 HB_UShort Mark2Count; /* number of Mark2Record tables */
401 HB_Mark2Record* Mark2Record; /* array of Mark2Record tables */
404 typedef struct HB_Mark2Array_ HB_Mark2Array;
407 struct HB_MarkMarkPos_
409 HB_UShort PosFormat; /* always 1 */
410 HB_Coverage Mark1Coverage; /* first mark glyph coverage table */
411 HB_Coverage Mark2Coverage; /* second mark glyph coverave table */
412 HB_UShort ClassCount; /* number of combining mark classes */
413 HB_MarkArray Mark1Array; /* MarkArray table for first mark */
414 HB_Mark2Array Mark2Array; /* MarkArray table for second mark */
417 typedef struct HB_MarkMarkPos_ HB_MarkMarkPos;
420 /* needed by both lookup type 7 and 8 */
422 struct HB_PosLookupRecord_
424 HB_UShort SequenceIndex; /* index into current
426 HB_UShort LookupListIndex; /* Lookup to apply to that pos. */
429 typedef struct HB_PosLookupRecord_ HB_PosLookupRecord;
436 HB_UShort GlyphCount; /* total number of input glyphs */
437 HB_UShort PosCount; /* number of PosLookupRecord tables */
438 HB_UShort* Input; /* array of input glyph IDs */
439 HB_PosLookupRecord* PosLookupRecord;
440 /* array of PosLookupRecord tables */
443 typedef struct HB_PosRule_ HB_PosRule;
446 struct HB_PosRuleSet_
448 HB_UShort PosRuleCount; /* number of PosRule tables */
449 HB_PosRule* PosRule; /* array of PosRule tables */
452 typedef struct HB_PosRuleSet_ HB_PosRuleSet;
455 struct HB_ContextPosFormat1_
457 HB_Coverage Coverage; /* Coverage table */
458 HB_UShort PosRuleSetCount; /* number of PosRuleSet tables */
459 HB_PosRuleSet* PosRuleSet; /* array of PosRuleSet tables */
462 typedef struct HB_ContextPosFormat1_ HB_ContextPosFormat1;
465 struct HB_PosClassRule_
467 HB_UShort GlyphCount; /* total number of context classes */
468 HB_UShort PosCount; /* number of PosLookupRecord tables */
469 HB_UShort* Class; /* array of classes */
470 HB_PosLookupRecord* PosLookupRecord;
471 /* array of PosLookupRecord tables */
474 typedef struct HB_PosClassRule_ HB_PosClassRule;
477 struct HB_PosClassSet_
479 HB_UShort PosClassRuleCount;
480 /* number of PosClassRule tables */
481 HB_PosClassRule* PosClassRule; /* array of PosClassRule tables */
484 typedef struct HB_PosClassSet_ HB_PosClassSet;
487 /* The `MaxContextLength' field is not defined in the TTO specification
488 but simplifies the implementation of this format. It holds the
489 maximal context length used in the context rules. */
491 struct HB_ContextPosFormat2_
493 HB_UShort MaxContextLength;
494 /* maximal context length */
495 HB_Coverage Coverage; /* Coverage table */
496 HB_ClassDefinition ClassDef; /* ClassDef table */
497 HB_UShort PosClassSetCount;
498 /* number of PosClassSet tables */
499 HB_PosClassSet* PosClassSet; /* array of PosClassSet tables */
502 typedef struct HB_ContextPosFormat2_ HB_ContextPosFormat2;
505 struct HB_ContextPosFormat3_
507 HB_UShort GlyphCount; /* number of input glyphs */
508 HB_UShort PosCount; /* number of PosLookupRecord tables */
509 HB_Coverage* Coverage; /* array of Coverage tables */
510 HB_PosLookupRecord* PosLookupRecord;
511 /* array of PosLookupRecord tables */
514 typedef struct HB_ContextPosFormat3_ HB_ContextPosFormat3;
517 struct HB_ContextPos_
519 HB_Byte PosFormat; /* 1, 2, or 3 */
523 HB_ContextPosFormat1 cpf1;
524 HB_ContextPosFormat2 cpf2;
525 HB_ContextPosFormat3 cpf3;
529 typedef struct HB_ContextPos_ HB_ContextPos;
534 struct HB_ChainPosRule_
536 HB_UShort* Backtrack; /* array of backtrack glyph IDs */
537 HB_UShort* Input; /* array of input glyph IDs */
538 HB_UShort* Lookahead; /* array of lookahead glyph IDs */
539 HB_PosLookupRecord* PosLookupRecord;
540 /* array of PosLookupRecords */
541 HB_UShort BacktrackGlyphCount;
542 /* total number of backtrack glyphs */
543 HB_UShort InputGlyphCount;
544 /* total number of input glyphs */
545 HB_UShort LookaheadGlyphCount;
546 /* total number of lookahead glyphs */
547 HB_UShort PosCount; /* number of PosLookupRecords */
550 typedef struct HB_ChainPosRule_ HB_ChainPosRule;
553 struct HB_ChainPosRuleSet_
555 HB_UShort ChainPosRuleCount;
556 /* number of ChainPosRule tables */
557 HB_ChainPosRule* ChainPosRule; /* array of ChainPosRule tables */
560 typedef struct HB_ChainPosRuleSet_ HB_ChainPosRuleSet;
563 struct HB_ChainContextPosFormat1_
565 HB_Coverage Coverage; /* Coverage table */
566 HB_UShort ChainPosRuleSetCount;
567 /* number of ChainPosRuleSet tables */
568 HB_ChainPosRuleSet* ChainPosRuleSet;
569 /* array of ChainPosRuleSet tables */
572 typedef struct HB_ChainContextPosFormat1_ HB_ChainContextPosFormat1;
575 struct HB_ChainPosClassRule_
577 HB_UShort* Backtrack; /* array of backtrack classes */
578 HB_UShort* Input; /* array of context classes */
579 HB_UShort* Lookahead; /* array of lookahead classes */
580 HB_PosLookupRecord* PosLookupRecord;
581 /* array of substitution lookups */
582 HB_UShort BacktrackGlyphCount;
583 /* total number of backtrack
585 HB_UShort InputGlyphCount;
586 /* total number of context classes */
587 HB_UShort LookaheadGlyphCount;
588 /* total number of lookahead
590 HB_UShort PosCount; /* number of PosLookupRecords */
593 typedef struct HB_ChainPosClassRule_ HB_ChainPosClassRule;
596 struct HB_ChainPosClassSet_
598 HB_UShort ChainPosClassRuleCount;
599 /* number of ChainPosClassRule
601 HB_ChainPosClassRule* ChainPosClassRule;
602 /* array of ChainPosClassRule
606 typedef struct HB_ChainPosClassSet_ HB_ChainPosClassSet;
609 /* The `MaxXXXLength' fields are not defined in the TTO specification
610 but simplifies the implementation of this format. It holds the
611 maximal context length used in the specific context rules. */
613 struct HB_ChainContextPosFormat2_
615 HB_Coverage Coverage; /* Coverage table */
617 HB_UShort MaxBacktrackLength;
618 /* maximal backtrack length */
619 HB_ClassDefinition BacktrackClassDef;
620 /* BacktrackClassDef table */
621 HB_UShort MaxInputLength;
622 /* maximal input length */
623 HB_ClassDefinition InputClassDef;
624 /* InputClassDef table */
625 HB_UShort MaxLookaheadLength;
626 /* maximal lookahead length */
627 HB_ClassDefinition LookaheadClassDef;
628 /* LookaheadClassDef table */
630 HB_UShort ChainPosClassSetCount;
631 /* number of ChainPosClassSet
633 HB_ChainPosClassSet* ChainPosClassSet;
634 /* array of ChainPosClassSet
638 typedef struct HB_ChainContextPosFormat2_ HB_ChainContextPosFormat2;
641 struct HB_ChainContextPosFormat3_
643 HB_UShort BacktrackGlyphCount;
644 /* number of backtrack glyphs */
645 HB_Coverage* BacktrackCoverage;
646 /* array of backtrack Coverage
648 HB_UShort InputGlyphCount;
649 /* number of input glyphs */
650 HB_Coverage* InputCoverage;
651 /* array of input coverage
653 HB_UShort LookaheadGlyphCount;
654 /* number of lookahead glyphs */
655 HB_Coverage* LookaheadCoverage;
656 /* array of lookahead coverage
658 HB_UShort PosCount; /* number of PosLookupRecords */
659 HB_PosLookupRecord* PosLookupRecord;
660 /* array of substitution lookups */
663 typedef struct HB_ChainContextPosFormat3_ HB_ChainContextPosFormat3;
666 struct HB_ChainContextPos_
668 HB_Byte PosFormat; /* 1, 2, or 3 */
672 HB_ChainContextPosFormat1 ccpf1;
673 HB_ChainContextPosFormat2 ccpf2;
674 HB_ChainContextPosFormat3 ccpf3;
678 typedef struct HB_ChainContextPos_ HB_ChainContextPos;
683 struct HB_ExtensionPos_
685 HB_UShort PosFormat; /* always 1 */
686 HB_UShort LookuptType; /* lookup-type of referenced subtable */
687 HB_GPOS_SubTable *subtable; /* referenced subtable */
690 typedef struct HB_ExtensionPos_ HB_ExtensionPos;
694 union HB_GPOS_SubTable_
698 HB_CursivePos cursive;
699 HB_MarkBasePos markbase;
700 HB_MarkLigPos marklig;
701 HB_MarkMarkPos markmark;
702 HB_ContextPos context;
703 HB_ChainContextPos chain;
706 typedef union HB_GPOS_SubTable_ HB_GPOS_SubTable;
711 _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
713 HB_UShort lookup_type );
716 _HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,
717 HB_UShort lookup_type );
721 #endif /* HARFBUZZ_GPOS_PRIVATE_H */