• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2  *
3  * tttypes.h
4  *
5  *   Basic SFNT/TrueType type definitions and interface (specification
6  *   only).
7  *
8  * Copyright 1996-2018 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 #include FT_COLOR_H
28 
29 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
30 #include FT_MULTIPLE_MASTERS_H
31 #endif
32 
33 
34 FT_BEGIN_HEADER
35 
36 
37   /*************************************************************************/
38   /*************************************************************************/
39   /*************************************************************************/
40   /***                                                                   ***/
41   /***                                                                   ***/
42   /***             REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS         ***/
43   /***                                                                   ***/
44   /***                                                                   ***/
45   /*************************************************************************/
46   /*************************************************************************/
47   /*************************************************************************/
48 
49 
50   /**************************************************************************
51    *
52    * @struct:
53    *   TTC_HeaderRec
54    *
55    * @description:
56    *   TrueType collection header.  This table contains the offsets of
57    *   the font headers of each distinct TrueType face in the file.
58    *
59    * @fields:
60    *   tag ::
61    *     Must be `ttc ' to indicate a TrueType collection.
62    *
63    *   version ::
64    *     The version number.
65    *
66    *   count ::
67    *     The number of faces in the collection.  The
68    *     specification says this should be an unsigned long, but
69    *     we use a signed long since we need the value -1 for
70    *     specific purposes.
71    *
72    *   offsets ::
73    *     The offsets of the font headers, one per face.
74    */
75   typedef struct  TTC_HeaderRec_
76   {
77     FT_ULong   tag;
78     FT_Fixed   version;
79     FT_Long    count;
80     FT_ULong*  offsets;
81 
82   } TTC_HeaderRec;
83 
84 
85   /**************************************************************************
86    *
87    * @struct:
88    *   SFNT_HeaderRec
89    *
90    * @description:
91    *   SFNT file format header.
92    *
93    * @fields:
94    *   format_tag ::
95    *     The font format tag.
96    *
97    *   num_tables ::
98    *     The number of tables in file.
99    *
100    *   search_range ::
101    *     Must be `16 * (max power of 2 <= num_tables)'.
102    *
103    *   entry_selector ::
104    *     Must be log2 of `search_range / 16'.
105    *
106    *   range_shift ::
107    *     Must be `num_tables * 16 - search_range'.
108    */
109   typedef struct  SFNT_HeaderRec_
110   {
111     FT_ULong   format_tag;
112     FT_UShort  num_tables;
113     FT_UShort  search_range;
114     FT_UShort  entry_selector;
115     FT_UShort  range_shift;
116 
117     FT_ULong   offset;  /* not in file */
118 
119   } SFNT_HeaderRec, *SFNT_Header;
120 
121 
122   /**************************************************************************
123    *
124    * @struct:
125    *   TT_TableRec
126    *
127    * @description:
128    *   This structure describes a given table of a TrueType font.
129    *
130    * @fields:
131    *   Tag ::
132    *     A four-bytes tag describing the table.
133    *
134    *   CheckSum ::
135    *     The table checksum.  This value can be ignored.
136    *
137    *   Offset ::
138    *     The offset of the table from the start of the TrueType
139    *     font in its resource.
140    *
141    *   Length ::
142    *     The table length (in bytes).
143    */
144   typedef struct  TT_TableRec_
145   {
146     FT_ULong  Tag;        /*        table type */
147     FT_ULong  CheckSum;   /*    table checksum */
148     FT_ULong  Offset;     /* table file offset */
149     FT_ULong  Length;     /*      table length */
150 
151   } TT_TableRec, *TT_Table;
152 
153 
154   /**************************************************************************
155    *
156    * @struct:
157    *   WOFF_HeaderRec
158    *
159    * @description:
160    *   WOFF file format header.
161    *
162    * @fields:
163    *   See
164    *
165    *     https://www.w3.org/TR/WOFF/#WOFFHeader
166    */
167   typedef struct  WOFF_HeaderRec_
168   {
169     FT_ULong   signature;
170     FT_ULong   flavor;
171     FT_ULong   length;
172     FT_UShort  num_tables;
173     FT_UShort  reserved;
174     FT_ULong   totalSfntSize;
175     FT_UShort  majorVersion;
176     FT_UShort  minorVersion;
177     FT_ULong   metaOffset;
178     FT_ULong   metaLength;
179     FT_ULong   metaOrigLength;
180     FT_ULong   privOffset;
181     FT_ULong   privLength;
182 
183   } WOFF_HeaderRec, *WOFF_Header;
184 
185 
186   /**************************************************************************
187    *
188    * @struct:
189    *   WOFF_TableRec
190    *
191    * @description:
192    *   This structure describes a given table of a WOFF font.
193    *
194    * @fields:
195    *   Tag ::
196    *     A four-bytes tag describing the table.
197    *
198    *   Offset ::
199    *     The offset of the table from the start of the WOFF
200    *     font in its resource.
201    *
202    *   CompLength ::
203    *     Compressed table length (in bytes).
204    *
205    *   OrigLength ::
206    *     Uncompressed table length (in bytes).
207    *
208    *   CheckSum ::
209    *     The table checksum.  This value can be ignored.
210    *
211    *   OrigOffset ::
212    *     The uncompressed table file offset.  This value gets
213    *     computed while constructing the (uncompressed) SFNT
214    *     header.  It is not contained in the WOFF file.
215    */
216   typedef struct  WOFF_TableRec_
217   {
218     FT_ULong  Tag;           /* table ID                  */
219     FT_ULong  Offset;        /* table file offset         */
220     FT_ULong  CompLength;    /* compressed table length   */
221     FT_ULong  OrigLength;    /* uncompressed table length */
222     FT_ULong  CheckSum;      /* uncompressed checksum     */
223 
224     FT_ULong  OrigOffset;    /* uncompressed table file offset */
225                              /* (not in the WOFF file)         */
226   } WOFF_TableRec, *WOFF_Table;
227 
228 
229   /**************************************************************************
230    *
231    * @struct:
232    *   TT_LongMetricsRec
233    *
234    * @description:
235    *   A structure modeling the long metrics of the `hmtx' and `vmtx'
236    *   TrueType tables.  The values are expressed in font units.
237    *
238    * @fields:
239    *   advance ::
240    *     The advance width or height for the glyph.
241    *
242    *   bearing ::
243    *     The left-side or top-side bearing for the glyph.
244    */
245   typedef struct  TT_LongMetricsRec_
246   {
247     FT_UShort  advance;
248     FT_Short   bearing;
249 
250   } TT_LongMetricsRec, *TT_LongMetrics;
251 
252 
253   /**************************************************************************
254    *
255    * @type:
256    *   TT_ShortMetrics
257    *
258    * @description:
259    *   A simple type to model the short metrics of the `hmtx' and `vmtx'
260    *   tables.
261    */
262   typedef FT_Short  TT_ShortMetrics;
263 
264 
265   /**************************************************************************
266    *
267    * @struct:
268    *   TT_NameRec
269    *
270    * @description:
271    *   A structure modeling TrueType name records.  Name records are used
272    *   to store important strings like family name, style name,
273    *   copyright, etc. in _localized_ versions (i.e., language, encoding,
274    *   etc).
275    *
276    * @fields:
277    *   platformID ::
278    *     The ID of the name's encoding platform.
279    *
280    *   encodingID ::
281    *     The platform-specific ID for the name's encoding.
282    *
283    *   languageID ::
284    *     The platform-specific ID for the name's language.
285    *
286    *   nameID ::
287    *     The ID specifying what kind of name this is.
288    *
289    *   stringLength ::
290    *     The length of the string in bytes.
291    *
292    *   stringOffset ::
293    *     The offset to the string in the `name' table.
294    *
295    *   string ::
296    *     A pointer to the string's bytes.  Note that these
297    *     are usually UTF-16 encoded characters.
298    */
299   typedef struct  TT_NameRec_
300   {
301     FT_UShort  platformID;
302     FT_UShort  encodingID;
303     FT_UShort  languageID;
304     FT_UShort  nameID;
305     FT_UShort  stringLength;
306     FT_ULong   stringOffset;
307 
308     /* this last field is not defined in the spec */
309     /* but used by the FreeType engine            */
310 
311     FT_Byte*  string;
312 
313   } TT_NameRec, *TT_Name;
314 
315 
316   /**************************************************************************
317    *
318    * @struct:
319    *   TT_LangTagRec
320    *
321    * @description:
322    *   A structure modeling language tag records in SFNT `name' tables,
323    *   introduced in OpenType version 1.6.
324    *
325    * @fields:
326    *   stringLength ::
327    *     The length of the string in bytes.
328    *
329    *   stringOffset ::
330    *     The offset to the string in the `name' table.
331    *
332    *   string ::
333    *     A pointer to the string's bytes.  Note that these
334    *     are UTF-16BE encoded characters.
335    */
336   typedef struct TT_LangTagRec_
337   {
338     FT_UShort  stringLength;
339     FT_ULong   stringOffset;
340 
341     /* this last field is not defined in the spec */
342     /* but used by the FreeType engine            */
343 
344     FT_Byte*  string;
345 
346   } TT_LangTagRec, *TT_LangTag;
347 
348 
349   /**************************************************************************
350    *
351    * @struct:
352    *   TT_NameTableRec
353    *
354    * @description:
355    *   A structure modeling the TrueType name table.
356    *
357    * @fields:
358    *   format ::
359    *     The format of the name table.
360    *
361    *   numNameRecords ::
362    *     The number of names in table.
363    *
364    *   storageOffset ::
365    *     The offset of the name table in the `name'
366    *     TrueType table.
367    *
368    *   names ::
369    *     An array of name records.
370    *
371    *   numLangTagRecords ::
372    *     The number of language tags in table.
373    *
374    *   langTags ::
375    *     An array of language tag records.
376    *
377    *   stream ::
378    *     The file's input stream.
379    */
380   typedef struct  TT_NameTableRec_
381   {
382     FT_UShort       format;
383     FT_UInt         numNameRecords;
384     FT_UInt         storageOffset;
385     TT_NameRec*     names;
386     FT_UInt         numLangTagRecords;
387     TT_LangTagRec*  langTags;
388     FT_Stream       stream;
389 
390   } TT_NameTableRec, *TT_NameTable;
391 
392 
393   /*************************************************************************/
394   /*************************************************************************/
395   /*************************************************************************/
396   /***                                                                   ***/
397   /***                                                                   ***/
398   /***             OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS         ***/
399   /***                                                                   ***/
400   /***                                                                   ***/
401   /*************************************************************************/
402   /*************************************************************************/
403   /*************************************************************************/
404 
405 
406   /**************************************************************************
407    *
408    * @struct:
409    *   TT_GaspRangeRec
410    *
411    * @description:
412    *   A tiny structure used to model a gasp range according to the
413    *   TrueType specification.
414    *
415    * @fields:
416    *   maxPPEM ::
417    *     The maximum ppem value to which `gaspFlag' applies.
418    *
419    *   gaspFlag ::
420    *     A flag describing the grid-fitting and anti-aliasing
421    *     modes to be used.
422    */
423   typedef struct  TT_GaspRangeRec_
424   {
425     FT_UShort  maxPPEM;
426     FT_UShort  gaspFlag;
427 
428   } TT_GaspRangeRec, *TT_GaspRange;
429 
430 
431 #define TT_GASP_GRIDFIT  0x01
432 #define TT_GASP_DOGRAY   0x02
433 
434 
435   /**************************************************************************
436    *
437    * @struct:
438    *   TT_GaspRec
439    *
440    * @description:
441    *   A structure modeling the TrueType `gasp' table used to specify
442    *   grid-fitting and anti-aliasing behaviour.
443    *
444    * @fields:
445    *   version ::
446    *     The version number.
447    *
448    *   numRanges ::
449    *     The number of gasp ranges in table.
450    *
451    *   gaspRanges ::
452    *     An array of gasp ranges.
453    */
454   typedef struct  TT_Gasp_
455   {
456     FT_UShort     version;
457     FT_UShort     numRanges;
458     TT_GaspRange  gaspRanges;
459 
460   } TT_GaspRec;
461 
462 
463   /*************************************************************************/
464   /*************************************************************************/
465   /*************************************************************************/
466   /***                                                                   ***/
467   /***                                                                   ***/
468   /***                    EMBEDDED BITMAPS SUPPORT                       ***/
469   /***                                                                   ***/
470   /***                                                                   ***/
471   /*************************************************************************/
472   /*************************************************************************/
473   /*************************************************************************/
474 
475 
476   /**************************************************************************
477    *
478    * @struct:
479    *   TT_SBit_MetricsRec
480    *
481    * @description:
482    *   A structure used to hold the big metrics of a given glyph bitmap
483    *   in a TrueType or OpenType font.  These are usually found in the
484    *   `EBDT' (Microsoft) or `bloc' (Apple) table.
485    *
486    * @fields:
487    *   height ::
488    *     The glyph height in pixels.
489    *
490    *   width ::
491    *     The glyph width in pixels.
492    *
493    *   horiBearingX ::
494    *     The horizontal left bearing.
495    *
496    *   horiBearingY ::
497    *     The horizontal top bearing.
498    *
499    *   horiAdvance ::
500    *     The horizontal advance.
501    *
502    *   vertBearingX ::
503    *     The vertical left bearing.
504    *
505    *   vertBearingY ::
506    *     The vertical top bearing.
507    *
508    *   vertAdvance ::
509    *     The vertical advance.
510    */
511   typedef struct  TT_SBit_MetricsRec_
512   {
513     FT_UShort  height;
514     FT_UShort  width;
515 
516     FT_Short   horiBearingX;
517     FT_Short   horiBearingY;
518     FT_UShort  horiAdvance;
519 
520     FT_Short   vertBearingX;
521     FT_Short   vertBearingY;
522     FT_UShort  vertAdvance;
523 
524   } TT_SBit_MetricsRec, *TT_SBit_Metrics;
525 
526 
527   /**************************************************************************
528    *
529    * @struct:
530    *   TT_SBit_SmallMetricsRec
531    *
532    * @description:
533    *   A structure used to hold the small metrics of a given glyph bitmap
534    *   in a TrueType or OpenType font.  These are usually found in the
535    *   `EBDT' (Microsoft) or the `bdat' (Apple) table.
536    *
537    * @fields:
538    *   height ::
539    *     The glyph height in pixels.
540    *
541    *   width ::
542    *     The glyph width in pixels.
543    *
544    *   bearingX ::
545    *     The left-side bearing.
546    *
547    *   bearingY ::
548    *     The top-side bearing.
549    *
550    *   advance ::
551    *     The advance width or height.
552    */
553   typedef struct  TT_SBit_Small_Metrics_
554   {
555     FT_Byte  height;
556     FT_Byte  width;
557 
558     FT_Char  bearingX;
559     FT_Char  bearingY;
560     FT_Byte  advance;
561 
562   } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics;
563 
564 
565   /**************************************************************************
566    *
567    * @struct:
568    *   TT_SBit_LineMetricsRec
569    *
570    * @description:
571    *   A structure used to describe the text line metrics of a given
572    *   bitmap strike, for either a horizontal or vertical layout.
573    *
574    * @fields:
575    *   ascender ::
576    *     The ascender in pixels.
577    *
578    *   descender ::
579    *     The descender in pixels.
580    *
581    *   max_width ::
582    *     The maximum glyph width in pixels.
583    *
584    *   caret_slope_enumerator ::
585    *     Rise of the caret slope, typically set
586    *     to 1 for non-italic fonts.
587    *
588    *   caret_slope_denominator ::
589    *     Rise of the caret slope, typically set
590    *     to 0 for non-italic fonts.
591    *
592    *   caret_offset ::
593    *     Offset in pixels to move the caret for
594    *     proper positioning.
595    *
596    *   min_origin_SB ::
597    *     Minimum of horiBearingX (resp.
598    *     vertBearingY).
599    *   min_advance_SB ::
600    *     Minimum of
601    *
602    *     horizontal advance -
603    *     ( horiBearingX + width )
604    *
605    *     resp.
606    *
607    *     vertical advance -
608    *     ( vertBearingY + height )
609    *
610    *   max_before_BL ::
611    *     Maximum of horiBearingY (resp.
612    *     vertBearingY).
613    *
614    *   min_after_BL ::
615    *     Minimum of
616    *
617    *     horiBearingY - height
618    *
619    *     resp.
620    *
621    *     vertBearingX - width
622    *
623    *   pads ::
624    *     Unused (to make the size of the record
625    *     a multiple of 32 bits.
626    */
627   typedef struct  TT_SBit_LineMetricsRec_
628   {
629     FT_Char  ascender;
630     FT_Char  descender;
631     FT_Byte  max_width;
632     FT_Char  caret_slope_numerator;
633     FT_Char  caret_slope_denominator;
634     FT_Char  caret_offset;
635     FT_Char  min_origin_SB;
636     FT_Char  min_advance_SB;
637     FT_Char  max_before_BL;
638     FT_Char  min_after_BL;
639     FT_Char  pads[2];
640 
641   } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics;
642 
643 
644   /**************************************************************************
645    *
646    * @struct:
647    *   TT_SBit_RangeRec
648    *
649    * @description:
650    *   A TrueType/OpenType subIndexTable as defined in the `EBLC'
651    *   (Microsoft) or `bloc' (Apple) tables.
652    *
653    * @fields:
654    *   first_glyph ::
655    *     The first glyph index in the range.
656    *
657    *   last_glyph ::
658    *     The last glyph index in the range.
659    *
660    *   index_format ::
661    *     The format of index table.  Valid values are 1
662    *     to 5.
663    *
664    *   image_format ::
665    *     The format of `EBDT' image data.
666    *
667    *   image_offset ::
668    *     The offset to image data in `EBDT'.
669    *
670    *   image_size ::
671    *     For index formats 2 and 5.  This is the size in
672    *     bytes of each glyph bitmap.
673    *
674    *   big_metrics ::
675    *     For index formats 2 and 5.  This is the big
676    *     metrics for each glyph bitmap.
677    *
678    *   num_glyphs ::
679    *     For index formats 4 and 5.  This is the number of
680    *     glyphs in the code array.
681    *
682    *   glyph_offsets ::
683    *     For index formats 1 and 3.
684    *
685    *   glyph_codes ::
686    *     For index formats 4 and 5.
687    *
688    *   table_offset ::
689    *     The offset of the index table in the `EBLC'
690    *     table.  Only used during strike loading.
691    */
692   typedef struct  TT_SBit_RangeRec_
693   {
694     FT_UShort           first_glyph;
695     FT_UShort           last_glyph;
696 
697     FT_UShort           index_format;
698     FT_UShort           image_format;
699     FT_ULong            image_offset;
700 
701     FT_ULong            image_size;
702     TT_SBit_MetricsRec  metrics;
703     FT_ULong            num_glyphs;
704 
705     FT_ULong*           glyph_offsets;
706     FT_UShort*          glyph_codes;
707 
708     FT_ULong            table_offset;
709 
710   } TT_SBit_RangeRec, *TT_SBit_Range;
711 
712 
713   /**************************************************************************
714    *
715    * @struct:
716    *   TT_SBit_StrikeRec
717    *
718    * @description:
719    *   A structure used describe a given bitmap strike in the `EBLC'
720    *   (Microsoft) or `bloc' (Apple) tables.
721    *
722    * @fields:
723    *  num_index_ranges ::
724    *    The number of index ranges.
725    *
726    *  index_ranges ::
727    *    An array of glyph index ranges.
728    *
729    *  color_ref ::
730    *    Unused.  `color_ref' is put in for future
731    *    enhancements, but these fields are already
732    *    in use by other platforms (e.g. Newton).
733    *    For details, please see
734    *
735    *    https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html
736    *
737    *  hori ::
738    *    The line metrics for horizontal layouts.
739    *
740    *  vert ::
741    *    The line metrics for vertical layouts.
742    *
743    *  start_glyph ::
744    *    The lowest glyph index for this strike.
745    *
746    *  end_glyph ::
747    *    The highest glyph index for this strike.
748    *
749    *  x_ppem ::
750    *    The number of horizontal pixels per EM.
751    *
752    *  y_ppem ::
753    *    The number of vertical pixels per EM.
754    *
755    *  bit_depth ::
756    *    The bit depth.  Valid values are 1, 2, 4,
757    *    and 8.
758    *
759    *  flags ::
760    *    Is this a vertical or horizontal strike?  For
761    *    details, please see
762    *
763    *    https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html
764    */
765   typedef struct  TT_SBit_StrikeRec_
766   {
767     FT_Int                  num_ranges;
768     TT_SBit_Range           sbit_ranges;
769     FT_ULong                ranges_offset;
770 
771     FT_ULong                color_ref;
772 
773     TT_SBit_LineMetricsRec  hori;
774     TT_SBit_LineMetricsRec  vert;
775 
776     FT_UShort               start_glyph;
777     FT_UShort               end_glyph;
778 
779     FT_Byte                 x_ppem;
780     FT_Byte                 y_ppem;
781 
782     FT_Byte                 bit_depth;
783     FT_Char                 flags;
784 
785   } TT_SBit_StrikeRec, *TT_SBit_Strike;
786 
787 
788   /**************************************************************************
789    *
790    * @struct:
791    *   TT_SBit_ComponentRec
792    *
793    * @description:
794    *   A simple structure to describe a compound sbit element.
795    *
796    * @fields:
797    *   glyph_code ::
798    *     The element's glyph index.
799    *
800    *   x_offset ::
801    *     The element's left bearing.
802    *
803    *   y_offset ::
804    *     The element's top bearing.
805    */
806   typedef struct  TT_SBit_ComponentRec_
807   {
808     FT_UShort  glyph_code;
809     FT_Char    x_offset;
810     FT_Char    y_offset;
811 
812   } TT_SBit_ComponentRec, *TT_SBit_Component;
813 
814 
815   /**************************************************************************
816    *
817    * @struct:
818    *   TT_SBit_ScaleRec
819    *
820    * @description:
821    *   A structure used describe a given bitmap scaling table, as defined
822    *   in the `EBSC' table.
823    *
824    * @fields:
825    *   hori ::
826    *     The horizontal line metrics.
827    *
828    *   vert ::
829    *     The vertical line metrics.
830    *
831    *   x_ppem ::
832    *     The number of horizontal pixels per EM.
833    *
834    *   y_ppem ::
835    *     The number of vertical pixels per EM.
836    *
837    *   x_ppem_substitute ::
838    *     Substitution x_ppem value.
839    *
840    *   y_ppem_substitute ::
841    *     Substitution y_ppem value.
842    */
843   typedef struct  TT_SBit_ScaleRec_
844   {
845     TT_SBit_LineMetricsRec  hori;
846     TT_SBit_LineMetricsRec  vert;
847 
848     FT_Byte                 x_ppem;
849     FT_Byte                 y_ppem;
850 
851     FT_Byte                 x_ppem_substitute;
852     FT_Byte                 y_ppem_substitute;
853 
854   } TT_SBit_ScaleRec, *TT_SBit_Scale;
855 
856 
857   /*************************************************************************/
858   /*************************************************************************/
859   /*************************************************************************/
860   /***                                                                   ***/
861   /***                                                                   ***/
862   /***                  POSTSCRIPT GLYPH NAMES SUPPORT                   ***/
863   /***                                                                   ***/
864   /***                                                                   ***/
865   /*************************************************************************/
866   /*************************************************************************/
867   /*************************************************************************/
868 
869 
870   /**************************************************************************
871    *
872    * @struct:
873    *   TT_Post_20Rec
874    *
875    * @description:
876    *   Postscript names sub-table, format 2.0.  Stores the PS name of
877    *   each glyph in the font face.
878    *
879    * @fields:
880    *   num_glyphs ::
881    *     The number of named glyphs in the table.
882    *
883    *   num_names ::
884    *     The number of PS names stored in the table.
885    *
886    *   glyph_indices ::
887    *     The indices of the glyphs in the names arrays.
888    *
889    *   glyph_names ::
890    *     The PS names not in Mac Encoding.
891    */
892   typedef struct  TT_Post_20Rec_
893   {
894     FT_UShort   num_glyphs;
895     FT_UShort   num_names;
896     FT_UShort*  glyph_indices;
897     FT_Char**   glyph_names;
898 
899   } TT_Post_20Rec, *TT_Post_20;
900 
901 
902   /**************************************************************************
903    *
904    * @struct:
905    *   TT_Post_25Rec
906    *
907    * @description:
908    *   Postscript names sub-table, format 2.5.  Stores the PS name of
909    *   each glyph in the font face.
910    *
911    * @fields:
912    *   num_glyphs ::
913    *     The number of glyphs in the table.
914    *
915    *   offsets ::
916    *     An array of signed offsets in a normal Mac
917    *     Postscript name encoding.
918    */
919   typedef struct  TT_Post_25_
920   {
921     FT_UShort  num_glyphs;
922     FT_Char*   offsets;
923 
924   } TT_Post_25Rec, *TT_Post_25;
925 
926 
927   /**************************************************************************
928    *
929    * @struct:
930    *   TT_Post_NamesRec
931    *
932    * @description:
933    *   Postscript names table, either format 2.0 or 2.5.
934    *
935    * @fields:
936    *   loaded ::
937    *     A flag to indicate whether the PS names are loaded.
938    *
939    *   format_20 ::
940    *     The sub-table used for format 2.0.
941    *
942    *   format_25 ::
943    *     The sub-table used for format 2.5.
944    */
945   typedef struct  TT_Post_NamesRec_
946   {
947     FT_Bool  loaded;
948 
949     union
950     {
951       TT_Post_20Rec  format_20;
952       TT_Post_25Rec  format_25;
953 
954     } names;
955 
956   } TT_Post_NamesRec, *TT_Post_Names;
957 
958 
959   /*************************************************************************/
960   /*************************************************************************/
961   /*************************************************************************/
962   /***                                                                   ***/
963   /***                                                                   ***/
964   /***                    GX VARIATION TABLE SUPPORT                     ***/
965   /***                                                                   ***/
966   /***                                                                   ***/
967   /*************************************************************************/
968   /*************************************************************************/
969   /*************************************************************************/
970 
971 
972 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
973   typedef struct GX_BlendRec_  *GX_Blend;
974 #endif
975 
976   /*************************************************************************/
977   /*************************************************************************/
978   /*************************************************************************/
979   /***                                                                   ***/
980   /***                                                                   ***/
981   /***              EMBEDDED BDF PROPERTIES TABLE SUPPORT                ***/
982   /***                                                                   ***/
983   /***                                                                   ***/
984   /*************************************************************************/
985   /*************************************************************************/
986   /*************************************************************************/
987 
988   /*
989    * These types are used to support a `BDF ' table that isn't part of the
990    * official TrueType specification.  It is mainly used in SFNT-based
991    * bitmap fonts that were generated from a set of BDF fonts.
992    *
993    * The format of the table is as follows.
994    *
995    *   USHORT   version      `BDF ' table version number, should be 0x0001.
996    *   USHORT   strikeCount  Number of strikes (bitmap sizes) in this table.
997    *   ULONG    stringTable  Offset (from start of BDF table) to string
998    *                         table.
999    *
1000    * This is followed by an array of `strikeCount' descriptors, having the
1001    * following format.
1002    *
1003    *   USHORT   ppem         Vertical pixels per EM for this strike.
1004    *   USHORT   numItems     Number of items for this strike (properties and
1005    *                         atoms).  Maximum is 255.
1006    *
1007    * This array in turn is followed by `strikeCount' value sets.  Each
1008    * `value set' is an array of `numItems' items with the following format.
1009    *
1010    *   ULONG    item_name    Offset in string table to item name.
1011    *   USHORT   item_type    The item type.  Possible values are
1012    *                            0 => string (e.g., COMMENT)
1013    *                            1 => atom   (e.g., FONT or even SIZE)
1014    *                            2 => int32
1015    *                            3 => uint32
1016    *                         0x10 => A flag to indicate a properties.  This
1017    *                                 is ORed with the above values.
1018    *   ULONG    item_value   For strings  => Offset into string table without
1019    *                                         the corresponding double quotes.
1020    *                         For atoms    => Offset into string table.
1021    *                         For integers => Direct value.
1022    *
1023    * All strings in the string table consist of bytes and are
1024    * zero-terminated.
1025    *
1026    */
1027 
1028 #ifdef TT_CONFIG_OPTION_BDF
1029 
1030   typedef struct  TT_BDFRec_
1031   {
1032     FT_Byte*   table;
1033     FT_Byte*   table_end;
1034     FT_Byte*   strings;
1035     FT_ULong   strings_size;
1036     FT_UInt    num_strikes;
1037     FT_Bool    loaded;
1038 
1039   } TT_BDFRec, *TT_BDF;
1040 
1041 #endif /* TT_CONFIG_OPTION_BDF */
1042 
1043   /*************************************************************************/
1044   /*************************************************************************/
1045   /*************************************************************************/
1046   /***                                                                   ***/
1047   /***                                                                   ***/
1048   /***                  ORIGINAL TT_FACE CLASS DEFINITION                ***/
1049   /***                                                                   ***/
1050   /***                                                                   ***/
1051   /*************************************************************************/
1052   /*************************************************************************/
1053   /*************************************************************************/
1054 
1055 
1056   /**************************************************************************
1057    *
1058    * This structure/class is defined here because it is common to the
1059    * following formats: TTF, OpenType-TT, and OpenType-CFF.
1060    *
1061    * Note, however, that the classes TT_Size and TT_GlyphSlot are not
1062    * shared between font drivers, and are thus defined in `ttobjs.h'.
1063    *
1064    */
1065 
1066 
1067   /**************************************************************************
1068    *
1069    * @type:
1070    *   TT_Face
1071    *
1072    * @description:
1073    *   A handle to a TrueType face/font object.  A TT_Face encapsulates
1074    *   the resolution and scaling independent parts of a TrueType font
1075    *   resource.
1076    *
1077    * @note:
1078    *   The TT_Face structure is also used as a `parent class' for the
1079    *   OpenType-CFF class (T2_Face).
1080    */
1081   typedef struct TT_FaceRec_*  TT_Face;
1082 
1083 
1084   /* a function type used for the truetype bytecode interpreter hooks */
1085   typedef FT_Error
1086   (*TT_Interpreter)( void*  exec_context );
1087 
1088   /* forward declaration */
1089   typedef struct TT_LoaderRec_*  TT_Loader;
1090 
1091 
1092   /**************************************************************************
1093    *
1094    * @functype:
1095    *   TT_Loader_GotoTableFunc
1096    *
1097    * @description:
1098    *   Seeks a stream to the start of a given TrueType table.
1099    *
1100    * @input:
1101    *   face ::
1102    *     A handle to the target face object.
1103    *
1104    *   tag ::
1105    *     A 4-byte tag used to name the table.
1106    *
1107    *   stream ::
1108    *     The input stream.
1109    *
1110    * @output:
1111    *   length ::
1112    *     The length of the table in bytes.  Set to 0 if not
1113    *     needed.
1114    *
1115    * @return:
1116    *   FreeType error code.  0 means success.
1117    *
1118    * @note:
1119    *   The stream cursor must be at the font file's origin.
1120    */
1121   typedef FT_Error
1122   (*TT_Loader_GotoTableFunc)( TT_Face    face,
1123                               FT_ULong   tag,
1124                               FT_Stream  stream,
1125                               FT_ULong*  length );
1126 
1127 
1128   /**************************************************************************
1129    *
1130    * @functype:
1131    *   TT_Loader_StartGlyphFunc
1132    *
1133    * @description:
1134    *   Seeks a stream to the start of a given glyph element, and opens a
1135    *   frame for it.
1136    *
1137    * @input:
1138    *   loader ::
1139    *     The current TrueType glyph loader object.
1140    *
1141    *     glyph index :: The index of the glyph to access.
1142    *
1143    *   offset ::
1144    *     The offset of the glyph according to the
1145    *     `locations' table.
1146    *
1147    *   byte_count ::
1148    *     The size of the frame in bytes.
1149    *
1150    * @return:
1151    *   FreeType error code.  0 means success.
1152    *
1153    * @note:
1154    *   This function is normally equivalent to FT_STREAM_SEEK(offset)
1155    *   followed by FT_FRAME_ENTER(byte_count) with the loader's stream,
1156    *   but alternative formats (e.g. compressed ones) might use something
1157    *   different.
1158    */
1159   typedef FT_Error
1160   (*TT_Loader_StartGlyphFunc)( TT_Loader  loader,
1161                                FT_UInt    glyph_index,
1162                                FT_ULong   offset,
1163                                FT_UInt    byte_count );
1164 
1165 
1166   /**************************************************************************
1167    *
1168    * @functype:
1169    *   TT_Loader_ReadGlyphFunc
1170    *
1171    * @description:
1172    *   Reads one glyph element (its header, a simple glyph, or a
1173    *   composite) from the loader's current stream frame.
1174    *
1175    * @input:
1176    *   loader ::
1177    *     The current TrueType glyph loader object.
1178    *
1179    * @return:
1180    *   FreeType error code.  0 means success.
1181    */
1182   typedef FT_Error
1183   (*TT_Loader_ReadGlyphFunc)( TT_Loader  loader );
1184 
1185 
1186   /**************************************************************************
1187    *
1188    * @functype:
1189    *   TT_Loader_EndGlyphFunc
1190    *
1191    * @description:
1192    *   Closes the current loader stream frame for the glyph.
1193    *
1194    * @input:
1195    *   loader ::
1196    *     The current TrueType glyph loader object.
1197    */
1198   typedef void
1199   (*TT_Loader_EndGlyphFunc)( TT_Loader  loader );
1200 
1201 
1202   typedef enum TT_SbitTableType_
1203   {
1204     TT_SBIT_TABLE_TYPE_NONE = 0,
1205     TT_SBIT_TABLE_TYPE_EBLC, /* `EBLC' (Microsoft), */
1206                              /* `bloc' (Apple)      */
1207     TT_SBIT_TABLE_TYPE_CBLC, /* `CBLC' (Google)     */
1208     TT_SBIT_TABLE_TYPE_SBIX, /* `sbix' (Apple)      */
1209 
1210     /* do not remove */
1211     TT_SBIT_TABLE_TYPE_MAX
1212 
1213   } TT_SbitTableType;
1214 
1215 
1216   /* OpenType 1.8 brings new tables for variation font support;  */
1217   /* to make the old MM and GX fonts still work we need to check */
1218   /* the presence (and validity) of the functionality provided   */
1219   /* by those tables.  The following flag macros are for the     */
1220   /* field `variation_support'.                                  */
1221   /*                                                             */
1222   /* Note that `fvar' gets checked immediately at font loading,  */
1223   /* while the other features are only loaded if MM support is   */
1224   /* actually requested.                                         */
1225 
1226   /* FVAR */
1227 #define TT_FACE_FLAG_VAR_FVAR  ( 1 << 0 )
1228 
1229   /* HVAR */
1230 #define TT_FACE_FLAG_VAR_HADVANCE  ( 1 << 1 )
1231 #define TT_FACE_FLAG_VAR_LSB       ( 1 << 2 )
1232 #define TT_FACE_FLAG_VAR_RSB       ( 1 << 3 )
1233 
1234   /* VVAR */
1235 #define TT_FACE_FLAG_VAR_VADVANCE  ( 1 << 4 )
1236 #define TT_FACE_FLAG_VAR_TSB       ( 1 << 5 )
1237 #define TT_FACE_FLAG_VAR_BSB       ( 1 << 6 )
1238 #define TT_FACE_FLAG_VAR_VORG      ( 1 << 7 )
1239 
1240   /* MVAR */
1241 #define TT_FACE_FLAG_VAR_MVAR  ( 1 << 8 )
1242 
1243 
1244   /**************************************************************************
1245    *
1246    *                        TrueType Face Type
1247    *
1248    * @struct:
1249    *   TT_Face
1250    *
1251    * @description:
1252    *   The TrueType face class.  These objects model the resolution and
1253    *   point-size independent data found in a TrueType font file.
1254    *
1255    * @fields:
1256    *   root ::
1257    *     The base FT_Face structure, managed by the
1258    *     base layer.
1259    *
1260    *   ttc_header ::
1261    *     The TrueType collection header, used when
1262    *     the file is a `ttc' rather than a `ttf'.
1263    *     For ordinary font files, the field
1264    *     `ttc_header.count' is set to 0.
1265    *
1266    *   format_tag ::
1267    *     The font format tag.
1268    *
1269    *   num_tables ::
1270    *     The number of TrueType tables in this font
1271    *     file.
1272    *
1273    *   dir_tables ::
1274    *     The directory of TrueType tables for this
1275    *     font file.
1276    *
1277    *   header ::
1278    *     The font's font header (`head' table).
1279    *     Read on font opening.
1280    *
1281    *   horizontal ::
1282    *     The font's horizontal header (`hhea'
1283    *     table).  This field also contains the
1284    *     associated horizontal metrics table
1285    *     (`hmtx').
1286    *
1287    *   max_profile ::
1288    *     The font's maximum profile table.  Read on
1289    *     font opening.  Note that some maximum
1290    *     values cannot be taken directly from this
1291    *     table.  We thus define additional fields
1292    *     below to hold the computed maxima.
1293    *
1294    *   vertical_info ::
1295    *     A boolean which is set when the font file
1296    *     contains vertical metrics.  If not, the
1297    *     value of the `vertical' field is
1298    *     undefined.
1299    *
1300    *   vertical ::
1301    *     The font's vertical header (`vhea' table).
1302    *     This field also contains the associated
1303    *     vertical metrics table (`vmtx'), if found.
1304    *     IMPORTANT: The contents of this field is
1305    *     undefined if the `vertical_info' field is
1306    *     unset.
1307    *
1308    *   num_names ::
1309    *     The number of name records within this
1310    *     TrueType font.
1311    *
1312    *   name_table ::
1313    *     The table of name records (`name').
1314    *
1315    *   os2 ::
1316    *     The font's OS/2 table (`OS/2').
1317    *
1318    *   postscript ::
1319    *     The font's PostScript table (`post'
1320    *     table).  The PostScript glyph names are
1321    *     not loaded by the driver on face opening.
1322    *     See the `ttpost' module for more details.
1323    *
1324    *   cmap_table ::
1325    *     Address of the face's `cmap' SFNT table
1326    *     in memory (it's an extracted frame).
1327    *
1328    *   cmap_size ::
1329    *     The size in bytes of the `cmap_table'
1330    *     described above.
1331    *
1332    *   goto_table ::
1333    *     A function called by each TrueType table
1334    *     loader to position a stream's cursor to
1335    *     the start of a given table according to
1336    *     its tag.  It defaults to TT_Goto_Face but
1337    *     can be different for strange formats (e.g.
1338    *     Type 42).
1339    *
1340    *   access_glyph_frame ::
1341    *     A function used to access the frame of a
1342    *     given glyph within the face's font file.
1343    *
1344    *   forget_glyph_frame ::
1345    *     A function used to forget the frame of a
1346    *     given glyph when all data has been loaded.
1347    *
1348    *   read_glyph_header ::
1349    *     A function used to read a glyph header.
1350    *     It must be called between an `access' and
1351    *     `forget'.
1352    *
1353    *   read_simple_glyph ::
1354    *     A function used to read a simple glyph.
1355    *     It must be called after the header was
1356    *     read, and before the `forget'.
1357    *
1358    *   read_composite_glyph ::
1359    *     A function used to read a composite glyph.
1360    *     It must be called after the header was
1361    *     read, and before the `forget'.
1362    *
1363    *   sfnt ::
1364    *     A pointer to the SFNT service.
1365    *
1366    *   psnames ::
1367    *     A pointer to the PostScript names service.
1368    *
1369    *   mm ::
1370    *     A pointer to the Multiple Masters service.
1371    *
1372    *   var ::
1373    *     A pointer to the Metrics Variations
1374    *     service.
1375    *
1376    *   hdmx ::
1377    *     The face's horizontal device metrics
1378    *     (`hdmx' table).  This table is optional in
1379    *     TrueType/OpenType fonts.
1380    *
1381    *   gasp ::
1382    *     The grid-fitting and scaling properties
1383    *     table (`gasp').  This table is optional in
1384    *     TrueType/OpenType fonts.
1385    *
1386    *   pclt ::
1387    *     The `pclt' SFNT table.
1388    *
1389    *   num_sbit_scales ::
1390    *     The number of sbit scales for this font.
1391    *
1392    *   sbit_scales ::
1393    *     Array of sbit scales embedded in this
1394    *     font.  This table is optional in a
1395    *     TrueType/OpenType font.
1396    *
1397    *   postscript_names ::
1398    *     A table used to store the Postscript names
1399    *     of  the glyphs for this font.  See the
1400    *     file  `ttconfig.h' for comments on the
1401    *     TT_CONFIG_OPTION_POSTSCRIPT_NAMES option.
1402    *
1403    *   palette_data ::
1404    *     Some fields from the `CPAL' table that are directly indexed.
1405    *
1406    *   palette_index ::
1407    *     The current palette index, as set by @FT_Palette_Select.
1408    *
1409    *   palette ::
1410    *     An array containing the current palette's colors.
1411    *
1412    *   have_foreground_color ::
1413    *     There was a call to @FT_Palette_Set_Foreground_Color.
1414    *
1415    *   foreground_color ::
1416    *     The current foreground color corresponding to `CPAL' color index
1417    *     0xFFFF.  Only valid if `have_foreground_color' is set.
1418    *
1419    *   font_program_size ::
1420    *     Size in bytecodes of the face's font
1421    *     program.  0 if none defined.  Ignored for
1422    *     Type 2 fonts.
1423    *
1424    *   font_program ::
1425    *     The face's font program (bytecode stream)
1426    *     executed at load time, also used during
1427    *     glyph rendering.  Comes from the `fpgm'
1428    *     table.  Ignored for Type 2 font fonts.
1429    *
1430    *   cvt_program_size ::
1431    *     The size in bytecodes of the face's cvt
1432    *     program.  Ignored for Type 2 fonts.
1433    *
1434    *   cvt_program ::
1435    *     The face's cvt program (bytecode stream)
1436    *     executed each time an instance/size is
1437    *     changed/reset.  Comes from the `prep'
1438    *     table.  Ignored for Type 2 fonts.
1439    *
1440    *   cvt_size ::
1441    *     Size of the control value table (in
1442    *     entries).   Ignored for Type 2 fonts.
1443    *
1444    *   cvt ::
1445    *     The face's original control value table.
1446    *     Coordinates are expressed in unscaled font
1447    *     units.  Comes from the `cvt ' table.
1448    *     Ignored for Type 2 fonts.
1449    *
1450    *   interpreter ::
1451    *     A pointer to the TrueType bytecode
1452    *     interpreters field is also used to hook
1453    *     the debugger in `ttdebug'.
1454    *
1455    *   extra ::
1456    *     Reserved for third-party font drivers.
1457    *
1458    *   postscript_name ::
1459    *     The PS name of the font.  Used by the
1460    *     postscript name service.
1461    *
1462    *   glyf_len ::
1463    *     The length of the `glyf' table.  Needed
1464    *     for malformed `loca' tables.
1465    *
1466    *   glyf_offset ::
1467    *     The file offset of the `glyf' table.
1468    *
1469    *   is_cff2 ::
1470    *     Set if the font format is CFF2.
1471    *
1472    *   doblend ::
1473    *     A boolean which is set if the font should
1474    *     be blended (this is for GX var).
1475    *
1476    *   blend ::
1477    *     Contains the data needed to control GX
1478    *     variation tables (rather like Multiple
1479    *     Master data).
1480    *
1481    *   variation_support ::
1482    *     Flags that indicate which OpenType
1483    *     functionality related to font variation
1484    *     support is present, valid, and usable.
1485    *     For example, TT_FACE_FLAG_VAR_FVAR is only
1486    *     set if we have at least one design axis.
1487    *
1488    *   var_postscript_prefix ::
1489    *     The PostScript name prefix needed for
1490    *     constructing a variation font instance's
1491    *     PS name .
1492    *
1493    *   var_postscript_prefix_len ::
1494    *     The length of the `var_postscript_prefix'
1495    *     string.
1496    *
1497    *   horz_metrics_size ::
1498    *     The size of the `hmtx' table.
1499    *
1500    *   vert_metrics_size ::
1501    *     The size of the `vmtx' table.
1502    *
1503    *   num_locations ::
1504    *     The number of glyph locations in this
1505    *     TrueType file.  This should be
1506    *     identical to the number of glyphs.
1507    *     Ignored for Type 2 fonts.
1508    *
1509    *   glyph_locations ::
1510    *     An array of longs.  These are offsets to
1511    *     glyph data within the `glyf' table.
1512    *     Ignored for Type 2 font faces.
1513    *
1514    *   hdmx_table ::
1515    *     A pointer to the `hdmx' table.
1516    *
1517    *   hdmx_table_size ::
1518    *     The size of the `hdmx' table.
1519    *
1520    *   hdmx_record_count ::
1521    *     The number of hdmx records.
1522    *
1523    *   hdmx_record_size ::
1524    *     The size of a single hdmx record.
1525    *
1526    *   hdmx_record_sizes ::
1527    *     An array holding the ppem sizes available
1528    *     in the `hdmx' table.
1529    *
1530    *   sbit_table ::
1531    *     A pointer to the font's embedded bitmap
1532    *     location table.
1533    *
1534    *   sbit_table_size ::
1535    *     The size of `sbit_table'.
1536    *
1537    *   sbit_table_type ::
1538    *     The sbit table type (CBLC, sbix, etc.).
1539    *
1540    *   sbit_num_strikes ::
1541    *     The number of sbit strikes exposed by
1542    *     FreeType's API, omitting invalid strikes.
1543    *
1544    *   sbit_strike_map ::
1545    *     A mapping between the strike indices
1546    *     exposed by the API and the indices used in
1547    *     the font's sbit table.
1548    *
1549    *   cpal ::
1550    *     A pointer to data related to the `CPAL' table.  NULL if the table
1551    *     is not available.
1552    *
1553    *   colr ::
1554    *     A pointer to data related to the `COLR' table.  NULL if the table
1555    *     is not available.
1556    *
1557    *   kern_table ::
1558    *     A pointer to the `kern' table.
1559    *
1560    *   kern_table_size ::
1561    *     The size of the `kern' table.
1562    *
1563    *   num_kern_tables ::
1564    *     The number of supported kern subtables
1565    *     (up to 32; FreeType recognizes only
1566    *     horizontal ones with format 0).
1567    *
1568    *   kern_avail_bits ::
1569    *     The availability status of kern subtables;
1570    *     if bit n is set, table n is available.
1571    *
1572    *   kern_order_bits ::
1573    *     The sortedness status of kern subtables;
1574    *     if bit n is set, table n is sorted.
1575    *
1576    *   bdf ::
1577    *     Data related to an SFNT font's `bdf'
1578    *     table; see `tttypes.h'.
1579    *
1580    *   horz_metrics_offset ::
1581    *     The file offset of the `hmtx' table.
1582    *
1583    *   vert_metrics_offset ::
1584    *     The file offset of the `vmtx' table.
1585    *
1586    *   sph_found_func_flags ::
1587    *     Flags identifying special bytecode
1588    *     functions (used by the v38 implementation
1589    *     of the bytecode interpreter).
1590    *
1591    *   sph_compatibility_mode ::
1592    *     This flag is set if we are in ClearType
1593    *     backward compatibility mode (used by the
1594    *     v38 implementation of the bytecode
1595    *     interpreter).
1596    *
1597    *   ebdt_start ::
1598    *     The file offset of the sbit data table
1599    *     (CBDT, bdat, etc.).
1600    *
1601    *   ebdt_size ::
1602    *     The size of the sbit data table.
1603    */
1604   typedef struct  TT_FaceRec_
1605   {
1606     FT_FaceRec            root;
1607 
1608     TTC_HeaderRec         ttc_header;
1609 
1610     FT_ULong              format_tag;
1611     FT_UShort             num_tables;
1612     TT_Table              dir_tables;
1613 
1614     TT_Header             header;       /* TrueType header table          */
1615     TT_HoriHeader         horizontal;   /* TrueType horizontal header     */
1616 
1617     TT_MaxProfile         max_profile;
1618 
1619     FT_Bool               vertical_info;
1620     TT_VertHeader         vertical;     /* TT Vertical header, if present */
1621 
1622     FT_UShort             num_names;    /* number of name records  */
1623     TT_NameTableRec       name_table;   /* name table              */
1624 
1625     TT_OS2                os2;          /* TrueType OS/2 table            */
1626     TT_Postscript         postscript;   /* TrueType Postscript table      */
1627 
1628     FT_Byte*              cmap_table;   /* extracted `cmap' table */
1629     FT_ULong              cmap_size;
1630 
1631     TT_Loader_GotoTableFunc   goto_table;
1632 
1633     TT_Loader_StartGlyphFunc  access_glyph_frame;
1634     TT_Loader_EndGlyphFunc    forget_glyph_frame;
1635     TT_Loader_ReadGlyphFunc   read_glyph_header;
1636     TT_Loader_ReadGlyphFunc   read_simple_glyph;
1637     TT_Loader_ReadGlyphFunc   read_composite_glyph;
1638 
1639     /* a typeless pointer to the SFNT_Interface table used to load */
1640     /* the basic TrueType tables in the face object                */
1641     void*                 sfnt;
1642 
1643     /* a typeless pointer to the FT_Service_PsCMapsRec table used to */
1644     /* handle glyph names <-> unicode & Mac values                   */
1645     void*                 psnames;
1646 
1647 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1648     /* a typeless pointer to the FT_Service_MultiMasters table used to */
1649     /* handle variation fonts                                          */
1650     void*                 mm;
1651 
1652     /* a typeless pointer to the FT_Service_MetricsVariationsRec table */
1653     /* used to handle the HVAR, VVAR, and MVAR OpenType tables         */
1654     void*                 var;
1655 #endif
1656 
1657     /* a typeless pointer to the PostScript Aux service */
1658     void*                 psaux;
1659 
1660 
1661     /************************************************************************
1662      *
1663      * Optional TrueType/OpenType tables
1664      *
1665      */
1666 
1667     /* grid-fitting and scaling table */
1668     TT_GaspRec            gasp;                 /* the `gasp' table */
1669 
1670     /* PCL 5 table */
1671     TT_PCLT               pclt;
1672 
1673     /* embedded bitmaps support */
1674     FT_ULong              num_sbit_scales;
1675     TT_SBit_Scale         sbit_scales;
1676 
1677     /* postscript names table */
1678     TT_Post_NamesRec      postscript_names;
1679 
1680     /* glyph colors */
1681     FT_Palette_Data       palette_data;         /* since 2.10 */
1682     FT_UShort             palette_index;
1683     FT_Color*             palette;
1684     FT_Bool               have_foreground_color;
1685     FT_Color              foreground_color;
1686 
1687 
1688     /************************************************************************
1689      *
1690      * TrueType-specific fields (ignored by the CFF driver)
1691      *
1692      */
1693 
1694     /* the font program, if any */
1695     FT_ULong              font_program_size;
1696     FT_Byte*              font_program;
1697 
1698     /* the cvt program, if any */
1699     FT_ULong              cvt_program_size;
1700     FT_Byte*              cvt_program;
1701 
1702     /* the original, unscaled, control value table */
1703     FT_ULong              cvt_size;
1704     FT_Short*             cvt;
1705 
1706     /* A pointer to the bytecode interpreter to use.  This is also */
1707     /* used to hook the debugger for the `ttdebug' utility.        */
1708     TT_Interpreter        interpreter;
1709 
1710 
1711     /************************************************************************
1712      *
1713      * Other tables or fields. This is used by derivative formats like
1714      * OpenType.
1715      *
1716      */
1717 
1718     FT_Generic            extra;
1719 
1720     const char*           postscript_name;
1721 
1722     FT_ULong              glyf_len;
1723     FT_ULong              glyf_offset;    /* since 2.7.1 */
1724 
1725     FT_Bool               is_cff2;        /* since 2.7.1 */
1726 
1727 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1728     FT_Bool               doblend;
1729     GX_Blend              blend;
1730 
1731     FT_UInt32             variation_support;     /* since 2.7.1 */
1732 
1733     const char*           var_postscript_prefix;     /* since 2.7.2 */
1734     FT_UInt               var_postscript_prefix_len; /* since 2.7.2 */
1735 
1736 #endif
1737 
1738     /* since version 2.2 */
1739 
1740     FT_ULong              horz_metrics_size;
1741     FT_ULong              vert_metrics_size;
1742 
1743     FT_ULong              num_locations; /* in broken TTF, gid > 0xFFFF */
1744     FT_Byte*              glyph_locations;
1745 
1746     FT_Byte*              hdmx_table;
1747     FT_ULong              hdmx_table_size;
1748     FT_UInt               hdmx_record_count;
1749     FT_ULong              hdmx_record_size;
1750     FT_Byte*              hdmx_record_sizes;
1751 
1752     FT_Byte*              sbit_table;
1753     FT_ULong              sbit_table_size;
1754     TT_SbitTableType      sbit_table_type;
1755     FT_UInt               sbit_num_strikes;
1756     FT_UInt*              sbit_strike_map;
1757 
1758     FT_Byte*              kern_table;
1759     FT_ULong              kern_table_size;
1760     FT_UInt               num_kern_tables;
1761     FT_UInt32             kern_avail_bits;
1762     FT_UInt32             kern_order_bits;
1763 
1764 #ifdef TT_CONFIG_OPTION_BDF
1765     TT_BDFRec             bdf;
1766 #endif /* TT_CONFIG_OPTION_BDF */
1767 
1768     /* since 2.3.0 */
1769     FT_ULong              horz_metrics_offset;
1770     FT_ULong              vert_metrics_offset;
1771 
1772 #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
1773     /* since 2.4.12 */
1774     FT_ULong              sph_found_func_flags; /* special functions found */
1775                                                 /* for this face           */
1776     FT_Bool               sph_compatibility_mode;
1777 #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
1778 
1779 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
1780     /* since 2.7 */
1781     FT_ULong              ebdt_start;  /* either `CBDT', `EBDT', or `bdat' */
1782     FT_ULong              ebdt_size;
1783 #endif
1784 
1785     /* since 2.10 */
1786     void*                 cpal;
1787     void*                 colr;
1788 
1789   } TT_FaceRec;
1790 
1791 
1792   /**************************************************************************
1793    *
1794    * @struct:
1795    *    TT_GlyphZoneRec
1796    *
1797    * @description:
1798    *   A glyph zone is used to load, scale and hint glyph outline
1799    *   coordinates.
1800    *
1801    * @fields:
1802    *   memory ::
1803    *     A handle to the memory manager.
1804    *
1805    *   max_points ::
1806    *     The maximum size in points of the zone.
1807    *
1808    *   max_contours ::
1809    *     Max size in links contours of the zone.
1810    *
1811    *   n_points ::
1812    *     The current number of points in the zone.
1813    *
1814    *   n_contours ::
1815    *     The current number of contours in the zone.
1816    *
1817    *   org ::
1818    *     The original glyph coordinates (font
1819    *     units/scaled).
1820    *
1821    *   cur ::
1822    *     The current glyph coordinates (scaled/hinted).
1823    *
1824    *   tags ::
1825    *     The point control tags.
1826    *
1827    *   contours ::
1828    *     The contours end points.
1829    *
1830    *   first_point ::
1831    *     Offset of the current subglyph's first point.
1832    */
1833   typedef struct  TT_GlyphZoneRec_
1834   {
1835     FT_Memory   memory;
1836     FT_UShort   max_points;
1837     FT_Short    max_contours;
1838     FT_UShort   n_points;    /* number of points in zone    */
1839     FT_Short    n_contours;  /* number of contours          */
1840 
1841     FT_Vector*  org;         /* original point coordinates  */
1842     FT_Vector*  cur;         /* current point coordinates   */
1843     FT_Vector*  orus;        /* original (unscaled) point coordinates */
1844 
1845     FT_Byte*    tags;        /* current touch flags         */
1846     FT_UShort*  contours;    /* contour end points          */
1847 
1848     FT_UShort   first_point; /* offset of first (#0) point  */
1849 
1850   } TT_GlyphZoneRec, *TT_GlyphZone;
1851 
1852 
1853   /* handle to execution context */
1854   typedef struct TT_ExecContextRec_*  TT_ExecContext;
1855 
1856 
1857   /**************************************************************************
1858    *
1859    * @type:
1860    *   TT_Size
1861    *
1862    * @description:
1863    *   A handle to a TrueType size object.
1864    */
1865   typedef struct TT_SizeRec_*  TT_Size;
1866 
1867 
1868   /* glyph loader structure */
1869   typedef struct  TT_LoaderRec_
1870   {
1871     TT_Face          face;
1872     TT_Size          size;
1873     FT_GlyphSlot     glyph;
1874     FT_GlyphLoader   gloader;
1875 
1876     FT_ULong         load_flags;
1877     FT_UInt          glyph_index;
1878 
1879     FT_Stream        stream;
1880     FT_Int           byte_len;
1881 
1882     FT_Short         n_contours;
1883     FT_BBox          bbox;
1884     FT_Int           left_bearing;
1885     FT_Int           advance;
1886     FT_Int           linear;
1887     FT_Bool          linear_def;
1888     FT_Vector        pp1;
1889     FT_Vector        pp2;
1890 
1891     /* the zone where we load our glyphs */
1892     TT_GlyphZoneRec  base;
1893     TT_GlyphZoneRec  zone;
1894 
1895     TT_ExecContext   exec;
1896     FT_Byte*         instructions;
1897     FT_ULong         ins_pos;
1898 
1899     /* for possible extensibility in other formats */
1900     void*            other;
1901 
1902     /* since version 2.1.8 */
1903     FT_Int           top_bearing;
1904     FT_Int           vadvance;
1905     FT_Vector        pp3;
1906     FT_Vector        pp4;
1907 
1908     /* since version 2.2.1 */
1909     FT_Byte*         cursor;
1910     FT_Byte*         limit;
1911 
1912     /* since version 2.6.2 */
1913     FT_ListRec       composites;
1914 
1915   } TT_LoaderRec;
1916 
1917 
1918 FT_END_HEADER
1919 
1920 #endif /* TTTYPES_H_ */
1921 
1922 
1923 /* END */
1924