1 /*******************************************************************
2  *
3  *  ftxgpos.h
4  *
5  *    TrueType Open GPOS table support
6  *
7  *  Copyright 1996-2000 by
8  *  David Turner, Robert Wilhelm, and Werner Lemberg.
9  *
10  *  This file is part of the FreeType project, and may only be used
11  *  modified and distributed under the terms of the FreeType project
12  *  license, LICENSE.TXT.  By continuing to use, modify, or distribute
13  *  this file you indicate that you have read the license and
14  *  understand and accept it fully.
15  *
16  ******************************************************************/
17 
18 #ifndef FTXOPEN_H
19 #error "Don't include this file! Use ftxopen.h instead."
20 #endif
21 
22 #ifndef FTXGPOS_H
23 #define FTXGPOS_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #define TTO_Err_Invalid_GPOS_SubTable_Format  0x1020
30 #define TTO_Err_Invalid_GPOS_SubTable         0x1021
31 
32 
33 /* Lookup types for glyph positioning */
34 
35 #define GPOS_LOOKUP_SINGLE     1
36 #define GPOS_LOOKUP_PAIR       2
37 #define GPOS_LOOKUP_CURSIVE    3
38 #define GPOS_LOOKUP_MARKBASE   4
39 #define GPOS_LOOKUP_MARKLIG    5
40 #define GPOS_LOOKUP_MARKMARK   6
41 #define GPOS_LOOKUP_CONTEXT    7
42 #define GPOS_LOOKUP_CHAIN      8
43 #define GPOS_LOOKUP_EXTENSION  9
44 
45 
46   /* A pointer to a function which loads a glyph.  Its parameters are
47      the same as in a call to TT_Load_Glyph() -- if no glyph loading
48      function will be registered with TTO_GPOS_Register_Glyph_Function(),
49      TT_Load_Glyph() will be called indeed.  The purpose of this function
50      pointer is to provide a hook for caching glyph outlines and sbits
51      (using the instance's generic pointer to hold the data).
52 
53      If for some reason no outline data is available (e.g. for an
54      embedded bitmap glyph), _glyph->outline.n_points should be set to
55      zero.  _glyph can be computed with
56 
57         _glyph = HANDLE_Glyph( glyph )                                    */
58 
59   typedef FT_Error  (*TTO_GlyphFunction)(FT_Face      face,
60 					 FT_UInt      glyphIndex,
61 					 FT_Int       loadFlags );
62 
63 
64   /* A pointer to a function which accesses the PostScript interpreter.
65      Multiple Master fonts need this interface to convert a metric ID
66      (as stored in an OpenType font version 1.2 or higher) `metric_id'
67      into a metric value (returned in `metric_value').
68 
69      `data' points to the user-defined structure specified during a
70      call to TT_GPOS_Register_MM_Function().
71 
72      `metric_value' must be returned as a scaled value (but shouldn't
73      be rounded).                                                       */
74 
75   typedef FT_Error  (*TTO_MMFunction)(FT_Face      face,
76 				      FT_UShort    metric_id,
77                                       FT_Pos*      metric_value,
78                                       void*        data );
79 
80 
81   struct  TTO_GPOSHeader_
82   {
83     FT_Memory          memory;
84 
85     FT_Fixed           Version;
86 
87     TTO_ScriptList     ScriptList;
88     TTO_FeatureList    FeatureList;
89     TTO_LookupList     LookupList;
90 
91     TTO_GDEFHeader*    gdef;
92 
93     /* the next field is used for a callback function to get the
94        glyph outline.                                            */
95 
96     TTO_GlyphFunction  gfunc;
97 
98     /* this is OpenType 1.2 -- Multiple Master fonts need this
99        callback function to get various metric values from the
100        PostScript interpreter.                                 */
101 
102     TTO_MMFunction     mmfunc;
103     void*              data;
104   };
105 
106   typedef struct TTO_GPOSHeader_  TTO_GPOSHeader;
107   typedef struct TTO_GPOSHeader_* TTO_GPOS;
108 
109 
110   /* shared tables */
111 
112   struct  TTO_ValueRecord_
113   {
114     FT_Short    XPlacement;             /* horizontal adjustment for
115                                            placement                      */
116     FT_Short    YPlacement;             /* vertical adjustment for
117                                            placement                      */
118     FT_Short    XAdvance;               /* horizontal adjustment for
119                                            advance                        */
120     FT_Short    YAdvance;               /* vertical adjustment for
121                                            advance                        */
122     TTO_Device  XPlacementDevice;       /* device table for horizontal
123                                            placement                      */
124     TTO_Device  YPlacementDevice;       /* device table for vertical
125                                            placement                      */
126     TTO_Device  XAdvanceDevice;         /* device table for horizontal
127                                            advance                        */
128     TTO_Device  YAdvanceDevice;         /* device table for vertical
129                                            advance                        */
130     FT_UShort   XIdPlacement;           /* horizontal placement metric ID */
131     FT_UShort   YIdPlacement;           /* vertical placement metric ID   */
132     FT_UShort   XIdAdvance;             /* horizontal advance metric ID   */
133     FT_UShort   YIdAdvance;             /* vertical advance metric ID     */
134   };
135 
136   typedef struct TTO_ValueRecord_  TTO_ValueRecord;
137 
138 
139 /* Mask values to scan the value format of the ValueRecord structure.
140    We always expand compressed ValueRecords of the font.              */
141 
142 #define HAVE_X_PLACEMENT         0x0001
143 #define HAVE_Y_PLACEMENT         0x0002
144 #define HAVE_X_ADVANCE           0x0004
145 #define HAVE_Y_ADVANCE           0x0008
146 #define HAVE_X_PLACEMENT_DEVICE  0x0010
147 #define HAVE_Y_PLACEMENT_DEVICE  0x0020
148 #define HAVE_X_ADVANCE_DEVICE    0x0040
149 #define HAVE_Y_ADVANCE_DEVICE    0x0080
150 #define HAVE_X_ID_PLACEMENT      0x0100
151 #define HAVE_Y_ID_PLACEMENT      0x0200
152 #define HAVE_X_ID_ADVANCE        0x0400
153 #define HAVE_Y_ID_ADVANCE        0x0800
154 
155 
156   struct  TTO_AnchorFormat1_
157   {
158     FT_Short   XCoordinate;             /* horizontal value */
159     FT_Short   YCoordinate;             /* vertical value   */
160   };
161 
162   typedef struct TTO_AnchorFormat1_  TTO_AnchorFormat1;
163 
164 
165   struct  TTO_AnchorFormat2_
166   {
167     FT_Short   XCoordinate;             /* horizontal value             */
168     FT_Short   YCoordinate;             /* vertical value               */
169     FT_UShort  AnchorPoint;             /* index to glyph contour point */
170   };
171 
172   typedef struct TTO_AnchorFormat2_  TTO_AnchorFormat2;
173 
174 
175   struct  TTO_AnchorFormat3_
176   {
177     FT_Short    XCoordinate;            /* horizontal value              */
178     FT_Short    YCoordinate;            /* vertical value                */
179     TTO_Device  XDeviceTable;           /* device table for X coordinate */
180     TTO_Device  YDeviceTable;           /* device table for Y coordinate */
181   };
182 
183   typedef struct TTO_AnchorFormat3_  TTO_AnchorFormat3;
184 
185 
186   struct  TTO_AnchorFormat4_
187   {
188     FT_UShort  XIdAnchor;               /* horizontal metric ID */
189     FT_UShort  YIdAnchor;               /* vertical metric ID   */
190   };
191 
192   typedef struct TTO_AnchorFormat4_  TTO_AnchorFormat4;
193 
194 
195   struct  TTO_Anchor_
196   {
197     FT_UShort  PosFormat;               /* 1, 2, 3, or 4 -- 0 indicates
198                                            that there is no Anchor table */
199 
200     union
201     {
202       TTO_AnchorFormat1  af1;
203       TTO_AnchorFormat2  af2;
204       TTO_AnchorFormat3  af3;
205       TTO_AnchorFormat4  af4;
206     } af;
207   };
208 
209   typedef struct TTO_Anchor_  TTO_Anchor;
210 
211 
212   struct  TTO_MarkRecord_
213   {
214     FT_UShort   Class;                  /* mark class   */
215     TTO_Anchor  MarkAnchor;             /* anchor table */
216   };
217 
218   typedef struct TTO_MarkRecord_  TTO_MarkRecord;
219 
220 
221   struct  TTO_MarkArray_
222   {
223     FT_UShort        MarkCount;         /* number of MarkRecord tables */
224     TTO_MarkRecord*  MarkRecord;        /* array of MarkRecord tables  */
225   };
226 
227   typedef struct TTO_MarkArray_  TTO_MarkArray;
228 
229 
230   /* LookupType 1 */
231 
232   struct  TTO_SinglePosFormat1_
233   {
234     TTO_ValueRecord  Value;             /* ValueRecord for all covered
235                                            glyphs                      */
236   };
237 
238   typedef struct TTO_SinglePosFormat1_  TTO_SinglePosFormat1;
239 
240 
241   struct  TTO_SinglePosFormat2_
242   {
243     FT_UShort         ValueCount;       /* number of ValueRecord tables */
244     TTO_ValueRecord*  Value;            /* array of ValueRecord tables  */
245   };
246 
247   typedef struct TTO_SinglePosFormat2_  TTO_SinglePosFormat2;
248 
249 
250   struct  TTO_SinglePos_
251   {
252     FT_UShort     PosFormat;            /* 1 or 2         */
253     TTO_Coverage  Coverage;             /* Coverage table */
254 
255     FT_UShort     ValueFormat;          /* format of ValueRecord table */
256 
257     union
258     {
259       TTO_SinglePosFormat1  spf1;
260       TTO_SinglePosFormat2  spf2;
261     } spf;
262   };
263 
264   typedef struct TTO_SinglePos_  TTO_SinglePos;
265 
266 
267   /* LookupType 2 */
268 
269   struct  TTO_PairValueRecord_
270   {
271     FT_UShort        SecondGlyph;       /* glyph ID for second glyph  */
272     TTO_ValueRecord  Value1;            /* pos. data for first glyph  */
273     TTO_ValueRecord  Value2;            /* pos. data for second glyph */
274   };
275 
276   typedef struct TTO_PairValueRecord_  TTO_PairValueRecord;
277 
278 
279   struct  TTO_PairSet_
280   {
281     FT_UShort             PairValueCount;
282                                         /* number of PairValueRecord tables */
283     TTO_PairValueRecord*  PairValueRecord;
284                                         /* array of PairValueRecord tables  */
285   };
286 
287   typedef struct TTO_PairSet_  TTO_PairSet;
288 
289 
290   struct  TTO_PairPosFormat1_
291   {
292     FT_UShort     PairSetCount;         /* number of PairSet tables    */
293     TTO_PairSet*  PairSet;              /* array of PairSet tables     */
294   };
295 
296   typedef struct TTO_PairPosFormat1_  TTO_PairPosFormat1;
297 
298 
299   struct  TTO_Class2Record_
300   {
301     TTO_ValueRecord  Value1;            /* pos. data for first glyph  */
302     TTO_ValueRecord  Value2;            /* pos. data for second glyph */
303   };
304 
305   typedef struct TTO_Class2Record_  TTO_Class2Record;
306 
307 
308   struct  TTO_Class1Record_
309   {
310     TTO_Class2Record*  Class2Record;    /* array of Class2Record tables */
311   };
312 
313   typedef struct TTO_Class1Record_  TTO_Class1Record;
314 
315 
316   struct  TTO_PairPosFormat2_
317   {
318     TTO_ClassDefinition  ClassDef1;     /* class def. for first glyph     */
319     TTO_ClassDefinition  ClassDef2;     /* class def. for second glyph    */
320     FT_UShort            Class1Count;   /* number of classes in ClassDef1
321                                            table                          */
322     FT_UShort            Class2Count;   /* number of classes in ClassDef2
323                                            table                          */
324     TTO_Class1Record*    Class1Record;  /* array of Class1Record tables   */
325   };
326 
327   typedef struct TTO_PairPosFormat2_  TTO_PairPosFormat2;
328 
329 
330   struct  TTO_PairPos_
331   {
332     FT_UShort     PosFormat;            /* 1 or 2         */
333     TTO_Coverage  Coverage;             /* Coverage table */
334     FT_UShort     ValueFormat1;         /* format of ValueRecord table
335                                            for first glyph             */
336     FT_UShort     ValueFormat2;         /* format of ValueRecord table
337                                            for second glyph            */
338 
339     union
340     {
341       TTO_PairPosFormat1  ppf1;
342       TTO_PairPosFormat2  ppf2;
343     } ppf;
344   };
345 
346   typedef struct TTO_PairPos_  TTO_PairPos;
347 
348 
349   /* LookupType 3 */
350 
351   struct  TTO_EntryExitRecord_
352   {
353     TTO_Anchor  EntryAnchor;            /* entry Anchor table */
354     TTO_Anchor  ExitAnchor;             /* exit Anchor table  */
355   };
356 
357 
358   typedef struct TTO_EntryExitRecord_  TTO_EntryExitRecord;
359 
360   struct  TTO_CursivePos_
361   {
362     FT_UShort             PosFormat;    /* always 1                         */
363     TTO_Coverage          Coverage;     /* Coverage table                   */
364     FT_UShort             EntryExitCount;
365                                         /* number of EntryExitRecord tables */
366     TTO_EntryExitRecord*  EntryExitRecord;
367                                         /* array of EntryExitRecord tables  */
368   };
369 
370   typedef struct TTO_CursivePos_  TTO_CursivePos;
371 
372 
373   /* LookupType 4 */
374 
375   struct  TTO_BaseRecord_
376   {
377     TTO_Anchor*  BaseAnchor;            /* array of base glyph anchor
378                                            tables                     */
379   };
380 
381   typedef struct TTO_BaseRecord_  TTO_BaseRecord;
382 
383 
384   struct  TTO_BaseArray_
385   {
386     FT_UShort        BaseCount;         /* number of BaseRecord tables */
387     TTO_BaseRecord*  BaseRecord;        /* array of BaseRecord tables  */
388   };
389 
390   typedef struct TTO_BaseArray_  TTO_BaseArray;
391 
392 
393   struct  TTO_MarkBasePos_
394   {
395     FT_UShort      PosFormat;           /* always 1                  */
396     TTO_Coverage   MarkCoverage;        /* mark glyph coverage table */
397     TTO_Coverage   BaseCoverage;        /* base glyph coverage table */
398     FT_UShort      ClassCount;          /* number of mark classes    */
399     TTO_MarkArray  MarkArray;           /* mark array table          */
400     TTO_BaseArray  BaseArray;           /* base array table          */
401   };
402 
403   typedef struct TTO_MarkBasePos_  TTO_MarkBasePos;
404 
405 
406   /* LookupType 5 */
407 
408   struct  TTO_ComponentRecord_
409   {
410     TTO_Anchor*  LigatureAnchor;        /* array of ligature glyph anchor
411                                            tables                         */
412   };
413 
414   typedef struct TTO_ComponentRecord_  TTO_ComponentRecord;
415 
416 
417   struct  TTO_LigatureAttach_
418   {
419     FT_UShort             ComponentCount;
420                                         /* number of ComponentRecord tables */
421     TTO_ComponentRecord*  ComponentRecord;
422                                         /* array of ComponentRecord tables  */
423   };
424 
425   typedef struct TTO_LigatureAttach_  TTO_LigatureAttach;
426 
427 
428   struct  TTO_LigatureArray_
429   {
430     FT_UShort            LigatureCount; /* number of LigatureAttach tables */
431     TTO_LigatureAttach*  LigatureAttach;
432                                         /* array of LigatureAttach tables  */
433   };
434 
435   typedef struct TTO_LigatureArray_  TTO_LigatureArray;
436 
437 
438   struct  TTO_MarkLigPos_
439   {
440     FT_UShort          PosFormat;       /* always 1                      */
441     TTO_Coverage       MarkCoverage;    /* mark glyph coverage table     */
442     TTO_Coverage       LigatureCoverage;
443                                         /* ligature glyph coverage table */
444     FT_UShort          ClassCount;      /* number of mark classes        */
445     TTO_MarkArray      MarkArray;       /* mark array table              */
446     TTO_LigatureArray  LigatureArray;   /* ligature array table          */
447   };
448 
449   typedef struct TTO_MarkLigPos_  TTO_MarkLigPos;
450 
451 
452   /* LookupType 6 */
453 
454   struct  TTO_Mark2Record_
455   {
456     TTO_Anchor*  Mark2Anchor;           /* array of mark glyph anchor
457                                            tables                     */
458   };
459 
460   typedef struct TTO_Mark2Record_  TTO_Mark2Record;
461 
462 
463   struct  TTO_Mark2Array_
464   {
465     FT_UShort         Mark2Count;       /* number of Mark2Record tables */
466     TTO_Mark2Record*  Mark2Record;      /* array of Mark2Record tables  */
467   };
468 
469   typedef struct TTO_Mark2Array_  TTO_Mark2Array;
470 
471 
472   struct  TTO_MarkMarkPos_
473   {
474     FT_UShort       PosFormat;          /* always 1                         */
475     TTO_Coverage    Mark1Coverage;      /* first mark glyph coverage table  */
476     TTO_Coverage    Mark2Coverage;      /* second mark glyph coverave table */
477     FT_UShort       ClassCount;         /* number of combining mark classes */
478     TTO_MarkArray   Mark1Array;         /* MarkArray table for first mark   */
479     TTO_Mark2Array  Mark2Array;         /* MarkArray table for second mark  */
480   };
481 
482   typedef struct TTO_MarkMarkPos_  TTO_MarkMarkPos;
483 
484 
485   /* needed by both lookup type 7 and 8 */
486 
487   struct  TTO_PosLookupRecord_
488   {
489     FT_UShort  SequenceIndex;           /* index into current
490                                            glyph sequence               */
491     FT_UShort  LookupListIndex;         /* Lookup to apply to that pos. */
492   };
493 
494   typedef struct TTO_PosLookupRecord_  TTO_PosLookupRecord;
495 
496 
497   /* LookupType 7 */
498 
499   struct  TTO_PosRule_
500   {
501     FT_UShort             GlyphCount;   /* total number of input glyphs     */
502     FT_UShort             PosCount;     /* number of PosLookupRecord tables */
503     FT_UShort*            Input;        /* array of input glyph IDs         */
504     TTO_PosLookupRecord*  PosLookupRecord;
505                                         /* array of PosLookupRecord tables  */
506   };
507 
508   typedef struct TTO_PosRule_  TTO_PosRule;
509 
510 
511   struct  TTO_PosRuleSet_
512   {
513     FT_UShort     PosRuleCount;         /* number of PosRule tables */
514     TTO_PosRule*  PosRule;              /* array of PosRule tables  */
515   };
516 
517   typedef struct TTO_PosRuleSet_  TTO_PosRuleSet;
518 
519 
520   struct  TTO_ContextPosFormat1_
521   {
522     TTO_Coverage     Coverage;          /* Coverage table              */
523     FT_UShort        PosRuleSetCount;   /* number of PosRuleSet tables */
524     TTO_PosRuleSet*  PosRuleSet;        /* array of PosRuleSet tables  */
525   };
526 
527   typedef struct TTO_ContextPosFormat1_  TTO_ContextPosFormat1;
528 
529 
530   struct  TTO_PosClassRule_
531   {
532     FT_UShort             GlyphCount;   /* total number of context classes  */
533     FT_UShort             PosCount;     /* number of PosLookupRecord tables */
534     FT_UShort*            Class;        /* array of classes                 */
535     TTO_PosLookupRecord*  PosLookupRecord;
536                                         /* array of PosLookupRecord tables  */
537   };
538 
539   typedef struct TTO_PosClassRule_  TTO_PosClassRule;
540 
541 
542   struct  TTO_PosClassSet_
543   {
544     FT_UShort          PosClassRuleCount;
545                                         /* number of PosClassRule tables */
546     TTO_PosClassRule*  PosClassRule;    /* array of PosClassRule tables  */
547   };
548 
549   typedef struct TTO_PosClassSet_  TTO_PosClassSet;
550 
551 
552   /* The `MaxContextLength' field is not defined in the TTO specification
553      but simplifies the implementation of this format.  It holds the
554      maximal context length used in the context rules.                    */
555 
556   struct  TTO_ContextPosFormat2_
557   {
558     FT_UShort            MaxContextLength;
559                                         /* maximal context length       */
560     TTO_Coverage         Coverage;      /* Coverage table               */
561     TTO_ClassDefinition  ClassDef;      /* ClassDef table               */
562     FT_UShort            PosClassSetCount;
563                                         /* number of PosClassSet tables */
564     TTO_PosClassSet*     PosClassSet;   /* array of PosClassSet tables  */
565   };
566 
567   typedef struct TTO_ContextPosFormat2_  TTO_ContextPosFormat2;
568 
569 
570   struct  TTO_ContextPosFormat3_
571   {
572     FT_UShort             GlyphCount;   /* number of input glyphs           */
573     FT_UShort             PosCount;     /* number of PosLookupRecord tables */
574     TTO_Coverage*         Coverage;     /* array of Coverage tables         */
575     TTO_PosLookupRecord*  PosLookupRecord;
576                                         /* array of PosLookupRecord tables  */
577   };
578 
579   typedef struct TTO_ContextPosFormat3_  TTO_ContextPosFormat3;
580 
581 
582   struct  TTO_ContextPos_
583   {
584     FT_UShort  PosFormat;               /* 1, 2, or 3     */
585 
586     union
587     {
588       TTO_ContextPosFormat1  cpf1;
589       TTO_ContextPosFormat2  cpf2;
590       TTO_ContextPosFormat3  cpf3;
591     } cpf;
592   };
593 
594   typedef struct TTO_ContextPos_  TTO_ContextPos;
595 
596 
597   /* LookupType 8 */
598 
599   struct  TTO_ChainPosRule_
600   {
601     FT_UShort             BacktrackGlyphCount;
602                                         /* total number of backtrack glyphs */
603     FT_UShort*            Backtrack;    /* array of backtrack glyph IDs     */
604     FT_UShort             InputGlyphCount;
605                                         /* total number of input glyphs     */
606     FT_UShort*            Input;        /* array of input glyph IDs         */
607     FT_UShort             LookaheadGlyphCount;
608                                         /* total number of lookahead glyphs */
609     FT_UShort*            Lookahead;    /* array of lookahead glyph IDs     */
610     FT_UShort             PosCount;     /* number of PosLookupRecords       */
611     TTO_PosLookupRecord*  PosLookupRecord;
612                                         /* array of PosLookupRecords       */
613   };
614 
615   typedef struct TTO_ChainPosRule_  TTO_ChainPosRule;
616 
617 
618   struct  TTO_ChainPosRuleSet_
619   {
620     FT_UShort          ChainPosRuleCount;
621                                         /* number of ChainPosRule tables */
622     TTO_ChainPosRule*  ChainPosRule;    /* array of ChainPosRule tables  */
623   };
624 
625   typedef struct TTO_ChainPosRuleSet_  TTO_ChainPosRuleSet;
626 
627 
628   struct  TTO_ChainContextPosFormat1_
629   {
630     TTO_Coverage          Coverage;     /* Coverage table                   */
631     FT_UShort             ChainPosRuleSetCount;
632                                         /* number of ChainPosRuleSet tables */
633     TTO_ChainPosRuleSet*  ChainPosRuleSet;
634                                         /* array of ChainPosRuleSet tables  */
635   };
636 
637   typedef struct TTO_ChainContextPosFormat1_  TTO_ChainContextPosFormat1;
638 
639 
640   struct  TTO_ChainPosClassRule_
641   {
642     FT_UShort             BacktrackGlyphCount;
643                                         /* total number of backtrack
644                                            classes                         */
645     FT_UShort*            Backtrack;    /* array of backtrack classes      */
646     FT_UShort             InputGlyphCount;
647                                         /* total number of context classes */
648     FT_UShort*            Input;        /* array of context classes        */
649     FT_UShort             LookaheadGlyphCount;
650                                         /* total number of lookahead
651                                            classes                         */
652     FT_UShort*            Lookahead;    /* array of lookahead classes      */
653     FT_UShort             PosCount;     /* number of PosLookupRecords      */
654     TTO_PosLookupRecord*  PosLookupRecord;
655                                         /* array of substitution lookups   */
656   };
657 
658   typedef struct TTO_ChainPosClassRule_  TTO_ChainPosClassRule;
659 
660 
661   struct  TTO_ChainPosClassSet_
662   {
663     FT_UShort               ChainPosClassRuleCount;
664                                         /* number of ChainPosClassRule
665                                            tables                      */
666     TTO_ChainPosClassRule*  ChainPosClassRule;
667                                         /* array of ChainPosClassRule
668                                            tables                      */
669   };
670 
671   typedef struct TTO_ChainPosClassSet_  TTO_ChainPosClassSet;
672 
673 
674   /* The `MaxXXXLength' fields are not defined in the TTO specification
675      but simplifies the implementation of this format.  It holds the
676      maximal context length used in the specific context rules.         */
677 
678   struct  TTO_ChainContextPosFormat2_
679   {
680     TTO_Coverage           Coverage;    /* Coverage table             */
681 
682     FT_UShort              MaxBacktrackLength;
683                                         /* maximal backtrack length   */
684     TTO_ClassDefinition    BacktrackClassDef;
685                                         /* BacktrackClassDef table    */
686     FT_UShort              MaxInputLength;
687                                         /* maximal input length       */
688     TTO_ClassDefinition    InputClassDef;
689                                         /* InputClassDef table        */
690     FT_UShort              MaxLookaheadLength;
691                                         /* maximal lookahead length   */
692     TTO_ClassDefinition    LookaheadClassDef;
693                                         /* LookaheadClassDef table    */
694 
695     FT_UShort              ChainPosClassSetCount;
696                                         /* number of ChainPosClassSet
697                                            tables                     */
698     TTO_ChainPosClassSet*  ChainPosClassSet;
699                                         /* array of ChainPosClassSet
700                                            tables                     */
701   };
702 
703   typedef struct TTO_ChainContextPosFormat2_  TTO_ChainContextPosFormat2;
704 
705 
706   struct  TTO_ChainContextPosFormat3_
707   {
708     FT_UShort             BacktrackGlyphCount;
709                                         /* number of backtrack glyphs    */
710     TTO_Coverage*         BacktrackCoverage;
711                                         /* array of backtrack Coverage
712                                            tables                        */
713     FT_UShort             InputGlyphCount;
714                                         /* number of input glyphs        */
715     TTO_Coverage*         InputCoverage;
716                                         /* array of input coverage
717                                            tables                        */
718     FT_UShort             LookaheadGlyphCount;
719                                         /* number of lookahead glyphs    */
720     TTO_Coverage*         LookaheadCoverage;
721                                         /* array of lookahead coverage
722                                            tables                        */
723     FT_UShort             PosCount;     /* number of PosLookupRecords    */
724     TTO_PosLookupRecord*  PosLookupRecord;
725                                         /* array of substitution lookups */
726   };
727 
728   typedef struct TTO_ChainContextPosFormat3_  TTO_ChainContextPosFormat3;
729 
730 
731   struct  TTO_ChainContextPos_
732   {
733     FT_UShort  PosFormat;             /* 1, 2, or 3 */
734 
735     union
736     {
737       TTO_ChainContextPosFormat1  ccpf1;
738       TTO_ChainContextPosFormat2  ccpf2;
739       TTO_ChainContextPosFormat3  ccpf3;
740     } ccpf;
741   };
742 
743   typedef struct TTO_ChainContextPos_  TTO_ChainContextPos;
744 
745 
746   union  TTO_GPOS_SubTable_
747   {
748     TTO_SinglePos        single;
749     TTO_PairPos          pair;
750     TTO_CursivePos       cursive;
751     TTO_MarkBasePos      markbase;
752     TTO_MarkLigPos       marklig;
753     TTO_MarkMarkPos      markmark;
754     TTO_ContextPos       context;
755     TTO_ChainContextPos  chain;
756   };
757 
758   typedef union TTO_GPOS_SubTable_  TTO_GPOS_SubTable;
759 
760 
761   /* finally, the GPOS API */
762 
763   /*  EXPORT_DEF
764       FT_Export ( FT_Error )  TT_Init_GPOS_Extension( TT_Engine  engine ); */
765 
766   EXPORT_DEF
767   FT_Error  TT_Load_GPOS_Table( FT_Face          face,
768                                 TTO_GPOSHeader** gpos,
769                                 TTO_GDEFHeader*  gdef );
770 
771   EXPORT_DEF
772   FT_Error  TT_Done_GPOS_Table( TTO_GPOSHeader* gpos );
773 
774   EXPORT_DEF
775   FT_Error  TT_GPOS_Select_Script( TTO_GPOSHeader*  gpos,
776                                    FT_ULong         script_tag,
777                                    FT_UShort*       script_index );
778   EXPORT_DEF
779   FT_Error  TT_GPOS_Select_Language( TTO_GPOSHeader*  gpos,
780                                      FT_ULong         language_tag,
781                                      FT_UShort        script_index,
782                                      FT_UShort*       language_index,
783                                      FT_UShort*       req_feature_index );
784   EXPORT_DEF
785   FT_Error  TT_GPOS_Select_Feature( TTO_GPOSHeader*  gpos,
786                                     FT_ULong         feature_tag,
787                                     FT_UShort        script_index,
788                                     FT_UShort        language_index,
789                                     FT_UShort*       feature_index );
790 
791   EXPORT_DEF
792   FT_Error  TT_GPOS_Query_Scripts( TTO_GPOSHeader*  gpos,
793                                    FT_ULong**       script_tag_list );
794   EXPORT_DEF
795   FT_Error  TT_GPOS_Query_Languages( TTO_GPOSHeader*  gpos,
796                                      FT_UShort        script_index,
797                                      FT_ULong**       language_tag_list );
798   EXPORT_DEF
799   FT_Error  TT_GPOS_Query_Features( TTO_GPOSHeader*  gpos,
800                                     FT_UShort        script_index,
801                                     FT_UShort        language_index,
802                                     FT_ULong**       feature_tag_list );
803 
804   EXPORT_DEF
805   FT_Error  TT_GPOS_Add_Feature( TTO_GPOSHeader*  gpos,
806                                  FT_UShort        feature_index,
807                                  FT_UInt          property );
808   EXPORT_DEF
809   FT_Error  TT_GPOS_Clear_Features( TTO_GPOSHeader*  gpos );
810 
811   EXPORT_DEF
812   FT_Error  TT_GPOS_Register_Glyph_Function( TTO_GPOSHeader*    gpos,
813                                              TTO_GlyphFunction  gfunc );
814 
815   EXPORT_DEF
816   FT_Error  TT_GPOS_Register_MM_Function( TTO_GPOSHeader*  gpos,
817                                           TTO_MMFunction   mmfunc,
818                                           void*            data );
819 
820   /* If `dvi' is TRUE, glyph contour points for anchor points and device
821      tables are ignored -- you will get device independent values.         */
822 
823   EXPORT_DEF
824   FT_Error  TT_GPOS_Apply_String( FT_Face           face,
825                                   TTO_GPOSHeader*   gpos,
826                                   FT_UShort         load_flags,
827 				  OTL_Buffer        buffer,
828                                   FT_Bool           dvi,
829                                   FT_Bool           r2l );
830 
831 #ifdef __cplusplus
832 }
833 #endif
834 
835 #endif /* FTXGPOS_H */
836 
837 
838 /* END */
839