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