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