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