update for HEAD-2003050101
[reactos.git] / lib / freetype / include / freetype / internal / tttypes.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  tttypes.h                                                              */
4 /*                                                                         */
5 /*    Basic SFNT/TrueType type definitions and interface (specification    */
6 /*    only).                                                               */
7 /*                                                                         */
8 /*  Copyright 1996-2001, 2002 by                                           */
9 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
10 /*                                                                         */
11 /*  This file is part of the FreeType project, and may only be used,       */
12 /*  modified, and distributed under the terms of the FreeType project      */
13 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
14 /*  this file you indicate that you have read the license and              */
15 /*  understand and accept it fully.                                        */
16 /*                                                                         */
17 /***************************************************************************/
18
19
20 #ifndef __TTTYPES_H__
21 #define __TTTYPES_H__
22
23
24 #include <ft2build.h>
25 #include FT_TRUETYPE_TABLES_H
26 #include FT_INTERNAL_OBJECTS_H
27
28
29 FT_BEGIN_HEADER
30
31
32   /*************************************************************************/
33   /*************************************************************************/
34   /*************************************************************************/
35   /***                                                                   ***/
36   /***                                                                   ***/
37   /***             REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS         ***/
38   /***                                                                   ***/
39   /***                                                                   ***/
40   /*************************************************************************/
41   /*************************************************************************/
42   /*************************************************************************/
43
44
45   /*************************************************************************/
46   /*                                                                       */
47   /* <Struct>                                                              */
48   /*    TTC_HeaderRec                                                      */
49   /*                                                                       */
50   /* <Description>                                                         */
51   /*    TrueType collection header.  This table contains the offsets of    */
52   /*    the font headers of each distinct TrueType face in the file.       */
53   /*                                                                       */
54   /* <Fields>                                                              */
55   /*    tag     :: Must be `ttc ' to indicate a TrueType collection.       */
56   /*                                                                       */
57   /*    version :: The version number.                                     */
58   /*                                                                       */
59   /*    count   :: The number of faces in the collection.  The             */
60   /*               specification says this should be an unsigned long, but */
61   /*               we use a signed long since we need the value -1 for     */
62   /*               specific purposes.                                      */
63   /*                                                                       */
64   /*    offsets :: The offsets of the font headers, one per face.          */
65   /*                                                                       */
66   typedef struct  TTC_HeaderRec_
67   {
68     FT_ULong   tag;
69     FT_Fixed   version;
70     FT_Long    count;
71     FT_ULong*  offsets;
72
73   } TTC_HeaderRec;
74
75
76   /*************************************************************************/
77   /*                                                                       */
78   /* <Struct>                                                              */
79   /*    SFNT_HeaderRec                                                     */
80   /*                                                                       */
81   /* <Description>                                                         */
82   /*    SFNT file format header.                                           */
83   /*                                                                       */
84   /* <Fields>                                                              */
85   /*    format_tag     :: The font format tag.                             */
86   /*                                                                       */
87   /*    num_tables     :: The number of tables in file.                    */
88   /*                                                                       */
89   /*    search_range   :: Must be `16 * (max power of 2 <= num_tables)'.   */
90   /*                                                                       */
91   /*    entry_selector :: Must be log2 of `search_range / 16'.             */
92   /*                                                                       */
93   /*    range_shift    :: Must be `num_tables * 16 - search_range'.        */
94   /*                                                                       */
95   typedef struct  SFNT_HeaderRec_
96   {
97     FT_ULong   format_tag;
98     FT_UShort  num_tables;
99     FT_UShort  search_range;
100     FT_UShort  entry_selector;
101     FT_UShort  range_shift;
102
103     FT_ULong   offset;  /* not in file */
104
105   } SFNT_HeaderRec, *SFNT_Header;
106
107
108   /*************************************************************************/
109   /*                                                                       */
110   /* <Struct>                                                              */
111   /*    TT_TableDirRec                                                     */
112   /*                                                                       */
113   /* <Description>                                                         */
114   /*    This structure models a TrueType table directory.  It is used to   */
115   /*    access the various tables of the font face.                        */
116   /*                                                                       */
117   /* <Fields>                                                              */
118   /*    version       :: The version number; starts with 0x00010000.       */
119   /*                                                                       */
120   /*    numTables     :: The number of tables.                             */
121   /*                                                                       */
122   /*    searchRange   :: Unused.                                           */
123   /*                                                                       */
124   /*    entrySelector :: Unused.                                           */
125   /*                                                                       */
126   /*    rangeShift    :: Unused.                                           */
127   /*                                                                       */
128   /* <Note>                                                                */
129   /*    This structure is only used during font opening.                   */
130   /*                                                                       */
131   typedef struct  TT_TableDirRec_
132   {
133     FT_Fixed   version;        /* should be 0x10000 */
134     FT_UShort  numTables;      /* number of tables  */
135
136     FT_UShort  searchRange;    /* These parameters are only used  */
137     FT_UShort  entrySelector;  /* for a dichotomy search in the   */
138     FT_UShort  rangeShift;     /* directory.  We ignore them.     */
139
140   } TT_TableDirRec;
141
142
143   /*************************************************************************/
144   /*                                                                       */
145   /* <Struct>                                                              */
146   /*    TT_TableRec                                                        */
147   /*                                                                       */
148   /* <Description>                                                         */
149   /*    This structure describes a given table of a TrueType font.         */
150   /*                                                                       */
151   /* <Fields>                                                              */
152   /*    Tag      :: A four-bytes tag describing the table.                 */
153   /*                                                                       */
154   /*    CheckSum :: The table checksum.  This value can be ignored.        */
155   /*                                                                       */
156   /*    Offset   :: The offset of the table from the start of the TrueType */
157   /*                font in its resource.                                  */
158   /*                                                                       */
159   /*    Length   :: The table length (in bytes).                           */
160   /*                                                                       */
161   typedef struct  TT_TableRec_
162   {
163     FT_ULong  Tag;        /*        table type */
164     FT_ULong  CheckSum;   /*    table checksum */
165     FT_ULong  Offset;     /* table file offset */
166     FT_ULong  Length;     /*      table length */
167
168   } TT_TableRec, *TT_Table;
169
170
171   /*************************************************************************/
172   /*                                                                       */
173   /* <Struct>                                                              */
174   /*    TT_CMapDirRec                                                      */
175   /*                                                                       */
176   /* <Description>                                                         */
177   /*    This structure describes the directory of the `cmap' table,        */
178   /*    containing the font's character mappings table.                    */
179   /*                                                                       */
180   /* <Fields>                                                              */
181   /*    tableVersionNumber :: The version number.                          */
182   /*                                                                       */
183   /*    numCMaps           :: The number of charmaps in the font.          */
184   /*                                                                       */
185   /* <Note>                                                                */
186   /*    This structure is only used during font loading.                   */
187   /*                                                                       */
188   typedef struct  TT_CMapDirRec_
189   {
190     FT_UShort  tableVersionNumber;
191     FT_UShort  numCMaps;
192
193   } TT_CMapDirRec, *TT_CMapDir;
194
195
196   /*************************************************************************/
197   /*                                                                       */
198   /* <Struct>                                                              */
199   /*    TT_CMapDirEntryRec                                                 */
200   /*                                                                       */
201   /* <Description>                                                         */
202   /*    This structure describes a charmap in a TrueType font.             */
203   /*                                                                       */
204   /* <Fields>                                                              */
205   /*    platformID :: An ID used to specify for which platform this        */
206   /*                  charmap is defined (FreeType manages all platforms). */
207   /*                                                                       */
208   /*    encodingID :: A platform-specific ID used to indicate which source */
209   /*                  encoding is used in this charmap.                    */
210   /*                                                                       */
211   /*    offset     :: The offset of the charmap relative to the start of   */
212   /*                  the `cmap' table.                                    */
213   /*                                                                       */
214   /* <Note>                                                                */
215   /*    This structure is only used during font loading.                   */
216   /*                                                                       */
217   typedef struct  TT_CMapDirEntryRec_
218   {
219     FT_UShort  platformID;
220     FT_UShort  platformEncodingID;
221     FT_Long    offset;
222
223   } TT_CMapDirEntryRec, *TT_CMapDirEntry;
224
225
226   /*************************************************************************/
227   /*                                                                       */
228   /* <Struct>                                                              */
229   /*    TT_LongMetricsRec                                                  */
230   /*                                                                       */
231   /* <Description>                                                         */
232   /*    A structure modeling the long metrics of the `hmtx' and `vmtx'     */
233   /*    TrueType tables.  The values are expressed in font units.          */
234   /*                                                                       */
235   /* <Fields>                                                              */
236   /*    advance :: The advance width or height for the glyph.              */
237   /*                                                                       */
238   /*    bearing :: The left-side or top-side bearing for the glyph.        */
239   /*                                                                       */
240   typedef struct  TT_LongMetricsRec_
241   {
242     FT_UShort  advance;
243     FT_Short   bearing;
244
245   } TT_LongMetricsRec, *TT_LongMetrics;
246
247
248   /*************************************************************************/
249   /*                                                                       */
250   /* <Type>                                                                */
251   /*    TT_ShortMetrics                                                    */
252   /*                                                                       */
253   /* <Description>                                                         */
254   /*    A simple type to model the short metrics of the `hmtx' and `vmtx'  */
255   /*    tables.                                                            */
256   /*                                                                       */
257   typedef FT_Short  TT_ShortMetrics;
258
259
260   /*************************************************************************/
261   /*                                                                       */
262   /* <Struct>                                                              */
263   /*    TT_NameEntryRec                                                    */
264   /*                                                                       */
265   /* <Description>                                                         */
266   /*    A structure modeling TrueType name records.  Name records are used */
267   /*    to store important strings like family name, style name,           */
268   /*    copyright, etc. in _localized_ versions (i.e., language, encoding, */
269   /*    etc).                                                              */
270   /*                                                                       */
271   /* <Fields>                                                              */
272   /*    platformID   :: The ID of the name's encoding platform.            */
273   /*                                                                       */
274   /*    encodingID   :: The platform-specific ID for the name's encoding.  */
275   /*                                                                       */
276   /*    languageID   :: The platform-specific ID for the name's language.  */
277   /*                                                                       */
278   /*    nameID       :: The ID specifying what kind of name this is.       */
279   /*                                                                       */
280   /*    stringLength :: The length of the string in bytes.                 */
281   /*                                                                       */
282   /*    stringOffset :: The offset to the string in the `name' table.      */
283   /*                                                                       */
284   /*    string       :: A pointer to the string's bytes.  Note that these  */
285   /*                    are usually UTF-16 encoded characters.             */
286   /*                                                                       */
287   typedef struct  TT_NameEntryRec_
288   {
289     FT_UShort  platformID;
290     FT_UShort  encodingID;
291     FT_UShort  languageID;
292     FT_UShort  nameID;
293     FT_UShort  stringLength;
294     FT_ULong   stringOffset;
295
296     /* this last field is not defined in the spec */
297     /* but used by the FreeType engine            */
298
299     FT_Byte*   string;
300
301   } TT_NameEntryRec, *TT_NameEntry;
302
303
304   /*************************************************************************/
305   /*                                                                       */
306   /* <Struct>                                                              */
307   /*    TT_NameTableRec                                                    */
308   /*                                                                       */
309   /* <Description>                                                         */
310   /*    A structure modeling the TrueType name table.                      */
311   /*                                                                       */
312   /* <Fields>                                                              */
313   /*    format         :: The format of the name table.                    */
314   /*                                                                       */
315   /*    numNameRecords :: The number of names in table.                    */
316   /*                                                                       */
317   /*    storageOffset  :: The offset of the name table in the `name'       */
318   /*                      TrueType table.                                  */
319   /*                                                                       */
320   /*    names          :: An array of name records.                        */
321   /*                                                                       */
322   /*    stream         :: the file's input stream.                         */
323   /*                                                                       */
324   typedef struct  TT_NameTableRec_
325   {
326     FT_UShort         format;
327     FT_UInt           numNameRecords;
328     FT_UInt           storageOffset;
329     TT_NameEntryRec*  names;
330     FT_Stream         stream;
331
332   } TT_NameTableRec, *TT_NameTable;
333
334
335   /*************************************************************************/
336   /*************************************************************************/
337   /*************************************************************************/
338   /***                                                                   ***/
339   /***                                                                   ***/
340   /***             OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS         ***/
341   /***                                                                   ***/
342   /***                                                                   ***/
343   /*************************************************************************/
344   /*************************************************************************/
345   /*************************************************************************/
346
347
348   /*************************************************************************/
349   /*                                                                       */
350   /* <Struct>                                                              */
351   /*    TT_GaspRangeRec                                                    */
352   /*                                                                       */
353   /* <Description>                                                         */
354   /*    A tiny structure used to model a gasp range according to the       */
355   /*    TrueType specification.                                            */
356   /*                                                                       */
357   /* <Fields>                                                              */
358   /*    maxPPEM  :: The maximum ppem value to which `gaspFlag' applies.    */
359   /*                                                                       */
360   /*    gaspFlag :: A flag describing the grid-fitting and anti-aliasing   */
361   /*                modes to be used.                                      */
362   /*                                                                       */
363   typedef struct  TT_GaspRangeRec_
364   {
365     FT_UShort  maxPPEM;
366     FT_UShort  gaspFlag;
367
368   } TT_GaspRangeRec, *TT_GaspRange;
369
370
371 #define TT_GASP_GRIDFIT  0x01
372 #define TT_GASP_DOGRAY   0x02
373
374
375   /*************************************************************************/
376   /*                                                                       */
377   /* <Struct>                                                              */
378   /*    TT_GaspRec                                                         */
379   /*                                                                       */
380   /* <Description>                                                         */
381   /*    A structure modeling the TrueType `gasp' table used to specify     */
382   /*    grid-fitting and anti-aliasing behaviour.                          */
383   /*                                                                       */
384   /* <Fields>                                                              */
385   /*    version    :: The version number.                                  */
386   /*                                                                       */
387   /*    numRanges  :: The number of gasp ranges in table.                  */
388   /*                                                                       */
389   /*    gaspRanges :: An array of gasp ranges.                             */
390   /*                                                                       */
391   typedef struct  TT_Gasp_
392   {
393     FT_UShort     version;
394     FT_UShort     numRanges;
395     TT_GaspRange  gaspRanges;
396
397   } TT_GaspRec;
398
399
400   /*************************************************************************/
401   /*                                                                       */
402   /* <Struct>                                                              */
403   /*    TT_HdmxEntryRec                                                    */
404   /*                                                                       */
405   /* <Description>                                                         */
406   /*    A small structure used to model the pre-computed widths of a given */
407   /*    size.  They are found in the `hdmx' table.                         */
408   /*                                                                       */
409   /* <Fields>                                                              */
410   /*    ppem      :: The pixels per EM value at which these metrics apply. */
411   /*                                                                       */
412   /*    max_width :: The maximum advance width for this metric.            */
413   /*                                                                       */
414   /*    widths    :: An array of widths.  Note: These are 8-bit bytes.     */
415   /*                                                                       */
416   typedef struct  TT_HdmxEntryRec_
417   {
418     FT_Byte   ppem;
419     FT_Byte   max_width;
420     FT_Byte*  widths;
421
422   } TT_HdmxEntryRec, *TT_HdmxEntry;
423
424
425   /*************************************************************************/
426   /*                                                                       */
427   /* <Struct>                                                              */
428   /*    TT_HdmxRec                                                         */
429   /*                                                                       */
430   /* <Description>                                                         */
431   /*    A structure used to model the `hdmx' table, which contains         */
432   /*    pre-computed widths for a set of given sizes/dimensions.           */
433   /*                                                                       */
434   /* <Fields>                                                              */
435   /*    version     :: The version number.                                 */
436   /*                                                                       */
437   /*    num_records :: The number of hdmx records.                         */
438   /*                                                                       */
439   /*    records     :: An array of hdmx records.                           */
440   /*                                                                       */
441   typedef struct  TT_HdmxRec_
442   {
443     FT_UShort     version;
444     FT_Short      num_records;
445     TT_HdmxEntry  records;
446
447   } TT_HdmxRec, *TT_Hdmx;
448
449
450   /*************************************************************************/
451   /*                                                                       */
452   /* <Struct>                                                              */
453   /*    TT_Kern0_PairRec                                                   */
454   /*                                                                       */
455   /* <Description>                                                         */
456   /*    A structure used to model a kerning pair for the kerning table     */
457   /*    format 0.  The engine now loads this table if it finds one in the  */
458   /*    font file.                                                         */
459   /*                                                                       */
460   /* <Fields>                                                              */
461   /*    left  :: The index of the left glyph in pair.                      */
462   /*                                                                       */
463   /*    right :: The index of the right glyph in pair.                     */
464   /*                                                                       */
465   /*    value :: The kerning distance.  A positive value spaces the        */
466   /*             glyphs, a negative one makes them closer.                 */
467   /*                                                                       */
468   typedef struct  TT_Kern0_PairRec_
469   {
470     FT_UShort  left;   /* index of left  glyph in pair */
471     FT_UShort  right;  /* index of right glyph in pair */
472     FT_FWord   value;  /* kerning value                */
473
474   } TT_Kern0_PairRec, *TT_Kern0_Pair;
475
476
477   /*************************************************************************/
478   /*************************************************************************/
479   /*************************************************************************/
480   /***                                                                   ***/
481   /***                                                                   ***/
482   /***                    EMBEDDED BITMAPS SUPPORT                       ***/
483   /***                                                                   ***/
484   /***                                                                   ***/
485   /*************************************************************************/
486   /*************************************************************************/
487   /*************************************************************************/
488
489
490   /*************************************************************************/
491   /*                                                                       */
492   /* <Struct>                                                              */
493   /*    TT_SBit_MetricsRec                                                 */
494   /*                                                                       */
495   /* <Description>                                                         */
496   /*    A structure used to hold the big metrics of a given glyph bitmap   */
497   /*    in a TrueType or OpenType font.  These are usually found in the    */
498   /*    `EBDT' (Microsoft) or `bloc' (Apple) table.                        */
499   /*                                                                       */
500   /* <Fields>                                                              */
501   /*    height       :: The glyph height in pixels.                        */
502   /*                                                                       */
503   /*    width        :: The glyph width in pixels.                         */
504   /*                                                                       */
505   /*    horiBearingX :: The horizontal left bearing.                       */
506   /*                                                                       */
507   /*    horiBearingY :: The horizontal top bearing.                        */
508   /*                                                                       */
509   /*    horiAdvance  :: The horizontal advance.                            */
510   /*                                                                       */
511   /*    vertBearingX :: The vertical left bearing.                         */
512   /*                                                                       */
513   /*    vertBearingY :: The vertical top bearing.                          */
514   /*                                                                       */
515   /*    vertAdvance  :: The vertical advance.                              */
516   /*                                                                       */
517   typedef struct  TT_SBit_MetricsRec_
518   {
519     FT_Byte  height;
520     FT_Byte  width;
521
522     FT_Char  horiBearingX;
523     FT_Char  horiBearingY;
524     FT_Byte  horiAdvance;
525
526     FT_Char  vertBearingX;
527     FT_Char  vertBearingY;
528     FT_Byte  vertAdvance;
529
530   } TT_SBit_MetricsRec, *TT_SBit_Metrics;
531
532
533   /*************************************************************************/
534   /*                                                                       */
535   /* <Struct>                                                              */
536   /*    TT_SBit_SmallMetricsRec                                            */
537   /*                                                                       */
538   /* <Description>                                                         */
539   /*    A structure used to hold the small metrics of a given glyph bitmap */
540   /*    in a TrueType or OpenType font.  These are usually found in the    */
541   /*    `EBDT' (Microsoft) or the `bdat' (Apple) table.                    */
542   /*                                                                       */
543   /* <Fields>                                                              */
544   /*    height   :: The glyph height in pixels.                            */
545   /*                                                                       */
546   /*    width    :: The glyph width in pixels.                             */
547   /*                                                                       */
548   /*    bearingX :: The left-side bearing.                                 */
549   /*                                                                       */
550   /*    bearingY :: The top-side bearing.                                  */
551   /*                                                                       */
552   /*    advance  :: The advance width or height.                           */
553   /*                                                                       */
554   typedef struct  TT_SBit_Small_Metrics_
555   {
556     FT_Byte  height;
557     FT_Byte  width;
558
559     FT_Char  bearingX;
560     FT_Char  bearingY;
561     FT_Byte  advance;
562
563   } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics;
564
565
566   /*************************************************************************/
567   /*                                                                       */
568   /* <Struct>                                                              */
569   /*    TT_SBit_LineMetricsRec                                             */
570   /*                                                                       */
571   /* <Description>                                                         */
572   /*    A structure used to describe the text line metrics of a given      */
573   /*    bitmap strike, for either a horizontal or vertical layout.         */
574   /*                                                                       */
575   /* <Fields>                                                              */
576   /*    ascender                :: The ascender in pixels.                 */
577   /*                                                                       */
578   /*    descender               :: The descender in pixels.                */
579   /*                                                                       */
580   /*    max_width               :: The maximum glyph width in pixels.      */
581   /*                                                                       */
582   /*    caret_slope_enumerator  :: Rise of the caret slope, typically set  */
583   /*                               to 1 for non-italic fonts.              */
584   /*                                                                       */
585   /*    caret_slope_denominator :: Rise of the caret slope, typically set  */
586   /*                               to 0 for non-italic fonts.              */
587   /*                                                                       */
588   /*    caret_offset            :: Offset in pixels to move the caret for  */
589   /*                               proper positioning.                     */
590   /*                                                                       */
591   /*    min_origin_SB           :: Minimum of horiBearingX (resp.          */
592   /*                               vertBearingY).                          */
593   /*    min_advance_SB          :: Minimum of                              */
594   /*                                                                       */
595   /*                                 horizontal advance -                  */
596   /*                                   ( horiBearingX + width )            */
597   /*                                                                       */
598   /*                               resp.                                   */
599   /*                                                                       */
600   /*                                 vertical advance -                    */
601   /*                                   ( vertBearingY + height )           */
602   /*                                                                       */
603   /*    max_before_BL           :: Maximum of horiBearingY (resp.          */
604   /*                               vertBearingY).                          */
605   /*                                                                       */
606   /*    min_after_BL            :: Minimum of                              */
607   /*                                                                       */
608   /*                                 horiBearingY - height                 */
609   /*                                                                       */
610   /*                               resp.                                   */
611   /*                                                                       */
612   /*                                 vertBearingX - width                  */
613   /*                                                                       */
614   /*    pads                    :: Unused (to make the size of the record  */
615   /*                               a multiple of 32 bits.                  */
616   /*                                                                       */
617   typedef struct  TT_SBit_LineMetricsRec_
618   {
619     FT_Char  ascender;
620     FT_Char  descender;
621     FT_Byte  max_width;
622     FT_Char  caret_slope_numerator;
623     FT_Char  caret_slope_denominator;
624     FT_Char  caret_offset;
625     FT_Char  min_origin_SB;
626     FT_Char  min_advance_SB;
627     FT_Char  max_before_BL;
628     FT_Char  min_after_BL;
629     FT_Char  pads[2];
630
631   } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics;
632
633
634   /*************************************************************************/
635   /*                                                                       */
636   /* <Struct>                                                              */
637   /*    TT_SBit_RangeRec                                                   */
638   /*                                                                       */
639   /* <Description>                                                         */
640   /*    A TrueType/OpenType subIndexTable as defined in the `EBLC'         */
641   /*    (Microsoft) or `bloc' (Apple) tables.                              */
642   /*                                                                       */
643   /* <Fields>                                                              */
644   /*    first_glyph   :: The first glyph index in the range.               */
645   /*                                                                       */
646   /*    last_glyph    :: The last glyph index in the range.                */
647   /*                                                                       */
648   /*    index_format  :: The format of index table.  Valid values are 1    */
649   /*                     to 5.                                             */
650   /*                                                                       */
651   /*    image_format  :: The format of `EBDT' image data.                  */
652   /*                                                                       */
653   /*    image_offset  :: The offset to image data in `EBDT'.               */
654   /*                                                                       */
655   /*    image_size    :: For index formats 2 and 5.  This is the size in   */
656   /*                     bytes of each glyph bitmap.                       */
657   /*                                                                       */
658   /*    big_metrics   :: For index formats 2 and 5.  This is the big       */
659   /*                     metrics for each glyph bitmap.                    */
660   /*                                                                       */
661   /*    num_glyphs    :: For index formats 4 and 5.  This is the number of */
662   /*                     glyphs in the code array.                         */
663   /*                                                                       */
664   /*    glyph_offsets :: For index formats 1 and 3.                        */
665   /*                                                                       */
666   /*    glyph_codes   :: For index formats 4 and 5.                        */
667   /*                                                                       */
668   /*    table_offset  :: The offset of the index table in the `EBLC'       */
669   /*                     table.  Only used during strike loading.          */
670   /*                                                                       */
671   typedef struct  TT_SBit_RangeRec
672   {
673     FT_UShort           first_glyph;
674     FT_UShort           last_glyph;
675
676     FT_UShort           index_format;
677     FT_UShort           image_format;
678     FT_ULong            image_offset;
679
680     FT_ULong            image_size;
681     TT_SBit_MetricsRec  metrics;
682     FT_ULong            num_glyphs;
683
684     FT_ULong*           glyph_offsets;
685     FT_UShort*          glyph_codes;
686
687     FT_ULong            table_offset;
688
689   } TT_SBit_RangeRec, *TT_SBit_Range;
690
691
692   /*************************************************************************/
693   /*                                                                       */
694   /* <Struct>                                                              */
695   /*    TT_SBit_StrikeRec                                                  */
696   /*                                                                       */
697   /* <Description>                                                         */
698   /*    A structure used describe a given bitmap strike in the `EBLC'      */
699   /*    (Microsoft) or `bloc' (Apple) tables.                              */
700   /*                                                                       */
701   /* <Fields>                                                              */
702   /*   num_index_ranges :: The number of index ranges.                     */
703   /*                                                                       */
704   /*   index_ranges     :: An array of glyph index ranges.                 */
705   /*                                                                       */
706   /*   color_ref        :: Unused.  `color_ref' is put in for future       */
707   /*                       enhancements, but these fields are already      */
708   /*                       in use by other platforms (e.g. Newton).        */
709   /*                       For details, please see                         */
710   /*                                                                       */
711   /*                         http://fonts.apple.com/                       */
712   /*                                TTRefMan/RM06/Chap6bloc.html           */
713   /*                                                                       */
714   /*   hori             :: The line metrics for horizontal layouts.        */
715   /*                                                                       */
716   /*   vert             :: The line metrics for vertical layouts.          */
717   /*                                                                       */
718   /*   start_glyph      :: The lowest glyph index for this strike.         */
719   /*                                                                       */
720   /*   end_glyph        :: The highest glyph index for this strike.        */
721   /*                                                                       */
722   /*   x_ppem           :: The number of horizontal pixels per EM.         */
723   /*                                                                       */
724   /*   y_ppem           :: The number of vertical pixels per EM.           */
725   /*                                                                       */
726   /*   bit_depth        :: The bit depth.  Valid values are 1, 2, 4,       */
727   /*                       and 8.                                          */
728   /*                                                                       */
729   /*   flags            :: Is this a vertical or horizontal strike?  For   */
730   /*                       details, please see                             */
731   /*                                                                       */
732   /*                         http://fonts.apple.com/                       */
733   /*                                TTRefMan/RM06/Chap6bloc.html           */
734   /*                                                                       */
735   typedef struct  TT_SBit_StrikeRec_
736   {
737     FT_Int                  num_ranges;
738     TT_SBit_Range           sbit_ranges;
739     FT_ULong                ranges_offset;
740
741     FT_ULong                color_ref;
742
743     TT_SBit_LineMetricsRec  hori;
744     TT_SBit_LineMetricsRec  vert;
745
746     FT_UShort               start_glyph;
747     FT_UShort               end_glyph;
748
749     FT_Byte                 x_ppem;
750     FT_Byte                 y_ppem;
751
752     FT_Byte                 bit_depth;
753     FT_Char                 flags;
754
755   } TT_SBit_StrikeRec, *TT_SBit_Strike;
756
757
758   /*************************************************************************/
759   /*                                                                       */
760   /* <Struct>                                                              */
761   /*    TT_SBit_ComponentRec                                               */
762   /*                                                                       */
763   /* <Description>                                                         */
764   /*    A simple structure to describe a compound sbit element.            */
765   /*                                                                       */
766   /* <Fields>                                                              */
767   /*    glyph_code :: The element's glyph index.                           */
768   /*                                                                       */
769   /*    x_offset   :: The element's left bearing.                          */
770   /*                                                                       */
771   /*    y_offset   :: The element's top bearing.                           */
772   /*                                                                       */
773   typedef struct  TT_SBit_ComponentRec_
774   {
775     FT_UShort  glyph_code;
776     FT_Char    x_offset;
777     FT_Char    y_offset;
778
779   } TT_SBit_ComponentRec, *TT_SBit_Component;
780
781
782   /*************************************************************************/
783   /*                                                                       */
784   /* <Struct>                                                              */
785   /*    TT_SBit_ScaleRec                                                   */
786   /*                                                                       */
787   /* <Description>                                                         */
788   /*    A structure used describe a given bitmap scaling table, as defined */
789   /*    in the `EBSC' table.                                               */
790   /*                                                                       */
791   /* <Fields>                                                              */
792   /*    hori              :: The horizontal line metrics.                  */
793   /*                                                                       */
794   /*    vert              :: The vertical line metrics.                    */
795   /*                                                                       */
796   /*    x_ppem            :: The number of horizontal pixels per EM.       */
797   /*                                                                       */
798   /*    y_ppem            :: The number of vertical pixels per EM.         */
799   /*                                                                       */
800   /*    x_ppem_substitute :: Substitution x_ppem value.                    */
801   /*                                                                       */
802   /*    y_ppem_substitute :: Substitution y_ppem value.                    */
803   /*                                                                       */
804   typedef struct  TT_SBit_ScaleRec_
805   {
806     TT_SBit_LineMetricsRec  hori;
807     TT_SBit_LineMetricsRec  vert;
808
809     FT_Byte                 x_ppem;
810     FT_Byte                 y_ppem;
811
812     FT_Byte                 x_ppem_substitute;
813     FT_Byte                 y_ppem_substitute;
814
815   } TT_SBit_ScaleRec, *TT_SBit_Scale;
816
817
818   /*************************************************************************/
819   /*************************************************************************/
820   /*************************************************************************/
821   /***                                                                   ***/
822   /***                                                                   ***/
823   /***                  POSTSCRIPT GLYPH NAMES SUPPORT                   ***/
824   /***                                                                   ***/
825   /***                                                                   ***/
826   /*************************************************************************/
827   /*************************************************************************/
828   /*************************************************************************/
829
830
831   /*************************************************************************/
832   /*                                                                       */
833   /* <Struct>                                                              */
834   /*    TT_Post_20Rec                                                      */
835   /*                                                                       */
836   /* <Description>                                                         */
837   /*    Postscript names sub-table, format 2.0.  Stores the PS name of     */
838   /*    each glyph in the font face.                                       */
839   /*                                                                       */
840   /* <Fields>                                                              */
841   /*    num_glyphs    :: The number of named glyphs in the table.          */
842   /*                                                                       */
843   /*    num_names     :: The number of PS names stored in the table.       */
844   /*                                                                       */
845   /*    glyph_indices :: The indices of the glyphs in the names arrays.    */
846   /*                                                                       */
847   /*    glyph_names   :: The PS names not in Mac Encoding.                 */
848   /*                                                                       */
849   typedef struct  TT_Post_20Rec_
850   {
851     FT_UShort   num_glyphs;
852     FT_UShort   num_names;
853     FT_UShort*  glyph_indices;
854     FT_Char**   glyph_names;
855
856   } TT_Post_20Rec, *TT_Post_20;
857
858
859   /*************************************************************************/
860   /*                                                                       */
861   /* <Struct>                                                              */
862   /*    TT_Post_25Rec                                                      */
863   /*                                                                       */
864   /* <Description>                                                         */
865   /*    Postscript names sub-table, format 2.5.  Stores the PS name of     */
866   /*    each glyph in the font face.                                       */
867   /*                                                                       */
868   /* <Fields>                                                              */
869   /*    num_glyphs :: The number of glyphs in the table.                   */
870   /*                                                                       */
871   /*    offsets    :: An array of signed offsets in a normal Mac           */
872   /*                  Postscript name encoding.                            */
873   /*                                                                       */
874   typedef struct  TT_Post_25_
875   {
876     FT_UShort  num_glyphs;
877     FT_Char*   offsets;
878
879   } TT_Post_25Rec, *TT_Post_25;
880
881
882   /*************************************************************************/
883   /*                                                                       */
884   /* <Struct>                                                              */
885   /*    TT_Post_NamesRec                                                   */
886   /*                                                                       */
887   /* <Description>                                                         */
888   /*    Postscript names table, either format 2.0 or 2.5.                  */
889   /*                                                                       */
890   /* <Fields>                                                              */
891   /*    loaded    :: A flag to indicate whether the PS names are loaded.   */
892   /*                                                                       */
893   /*    format_20 :: The sub-table used for format 2.0.                    */
894   /*                                                                       */
895   /*    format_25 :: The sub-table used for format 2.5.                    */
896   /*                                                                       */
897   typedef struct  TT_Post_NamesRec_
898   {
899     FT_Bool  loaded;
900
901     union
902     {
903       TT_Post_20Rec  format_20;
904       TT_Post_25Rec  format_25;
905
906     } names;
907
908   } TT_Post_NamesRec, *TT_Post_Names;
909
910
911   /*************************************************************************/
912   /*************************************************************************/
913   /*************************************************************************/
914   /***                                                                   ***/
915   /***                                                                   ***/
916   /***                  TRUETYPE CHARMAPS SUPPORT                        ***/
917   /***                                                                   ***/
918   /***                                                                   ***/
919   /*************************************************************************/
920   /*************************************************************************/
921   /*************************************************************************/
922
923
924   /* format 0 */
925
926   typedef struct  TT_CMap0_
927   {
928     FT_ULong  language;       /* for Mac fonts (originally ushort) */
929
930     FT_Byte*  glyphIdArray;
931
932   } TT_CMap0Rec, *TT_CMap0;
933
934
935   /* format 2 */
936
937   typedef struct  TT_CMap2SubHeaderRec_
938   {
939     FT_UShort  firstCode;      /* first valid low byte         */
940     FT_UShort  entryCount;     /* number of valid low bytes    */
941     FT_Short   idDelta;        /* delta value to glyphIndex    */
942     FT_UShort  idRangeOffset;  /* offset from here to 1st code */
943
944   } TT_CMap2SubHeaderRec, *TT_CMap2SubHeader;
945
946
947   typedef struct  TT_CMap2Rec_
948   {
949     FT_ULong            language;     /* for Mac fonts (originally ushort) */
950
951     FT_UShort*          subHeaderKeys;  /* high byte mapping table     */
952                                         /* value = subHeader index * 8 */
953     TT_CMap2SubHeader   subHeaders;
954     FT_UShort*          glyphIdArray;
955     FT_UShort           numGlyphId;   /* control value */
956
957   } TT_CMap2Rec, *TT_CMap2;
958
959
960   /* format 4 */
961
962   typedef struct  TT_CMap4Segment_
963   {
964     FT_UShort  endCount;
965     FT_UShort  startCount;
966     FT_Short   idDelta;
967     FT_UShort  idRangeOffset;
968
969   } TT_CMap4SegmentRec, *TT_CMap4Segment;
970
971
972   typedef struct  TT_CMap4Rec_
973   {
974     FT_ULong         language;       /* for Mac fonts (originally ushort) */
975
976     FT_UShort        segCountX2;     /* number of segments * 2            */
977     FT_UShort        searchRange;    /* these parameters can be used      */
978     FT_UShort        entrySelector;  /* for a binary search               */
979     FT_UShort        rangeShift;
980
981     TT_CMap4Segment  segments;
982     FT_UShort*       glyphIdArray;
983     FT_UShort        numGlyphId;     /* control value */
984
985     TT_CMap4Segment  last_segment;   /* last used segment; this is a small  */
986                                      /* cache to potentially increase speed */
987   } TT_CMap4Rec, *TT_CMap4;
988
989
990   /* format 6 */
991
992   typedef struct  TT_CMap6_
993   {
994     FT_ULong    language;       /* for Mac fonts (originally ushort)     */
995
996     FT_UShort   firstCode;      /* first character code of subrange      */
997     FT_UShort   entryCount;     /* number of character codes in subrange */
998
999     FT_UShort*  glyphIdArray;
1000
1001   } TT_CMap6Rec, *TT_CMap6;
1002
1003
1004   /* auxiliary table for format 8 and 12 */
1005
1006   typedef struct  TT_CMapGroupRec_
1007   {
1008     FT_ULong  startCharCode;
1009     FT_ULong  endCharCode;
1010     FT_ULong  startGlyphID;
1011
1012   } TT_CMapGroupRec, *TT_CMapGroup;
1013
1014
1015   /* FreeType handles format 8 and 12 identically.  It is not necessary to
1016      cover mixed 16bit and 32bit codes since FreeType always uses FT_ULong
1017      for input character codes -- converting Unicode surrogates to 32bit
1018      character codes must be done by the application.                      */
1019
1020   typedef struct  TT_CMap8_12Rec_
1021   {
1022     FT_ULong      language;        /* for Mac fonts */
1023
1024     FT_ULong      nGroups;
1025     TT_CMapGroup  groups;
1026
1027     TT_CMapGroup  last_group;      /* last used group; this is a small    */
1028                                    /* cache to potentially increase speed */
1029   } TT_CMap8_12Rec, *TT_CMap8_12;
1030
1031
1032   /* format 10 */
1033
1034   typedef struct  TT_CMap10Rec_
1035   {
1036     FT_ULong    language;           /* for Mac fonts */
1037
1038     FT_ULong    startCharCode;      /* first character covered */
1039     FT_ULong    numChars;           /* number of characters covered */
1040
1041     FT_UShort*  glyphs;
1042
1043   } TT_CMap10Rec, *TT_CMap10;
1044
1045
1046   typedef struct TT_CMapTableRec_*  TT_CMapTable;
1047
1048
1049   typedef FT_UInt
1050   (*TT_CharMap_Func)( TT_CMapTable  charmap,
1051                       FT_ULong      char_code );
1052
1053   typedef FT_ULong
1054   (*TT_CharNext_Func)( TT_CMapTable  charmap,
1055                        FT_ULong      char_code );
1056
1057
1058   /* charmap table */
1059   typedef struct  TT_CMapTableRec_
1060   {
1061     FT_UShort  platformID;
1062     FT_UShort  platformEncodingID;
1063     FT_UShort  format;
1064     FT_ULong   length;          /* must be ulong for formats 8, 10, and 12 */
1065
1066     FT_Bool    loaded;
1067     FT_ULong   offset;
1068
1069     union
1070     {
1071       TT_CMap0Rec     cmap0;
1072       TT_CMap2Rec     cmap2;
1073       TT_CMap4Rec     cmap4;
1074       TT_CMap6Rec     cmap6;
1075       TT_CMap8_12Rec  cmap8_12;
1076       TT_CMap10Rec    cmap10;
1077     } c;
1078
1079     TT_CharMap_Func   get_index;
1080     TT_CharNext_Func  get_next_char;
1081
1082   } TT_CMapTableRec;
1083
1084
1085   /*************************************************************************/
1086   /*                                                                       */
1087   /* <Struct>                                                              */
1088   /*    TT_CharMapRec                                                      */
1089   /*                                                                       */
1090   /* <Description>                                                         */
1091   /*    The TrueType character map object type.                            */
1092   /*                                                                       */
1093   /* <Fields>                                                              */
1094   /*    root :: The parent character map structure.                        */
1095   /*                                                                       */
1096   /*    cmap :: The used character map.                                    */
1097   /*                                                                       */
1098   typedef struct  TT_CharMapRec_
1099   {
1100     FT_CharMapRec    root;
1101     TT_CMapTableRec  cmap;
1102
1103   } TT_CharMapRec;
1104
1105
1106   /*************************************************************************/
1107   /*************************************************************************/
1108   /*************************************************************************/
1109   /***                                                                   ***/
1110   /***                                                                   ***/
1111   /***                  ORIGINAL TT_FACE CLASS DEFINITION                ***/
1112   /***                                                                   ***/
1113   /***                                                                   ***/
1114   /*************************************************************************/
1115   /*************************************************************************/
1116   /*************************************************************************/
1117
1118
1119   /*************************************************************************/
1120   /*                                                                       */
1121   /* This structure/class is defined here because it is common to the      */
1122   /* following formats: TTF, OpenType-TT, and OpenType-CFF.                */
1123   /*                                                                       */
1124   /* Note, however, that the classes TT_Size, TT_GlyphSlot, and TT_CharMap */
1125   /* are not shared between font drivers, and are thus defined in          */
1126   /* `ttobjs.h'.                                                           */
1127   /*                                                                       */
1128   /*************************************************************************/
1129
1130
1131   /*************************************************************************/
1132   /*                                                                       */
1133   /* <Type>                                                                */
1134   /*    TT_Face                                                            */
1135   /*                                                                       */
1136   /* <Description>                                                         */
1137   /*    A handle to a TrueType face/font object.  A TT_Face encapsulates   */
1138   /*    the resolution and scaling independent parts of a TrueType font    */
1139   /*    resource.                                                          */
1140   /*                                                                       */
1141   /* <Note>                                                                */
1142   /*    The TT_Face structure is also used as a `parent class' for the     */
1143   /*    OpenType-CFF class (T2_Face).                                      */
1144   /*                                                                       */
1145   typedef struct TT_FaceRec_*  TT_Face;
1146
1147
1148   /*************************************************************************/
1149   /*                                                                       */
1150   /* <Type>                                                                */
1151   /*    TT_CharMap                                                         */
1152   /*                                                                       */
1153   /* <Description>                                                         */
1154   /*    A handle to a TrueType character mapping object.                   */
1155   /*                                                                       */
1156   typedef struct TT_CharMapRec_*  TT_CharMap;
1157
1158
1159   /* a function type used for the truetype bytecode interpreter hooks */
1160   typedef FT_Error
1161   (*TT_Interpreter)( void*  exec_context );
1162
1163   /* forward declaration */
1164   typedef struct TT_LoaderRec_*  TT_Loader;
1165
1166
1167   /*************************************************************************/
1168   /*                                                                       */
1169   /* <FuncType>                                                            */
1170   /*    TT_Loader_GotoTableFunc                                            */
1171   /*                                                                       */
1172   /* <Description>                                                         */
1173   /*    Seeks a stream to the start of a given TrueType table.             */
1174   /*                                                                       */
1175   /* <Input>                                                               */
1176   /*    face   :: A handle to the target face object.                      */
1177   /*                                                                       */
1178   /*    tag    :: A 4-byte tag used to name the table.                     */
1179   /*                                                                       */
1180   /*    stream :: The input stream.                                        */
1181   /*                                                                       */
1182   /* <Output>                                                              */
1183   /*    length :: The length of the table in bytes.  Set to 0 if not       */
1184   /*              needed.                                                  */
1185   /*                                                                       */
1186   /* <Return>                                                              */
1187   /*    FreeType error code.  0 means success.                             */
1188   /*                                                                       */
1189   /* <Note>                                                                */
1190   /*    The stream cursor must be at the font file's origin.               */
1191   /*                                                                       */
1192   typedef FT_Error
1193   (*TT_Loader_GotoTableFunc)( TT_Face    face,
1194                               FT_ULong   tag,
1195                               FT_Stream  stream,
1196                               FT_ULong*  length );
1197
1198
1199   /*************************************************************************/
1200   /*                                                                       */
1201   /* <FuncType>                                                            */
1202   /*    TT_Loader_StartGlyphFunc                                           */
1203   /*                                                                       */
1204   /* <Description>                                                         */
1205   /*    Seeks a stream to the start of a given glyph element, and opens a  */
1206   /*    frame for it.                                                      */
1207   /*                                                                       */
1208   /* <Input>                                                               */
1209   /*    loader      :: The current TrueType glyph loader object.           */
1210   /*                                                                       */
1211   /*    glyph index :: The index of the glyph to access.                   */
1212   /*                                                                       */
1213   /*    offset      :: The offset of the glyph according to the            */
1214   /*                   `locations' table.                                  */
1215   /*                                                                       */
1216   /*    byte_count  :: The size of the frame in bytes.                     */
1217   /*                                                                       */
1218   /* <Return>                                                              */
1219   /*    FreeType error code.  0 means success.                             */
1220   /*                                                                       */
1221   /* <Note>                                                                */
1222   /*    This function is normally equivalent to FT_STREAM_SEEK(offset)     */
1223   /*    followed by FT_FRAME_ENTER(byte_count) with the loader's stream,   */
1224   /*    but alternative formats (e.g. compressed ones) might use something */
1225   /*    different.                                                         */
1226   /*                                                                       */
1227   typedef FT_Error
1228   (*TT_Loader_StartGlyphFunc)( TT_Loader  loader,
1229                                FT_UInt    glyph_index,
1230                                FT_ULong   offset,
1231                                FT_UInt    byte_count );
1232
1233
1234   /*************************************************************************/
1235   /*                                                                       */
1236   /* <FuncType>                                                            */
1237   /*    TT_Loader_ReadGlyphFunc                                            */
1238   /*                                                                       */
1239   /* <Description>                                                         */
1240   /*    Reads one glyph element (its header, a simple glyph, or a          */
1241   /*    composite) from the loader's current stream frame.                 */
1242   /*                                                                       */
1243   /* <Input>                                                               */
1244   /*    loader :: The current TrueType glyph loader object.                */
1245   /*                                                                       */
1246   /* <Return>                                                              */
1247   /*    FreeType error code.  0 means success.                             */
1248   /*                                                                       */
1249   typedef FT_Error
1250   (*TT_Loader_ReadGlyphFunc)( TT_Loader  loader );
1251
1252
1253   /*************************************************************************/
1254   /*                                                                       */
1255   /* <FuncType>                                                            */
1256   /*    TT_Loader_EndGlyphFunc                                             */
1257   /*                                                                       */
1258   /* <Description>                                                         */
1259   /*    Closes the current loader stream frame for the glyph.              */
1260   /*                                                                       */
1261   /* <Input>                                                               */
1262   /*    loader :: The current TrueType glyph loader object.                */
1263   /*                                                                       */
1264   typedef void
1265   (*TT_Loader_EndGlyphFunc)( TT_Loader  loader );
1266
1267
1268   /*************************************************************************/
1269   /*                                                                       */
1270   /*                         TrueType Face Type                            */
1271   /*                                                                       */
1272   /* <Struct>                                                              */
1273   /*    TT_Face                                                            */
1274   /*                                                                       */
1275   /* <Description>                                                         */
1276   /*    The TrueType face class.  These objects model the resolution and   */
1277   /*    point-size independent data found in a TrueType font file.         */
1278   /*                                                                       */
1279   /* <Fields>                                                              */
1280   /*    root                 :: The base FT_Face structure, managed by the */
1281   /*                            base layer.                                */
1282   /*                                                                       */
1283   /*    ttc_header           :: The TrueType collection header, used when  */
1284   /*                            the file is a `ttc' rather than a `ttf'.   */
1285   /*                            For ordinary font files, the field         */
1286   /*                            `ttc_header.count' is set to 0.            */
1287   /*                                                                       */
1288   /*    format_tag           :: The font format tag.                       */
1289   /*                                                                       */
1290   /*    num_tables           :: The number of TrueType tables in this font */
1291   /*                            file.                                      */
1292   /*                                                                       */
1293   /*    dir_tables           :: The directory of TrueType tables for this  */
1294   /*                            font file.                                 */
1295   /*                                                                       */
1296   /*    header               :: The font's font header (`head' table).     */
1297   /*                            Read on font opening.                      */
1298   /*                                                                       */
1299   /*    horizontal           :: The font's horizontal header (`hhea'       */
1300   /*                            table).  This field also contains the      */
1301   /*                            associated horizontal metrics table        */
1302   /*                            (`hmtx').                                  */
1303   /*                                                                       */
1304   /*    max_profile          :: The font's maximum profile table.  Read on */
1305   /*                            font opening.  Note that some maximum      */
1306   /*                            values cannot be taken directly from this  */
1307   /*                            table.  We thus define additional fields   */
1308   /*                            below to hold the computed maxima.         */
1309   /*                                                                       */
1310   /*    max_components       :: The maximum number of glyph components     */
1311   /*                            required to load any composite glyph from  */
1312   /*                            this font.  Used to size the load stack.   */
1313   /*                                                                       */
1314   /*    vertical_info        :: A boolean which is set when the font file  */
1315   /*                            contains vertical metrics.  If not, the    */
1316   /*                            value of the `vertical' field is           */
1317   /*                            undefined.                                 */
1318   /*                                                                       */
1319   /*    vertical             :: The font's vertical header (`vhea' table). */
1320   /*                            This field also contains the associated    */
1321   /*                            vertical metrics table (`vmtx'), if found. */
1322   /*                            IMPORTANT: The contents of this field is   */
1323   /*                            undefined if the `verticalInfo' field is   */
1324   /*                            unset.                                     */
1325   /*                                                                       */
1326   /*    num_names            :: The number of name records within this     */
1327   /*                            TrueType font.                             */
1328   /*                                                                       */
1329   /*    name_table           :: The table of name records (`name').        */
1330   /*                                                                       */
1331   /*    os2                  :: The font's OS/2 table (`OS/2').            */
1332   /*                                                                       */
1333   /*    postscript           :: The font's PostScript table (`post'        */
1334   /*                            table).  The PostScript glyph names are    */
1335   /*                            not loaded by the driver on face opening.  */
1336   /*                            See the `ttpost' module for more details.  */
1337   /*                                                                       */
1338   /*    cmap_table           :: Address of the face's `cmap' SFNT table    */
1339   /*                            in memory (it's an extracted frame).       */
1340   /*                                                                       */
1341   /*    cmap_size            :: The size in bytes of the `cmap_table'      */
1342   /*                            described above.                           */
1343   /*                                                                       */
1344   /*    num_charmaps         :: The number of character mappings in the    */
1345   /*                            font.                                      */
1346   /*                                                                       */
1347   /*    charmaps             :: The array of charmap objects for this font */
1348   /*                            file.  Note that this field is a typeless  */
1349   /*                            pointer.  The Reason is that the format of */
1350   /*                            charmaps varies with the underlying font   */
1351   /*                            format and cannot be determined here.      */
1352   /*                                                                       */
1353   /*    goto_table           :: A function called by each TrueType table   */
1354   /*                            loader to position a stream's cursor to    */
1355   /*                            the start of a given table according to    */
1356   /*                            its tag.  It defaults to TT_Goto_Face but  */
1357   /*                            can be different for strange formats (e.g. */
1358   /*                            Type 42).                                  */
1359   /*                                                                       */
1360   /*    access_glyph_frame   :: A function used to access the frame of a   */
1361   /*                            given glyph within the face's font file.   */
1362   /*                                                                       */
1363   /*    forget_glyph_frame   :: A function used to forget the frame of a   */
1364   /*                            given glyph when all data has been loaded. */
1365   /*                                                                       */
1366   /*    read_glyph_header    :: A function used to read a glyph header.    */
1367   /*                            It must be called between an `access' and  */
1368   /*                            `forget'.                                  */
1369   /*                                                                       */
1370   /*    read_simple_glyph    :: A function used to read a simple glyph.    */
1371   /*                            It must be called after the header was     */
1372   /*                            read, and before the `forget'.             */
1373   /*                                                                       */
1374   /*    read_composite_glyph :: A function used to read a composite glyph. */
1375   /*                            It must be called after the header was     */
1376   /*                            read, and before the `forget'.             */
1377   /*                                                                       */
1378   /*    sfnt                 :: A pointer to the SFNT `driver' interface.  */
1379   /*                                                                       */
1380   /*    psnames              :: A pointer to the `PSNames' module          */
1381   /*                            interface.                                 */
1382   /*                                                                       */
1383   /*    hdmx                 :: The face's horizontal device metrics       */
1384   /*                            (`hdmx' table).  This table is optional in */
1385   /*                            TrueType/OpenType fonts.                   */
1386   /*                                                                       */
1387   /*    gasp                 :: The grid-fitting and scaling properties    */
1388   /*                            table (`gasp').  This table is optional in */
1389   /*                            TrueType/OpenType fonts.                   */
1390   /*                                                                       */
1391   /*    pclt                 :: The `pclt' SFNT table.                     */
1392   /*                                                                       */
1393   /*    num_sbit_strikes     :: The number of sbit strikes, i.e., bitmap   */
1394   /*                            sizes, embedded in this font.              */
1395   /*                                                                       */
1396   /*    sbit_strikes         :: An array of sbit strikes embedded in this  */
1397   /*                            font.  This table is optional in a         */
1398   /*                            TrueType/OpenType font.                    */
1399   /*                                                                       */
1400   /*    num_sbit_scales      :: The number of sbit scales for this font.   */
1401   /*                                                                       */
1402   /*    sbit_scales          :: Array of sbit scales embedded in this      */
1403   /*                            font.  This table is optional in a         */
1404   /*                            TrueType/OpenType font.                    */
1405   /*                                                                       */
1406   /*    postscript_names     :: A table used to store the Postscript names */
1407   /*                            of  the glyphs for this font.  See the     */
1408   /*                            file  `ttconfig.h' for comments on the     */
1409   /*                            TT_CONFIG_OPTION_POSTSCRIPT_NAMES option.  */
1410   /*                                                                       */
1411   /*    num_locations        :: The number of glyph locations in this      */
1412   /*                            TrueType file.  This should be             */
1413   /*                            identical to the number of glyphs.         */
1414   /*                            Ignored for Type 2 fonts.                  */
1415   /*                                                                       */
1416   /*    glyph_locations      :: An array of longs.  These are offsets to   */
1417   /*                            glyph data within the `glyf' table.        */
1418   /*                            Ignored for Type 2 font faces.             */
1419   /*                                                                       */
1420   /*    font_program_size    :: Size in bytecodes of the face's font       */
1421   /*                            program.  0 if none defined.  Ignored for  */
1422   /*                            Type 2 fonts.                              */
1423   /*                                                                       */
1424   /*    font_program         :: The face's font program (bytecode stream)  */
1425   /*                            executed at load time, also used during    */
1426   /*                            glyph rendering.  Comes from the `fpgm'    */
1427   /*                            table.  Ignored for Type 2 font fonts.     */
1428   /*                                                                       */
1429   /*    cvt_program_size     :: The size in bytecodes of the face's cvt    */
1430   /*                            program.  Ignored for Type 2 fonts.        */
1431   /*                                                                       */
1432   /*    cvt_program          :: The face's cvt program (bytecode stream)   */
1433   /*                            executed each time an instance/size is     */
1434   /*                            changed/reset.  Comes from the `prep'      */
1435   /*                            table.  Ignored for Type 2 fonts.          */
1436   /*                                                                       */
1437   /*    cvt_size             :: Size of the control value table (in        */
1438   /*                            entries).   Ignored for Type 2 fonts.      */
1439   /*                                                                       */
1440   /*    cvt                  :: The face's original control value table.   */
1441   /*                            Coordinates are expressed in unscaled font */
1442   /*                            units.  Comes from the `cvt ' table.       */
1443   /*                            Ignored for Type 2 fonts.                  */
1444   /*                                                                       */
1445   /*    num_kern_pairs       :: The number of kerning pairs present in the */
1446   /*                            font file.  The engine only loads the      */
1447   /*                            first horizontal format 0 kern table it    */
1448   /*                            finds in the font file.  Ignored for       */
1449   /*                            Type 2 fonts.                              */
1450   /*                                                                       */
1451   /*    kern_table_index     :: The index of the kerning table in the font */
1452   /*                            kerning directory.  Ignored for Type 2     */
1453   /*                            fonts.                                     */
1454   /*                                                                       */
1455   /*    interpreter          :: A pointer to the TrueType bytecode         */
1456   /*                            interpreters field is also used to hook    */
1457   /*                            the debugger in `ttdebug'.                 */
1458   /*                                                                       */
1459   /*    extra                :: Reserved for third-party font drivers.     */
1460   /*                                                                       */
1461   typedef struct  TT_FaceRec_
1462   {
1463     FT_FaceRec            root;
1464
1465     TTC_HeaderRec         ttc_header;
1466
1467     FT_ULong              format_tag;
1468     FT_UShort             num_tables;
1469     TT_Table              dir_tables;
1470
1471     TT_Header             header;       /* TrueType header table          */
1472     TT_HoriHeader         horizontal;   /* TrueType horizontal header     */
1473
1474     TT_MaxProfile         max_profile;
1475     FT_ULong              max_components;
1476
1477     FT_Bool               vertical_info;
1478     TT_VertHeader         vertical;     /* TT Vertical header, if present */
1479
1480     FT_UShort             num_names;    /* number of name records  */
1481     TT_NameTableRec       name_table;   /* name table              */
1482
1483     TT_OS2                os2;          /* TrueType OS/2 table            */
1484     TT_Postscript         postscript;   /* TrueType Postscript table      */
1485
1486     FT_Byte*              cmap_table;   /* extracted 'cmap' table */
1487     FT_ULong              cmap_size;
1488
1489     TT_Loader_GotoTableFunc   goto_table;
1490
1491     TT_Loader_StartGlyphFunc  access_glyph_frame;
1492     TT_Loader_EndGlyphFunc    forget_glyph_frame;
1493     TT_Loader_ReadGlyphFunc   read_glyph_header;
1494     TT_Loader_ReadGlyphFunc   read_simple_glyph;
1495     TT_Loader_ReadGlyphFunc   read_composite_glyph;
1496
1497     /* a typeless pointer to the SFNT_Interface table used to load     */
1498     /* the basic TrueType tables in the face object                    */
1499     void*                 sfnt;
1500
1501     /* a typeless pointer to the PSNames_Interface table used to       */
1502     /* handle glyph names <-> unicode & Mac values                     */
1503     void*                 psnames;
1504
1505     /***********************************************************************/
1506     /*                                                                     */
1507     /* Optional TrueType/OpenType tables                                   */
1508     /*                                                                     */
1509     /***********************************************************************/
1510
1511     /* horizontal device metrics */
1512     TT_HdmxRec            hdmx;
1513
1514     /* grid-fitting and scaling table */
1515     TT_GaspRec            gasp;                 /* the `gasp' table */
1516
1517     /* PCL 5 table */
1518     TT_PCLT               pclt;
1519
1520     /* embedded bitmaps support */
1521     FT_ULong              num_sbit_strikes;
1522     TT_SBit_Strike        sbit_strikes;
1523
1524     FT_ULong              num_sbit_scales;
1525     TT_SBit_Scale         sbit_scales;
1526
1527     /* postscript names table */
1528     TT_Post_NamesRec      postscript_names;
1529
1530
1531     /***********************************************************************/
1532     /*                                                                     */
1533     /* TrueType-specific fields (ignored by the OTF-Type2 driver)          */
1534     /*                                                                     */
1535     /***********************************************************************/
1536
1537     /* the glyph locations */
1538     FT_UShort             num_locations;
1539     FT_Long*              glyph_locations;
1540
1541     /* the font program, if any */
1542     FT_ULong              font_program_size;
1543     FT_Byte*              font_program;
1544
1545     /* the cvt program, if any */
1546     FT_ULong              cvt_program_size;
1547     FT_Byte*              cvt_program;
1548
1549     /* the original, unscaled, control value table */
1550     FT_ULong              cvt_size;
1551     FT_Short*             cvt;
1552
1553     /* the format 0 kerning table, if any */
1554     FT_Int                num_kern_pairs;
1555     FT_Int                kern_table_index;
1556     TT_Kern0_Pair         kern_pairs;
1557
1558     /* A pointer to the bytecode interpreter to use.  This is also */
1559     /* used to hook the debugger for the `ttdebug' utility.        */
1560     TT_Interpreter        interpreter;
1561
1562
1563     /***********************************************************************/
1564     /*                                                                     */
1565     /* Other tables or fields. This is used by derivative formats like     */
1566     /* OpenType.                                                           */
1567     /*                                                                     */
1568     /***********************************************************************/
1569
1570     FT_Generic            extra;
1571
1572   } TT_FaceRec;
1573
1574
1575   /*************************************************************************/
1576   /*                                                                       */
1577   /*  <Struct>                                                             */
1578   /*     TT_GlyphZoneRec                                                   */
1579   /*                                                                       */
1580   /*  <Description>                                                        */
1581   /*     A glyph zone is used to load, scale and hint glyph outline        */
1582   /*     coordinates.                                                      */
1583   /*                                                                       */
1584   /*  <Fields>                                                             */
1585   /*     memory       :: A handle to the memory manager.                   */
1586   /*                                                                       */
1587   /*     max_points   :: The maximal size in points of the zone.           */
1588   /*                                                                       */
1589   /*     max_contours :: Max size in links contours of thez one.           */
1590   /*                                                                       */
1591   /*     n_points     :: The current number of points in the zone.         */
1592   /*                                                                       */
1593   /*     n_contours   :: The current number of contours in the zone.       */
1594   /*                                                                       */
1595   /*     org          :: The original glyph coordinates (font              */
1596   /*                     units/scaled).                                    */
1597   /*                                                                       */
1598   /*     cur          :: The current glyph coordinates (scaled/hinted).    */
1599   /*                                                                       */
1600   /*     tags         :: The point control tags.                           */
1601   /*                                                                       */
1602   /*     contours     :: The contours end points.                          */
1603   /*                                                                       */
1604   typedef struct  TT_GlyphZoneRec_
1605   {
1606     FT_Memory   memory;
1607     FT_UShort   max_points;
1608     FT_UShort   max_contours;
1609     FT_UShort   n_points;   /* number of points in zone    */
1610     FT_Short    n_contours; /* number of contours          */
1611
1612     FT_Vector*  org;        /* original point coordinates  */
1613     FT_Vector*  cur;        /* current point coordinates   */
1614
1615     FT_Byte*    tags;       /* current touch flags         */
1616     FT_UShort*  contours;   /* contour end points          */
1617
1618   } TT_GlyphZoneRec, *TT_GlyphZone;
1619
1620
1621   /* handle to execution context */
1622   typedef struct TT_ExecContextRec_*  TT_ExecContext;
1623
1624   /* glyph loader structure */
1625   typedef struct  TT_LoaderRec_
1626   {
1627     FT_Face          face;
1628     FT_Size          size;
1629     FT_GlyphSlot     glyph;
1630     FT_GlyphLoader   gloader;
1631
1632     FT_ULong         load_flags;
1633     FT_UInt          glyph_index;
1634
1635     FT_Stream        stream;
1636     FT_Int           byte_len;
1637
1638     FT_Short         n_contours;
1639     FT_BBox          bbox;
1640     FT_Int           left_bearing;
1641     FT_Int           advance;
1642     FT_Int           linear;
1643     FT_Bool          linear_def;
1644     FT_Bool          preserve_pps;
1645     FT_Vector        pp1;
1646     FT_Vector        pp2;
1647
1648     FT_ULong         glyf_offset;
1649
1650     /* the zone where we load our glyphs */
1651     TT_GlyphZoneRec  base;
1652     TT_GlyphZoneRec  zone;
1653
1654     TT_ExecContext   exec;
1655     FT_Byte*         instructions;
1656     FT_ULong         ins_pos;
1657
1658     /* for possible extensibility in other formats */
1659     void*            other;
1660
1661   } TT_LoaderRec;
1662
1663
1664 FT_END_HEADER
1665
1666 #endif /* __TTTYPES_H__ */
1667
1668
1669 /* END */