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