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