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