text:
/****************************************************************************
 *
 * tttypes.h
 *
 *   Basic SFNT/TrueType type definitions and interface (specification
 *   only).
 *
 * Copyright (C) 1996-2020 by
 * David Turner, Robert Wilhelm, and Werner Lemberg.
 *
 * This file is part of the FreeType project, and may only be used,
 * modified, and distributed under the terms of the FreeType project
 * license, LICENSE.TXT.  By continuing to use, modify, or distribute
 * this file you indicate that you have read the license and
 * understand and accept it fully.
 *
 */

#ifndef TTTYPES_H_
#define TTTYPES_H_

#include <ft2build.h>
#include FT_TRUETYPE_TABLES_H
#include FT_INTERNAL_OBJECTS_H
#include FT_COLOR_H

#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_MULTIPLE_MASTERS_H
#endif

FT_BEGIN_HEADER

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /***                                                                   ***/
  /***                                                                   ***/
  /***             REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS         ***/
  /***                                                                   ***/
  /***                                                                   ***/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /**************************************************************************
   *
   * @struct:
   *   TTC_HeaderRec
   *
   * @description:
   *   TrueType collection header.  This table contains the offsets of the
   *   font headers of each distinct TrueType face in the file.
   *
   * @fields:
   *   tag ::
   *     Must be 'ttc~' to indicate a TrueType collection.
   *
   *   version ::
   *     The version number.
   *
   *   count ::
   *     The number of faces in the collection.  The specification says this
   *     should be an unsigned long, but we use a signed long since we need
   *     the value -1 for specific purposes.
   *
   *   offsets ::
   *     The offsets of the font headers, one per face.
   */
  typedef struct  TTC_HeaderRec_
  {
    FT_ULong   tag;
    FT_Fixed   version;
    FT_Long    count;
    FT_ULong*  offsets;

  } TTC_HeaderRec;

  /**************************************************************************
   *
   * @struct:
   *   SFNT_HeaderRec
   *
   * @description:
   *   SFNT file format header.
   *
   * @fields:
   *   format_tag ::
   *     The font format tag.
   *
   *   num_tables ::
   *     The number of tables in file.
   *
   *   search_range ::
   *     Must be '16 * (max power of 2 <= num_tables)'.
   *
   *   entry_selector ::
   *     Must be log2 of 'search_range / 16'.
   *
   *   range_shift ::
   *     Must be 'num_tables * 16 - search_range'.
   */
  typedef struct  SFNT_HeaderRec_
  {
    FT_ULong   format_tag;
    FT_UShort  num_tables;
    FT_UShort  search_range;
    FT_UShort  entry_selector;
    FT_UShort  range_shift;

    FT_ULong   offset;  /* not in file */

  } SFNT_HeaderRec, *SFNT_Header;

  /**************************************************************************
   *
   * @struct:
   *   TT_TableRec
   *
   * @description:
   *   This structure describes a given table of a TrueType font.
   *
   * @fields:
   *   Tag ::
   *     A four-bytes tag describing the table.
   *
   *   CheckSum ::
   *     The table checksum.  This value can be ignored.
   *
   *   Offset ::
   *     The offset of the table from the start of the TrueType font in its
   *     resource.
   *
   *   Length ::
   *     The table length (in bytes).
   */
  typedef struct  TT_TableRec_
  {
    FT_ULong  Tag;        /*        table type */
    FT_ULong  CheckSum;   /*    table checksum */
    FT_ULong  Offset;     /* table file offset */
    FT_ULong  Length;     /*      table length */

  } TT_TableRec, *TT_Table;

  /**************************************************************************
   *
   * @struct:
   *   TT_LongMetricsRec
   *
   * @description:
   *   A structure modeling the long metrics of the 'hmtx' and 'vmtx'
   *   TrueType tables.  The values are expressed in font units.
   *
   * @fields:
   *   advance ::
   *     The advance width or height for the glyph.
   *
   *   bearing ::
   *     The left-side or top-side bearing for the glyph.
   */
  typedef struct  TT_LongMetricsRec_
  {
    FT_UShort  advance;
    FT_Short   bearing;

  } TT_LongMetricsRec, *TT_LongMetrics;

  /**************************************************************************
   *
   * @type:
   *   TT_ShortMetrics
   *
   * @description:
   *   A simple type to model the short metrics of the 'hmtx' and 'vmtx'
   *   tables.
   */
  typedef FT_Short  TT_ShortMetrics;

  /**************************************************************************
   *
   * @struct:
   *   TT_NameRec
   *
   * @description:
   *   A structure modeling TrueType name records.  Name records are used to
   *   store important strings like family name, style name, copyright,
   *   etc. in _localized_ versions (i.e., language, encoding, etc).
   *
   * @fields:
   *   platformID ::
   *     The ID of the name's encoding platform.
   *
   *   encodingID ::
   *     The platform-specific ID for the name's encoding.
   *
   *   languageID ::
   *     The platform-specific ID for the name's language.
   *
   *   nameID ::
   *     The ID specifying what kind of name this is.
   *
   *   stringLength ::
   *     The length of the string in bytes.
   *
   *   stringOffset ::
   *     The offset to the string in the 'name' table.
   *
   *   string ::
   *     A pointer to the string's bytes.  Note that these are usually UTF-16
   *     encoded characters.
   */
  typedef struct  TT_NameRec_
  {
    FT_UShort  platformID;
    FT_UShort  encodingID;
    FT_UShort  languageID;
    FT_UShort  nameID;
    FT_UShort  stringLength;
    FT_ULong   stringOffset;

    /* this last field is not defined in the spec */
    /* but used by the FreeType engine            */

    FT_Byte*  string;

  } TT_NameRec, *TT_Name;

  /**************************************************************************
   *
   * @struct:
   *   TT_LangTagRec
   *
   * @description:
   *   A structure modeling language tag records in SFNT 'name' tables,
   *   introduced in OpenType version 1.6.
   *
   * @fields:
   *   stringLength ::
   *     The length of the string in bytes.
   *
   *   stringOffset ::
   *     The offset to the string in the 'name' table.
   *
   *   string ::
   *     A pointer to the string's bytes.  Note that these are UTF-16BE
   *     encoded characters.
   */
  typedef struct TT_LangTagRec_
  {
    FT_UShort  stringLength;
    FT_ULong   stringOffset;

    /* this last field is not defined in the spec */
    /* but used by the FreeType engine            */

    FT_Byte*  string;

  } TT_LangTagRec, *TT_LangTag;

  /**************************************************************************
   *
   * @struct:
   *   TT_NameTableRec
   *
   * @description:
   *   A structure modeling the TrueType name table.
   *
   * @fields:
   *   format ::
   *     The format of the name table.
   *
   *   numNameRecords ::
   *     The number of names in table.
   *
   *   storageOffset ::
   *     The offset of the name table in the 'name' TrueType table.
   *
   *   names ::
   *     An array of name records.
   *
   *   numLangTagRecords ::
   *     The number of language tags in table.
   *
   *   langTags ::
   *     An array of language tag records.
   *
   *   stream ::
   *     The file's input stream.
   */
  typedef struct  TT_NameTableRec_
  {
    FT_UShort       format;
    FT_UInt         numNameRecords;
    FT_UInt         storageOffset;
    TT_NameRec*     names;
    FT_UInt         numLangTagRecords;
    TT_LangTagRec*  langTags;
    FT_Stream       stream;

  } TT_NameTableRec, *TT_NameTable;

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /***                                                                   ***/
  /***                                                                   ***/
  /***             OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS         ***/
  /***                                                                   ***/
  /***                                                                   ***/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /**************************************************************************
   *
   * @struct:
   *   TT_GaspRangeRec
   *
   * @description:
   *   A tiny structure used to model a gasp range according to the TrueType
   *   specification.
   *
   * @fields:
   *   maxPPEM ::
   *     The maximum ppem value to which `gaspFlag` applies.
   *
   *   gaspFlag ::
   *     A flag describing the grid-fitting and anti-aliasing modes to be
   *     used.
   */
  typedef struct  TT_GaspRangeRec_
  {
    FT_UShort  maxPPEM;
    FT_UShort  gaspFlag;

  } TT_GaspRangeRec, *TT_GaspRange;

#define TT_GASP_GRIDFIT  0x01
#define TT_GASP_DOGRAY   0x02

  /**************************************************************************
   *
   * @struct:
   *   TT_GaspRec
   *
   * @description:
   *   A structure modeling the TrueType 'gasp' table used to specify
   *   grid-fitting and anti-aliasing behaviour.
   *
   * @fields:
   *   version ::
   *     The version number.
   *
   *   numRanges ::
   *     The number of gasp ranges in table.
   *
   *   gaspRanges ::
   *     An array of gasp ranges.
   */
  typedef struct  TT_Gasp_
  {
    FT_UShort     version;
    FT_UShort     numRanges;
    TT_GaspRange  gaspRanges;

  } TT_GaspRec;

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /***                                                                   ***/
  /***                                                                   ***/
  /***                    EMBEDDED BITMAPS SUPPORT                       ***/
  /***                                                                   ***/
  /***                                                                   ***/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /**************************************************************************
   *
   * @struct:
   *   TT_SBit_MetricsRec
   *
   * @description:
   *   A structure used to hold the big metrics of a given glyph bitmap in a
   *   TrueType or OpenType font.  These are usually found in the 'EBDT'
   *   (Microsoft) or 'bloc' (Apple) table.
   *
   * @fields:
   *   height ::
   *     The glyph height in pixels.
   *
   *   width ::
   *     The glyph width in pixels.
   *
   *   horiBearingX ::
   *     The horizontal left bearing.
   *
   *   horiBearingY ::
   *     The horizontal top bearing.
   *
   *   horiAdvance ::
   *     The horizontal advance.
   *
   *   vertBearingX ::
   *     The vertical left bearing.
   *
   *   vertBearingY ::
   *     The vertical top bearing.
   *
   *   vertAdvance ::
   *     The vertical advance.
   */
  typedef struct  TT_SBit_MetricsRec_
  {
    FT_UShort  height;
    FT_UShort  width;

    FT_Short   horiBearingX;
    FT_Short   horiBearingY;
    FT_UShort  horiAdvance;

    FT_Short   vertBearingX;
    FT_Short   vertBearingY;
    FT_UShort  vertAdvance;

  } TT_SBit_MetricsRec, *TT_SBit_Metrics;

  /**************************************************************************
   *
   * @struct:
   *   TT_SBit_SmallMetricsRec
   *
   * @description:
   *   A structure used to hold the small metrics of a given glyph bitmap in
   *   a TrueType or OpenType font.  These are usually found in the 'EBDT'
   *   (Microsoft) or the 'bdat' (Apple) table.
   *
   * @fields:
   *   height ::
   *     The glyph height in pixels.
   *
   *   width ::
   *     The glyph width in pixels.
   *
   *   bearingX ::
   *     The left-side bearing.
   *
   *   bearingY ::
   *     The top-side bearing.
   *
   *   advance ::
   *     The advance width or height.
   */
  typedef struct  TT_SBit_Small_Metrics_
  {
    FT_Byte  height;
    FT_Byte  width;

    FT_Char  bearingX;
    FT_Char  bearingY;
    FT_Byte  advance;

  } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics;

  /**************************************************************************
   *
   * @struct:
   *   TT_SBit_LineMetricsRec
   *
   * @description:
   *   A structure used to describe the text line metrics of a given bitmap
   *   strike, for either a horizontal or vertical layout.
   *
   * @fields:
   *   ascender ::
   *     The ascender in pixels.
   *
   *   descender ::
   *     The descender in pixels.
   *
   *   max_width ::
   *     The maximum glyph width in pixels.
   *
   *   caret_slope_enumerator ::
   *     Rise of the caret slope, typically set to 1 for non-italic fonts.
   *
   *   caret_slope_denominator ::
   *     Rise of the caret slope, typically set to 0 for non-italic fonts.
   *
   *   caret_offset ::
   *     Offset in pixels to move the caret for proper positioning.
   *
   *   min_origin_SB ::
   *     Minimum of horiBearingX (resp.  vertBearingY).
   *   min_advance_SB ::
   *     Minimum of
   *
   *     horizontal advance - ( horiBearingX + width )
   *
   *     resp.
   *
   *     vertical advance - ( vertBearingY + height )
   *
   *   max_before_BL ::
   *     Maximum of horiBearingY (resp.  vertBearingY).
   *
   *   min_after_BL ::
   *     Minimum of
   *
   *     horiBearingY - height
   *
   *     resp.
   *
   *     vertBearingX - width
   *
   *   pads ::
   *     Unused (to make the size of the record a multiple of 32 bits.
   */
  typedef struct  TT_SBit_LineMetricsRec_
  {
    FT_Char  ascender;
    FT_Char  descender;
    FT_Byte  max_width;
    FT_Char  caret_slope_numerator;
    FT_Char  caret_slope_denominator;
    FT_Char  caret_offset;
    FT_Char  min_origin_SB;
    FT_Char  min_advance_SB;
    FT_Char  max_before_BL;
    FT_Char  min_after_BL;
    FT_Char  pads[2];

  } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics;

  /**************************************************************************
   *
   * @struct:
   *   TT_SBit_RangeRec
   *
   * @description:
   *   A TrueType/OpenType subIndexTable as defined in the 'EBLC' (Microsoft)
   *   or 'bloc' (Apple) tables.
   *
   * @fields:
   *   first_glyph ::
   *     The first glyph index in the range.
   *
   *   last_glyph ::
   *     The last glyph index in the range.
   *
   *   index_format ::
   *     The format of index table.  Valid values are 1 to 5.
   *
   *   image_format ::
   *     The format of 'EBDT' image data.
   *
   *   image_offset ::
   *     The offset to image data in 'EBDT'.
   *
   *   image_size ::
   *     For index formats 2 and 5.  This is the size in bytes of each glyph
   *     bitmap.
   *
   *   big_metrics ::
   *     For index formats 2 and 5.  This is the big metrics for each glyph
   *     bitmap.
   *
   *   num_glyphs ::
   *     For index formats 4 and 5.  This is the number of glyphs in the code
   *     array.
   *
   *   glyph_offsets ::
   *     For index formats 1 and 3.
   *
   *   glyph_codes ::
   *     For index formats 4 and 5.
   *
   *   table_offset ::
   *     The offset of the index table in the 'EBLC' table.  Only used during
   *     strike loading.
   */
  typedef struct  TT_SBit_RangeRec_
  {
    FT_UShort           first_glyph;
    FT_UShort           last_glyph;

    FT_UShort           index_format;
    FT_UShort           image_format;
    FT_ULong            image_offset;

    FT_ULong            image_size;
    TT_SBit_MetricsRec  metrics;
    FT_ULong            num_glyphs;

    FT_ULong*           glyph_offsets;
    FT_UShort*          glyph_codes;

    FT_ULong            table_offset;

  } TT_SBit_RangeRec, *TT_SBit_Range;

  /**************************************************************************
   *
   * @struct:
   *   TT_SBit_StrikeRec
   *
   * @description:
   *   A structure used describe a given bitmap strike in the 'EBLC'
   *   (Microsoft) or 'bloc' (Apple) tables.
   *
   * @fields:
   *  num_index_ranges ::
   *    The number of index ranges.
   *
   *  index_ranges ::
   *    An array of glyph index ranges.
   *
   *  color_ref ::
   *    Unused.  `color_ref` is put in for future enhancements, but these
   *    fields are already in use by other platforms (e.g. Newton).  For
   *    details, please see
   *
   *    https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html
   *
   *  hori ::
   *    The line metrics for horizontal layouts.
   *
   *  vert ::
   *    The line metrics for vertical layouts.
   *
   *  start_glyph ::
   *    The lowest glyph index for this strike.
   *
   *  end_glyph ::
   *    The highest glyph index for this strike.
   *
   *  x_ppem ::
   *    The number of horizontal pixels per EM.
   *
   *  y_ppem ::
   *    The number of vertical pixels per EM.
   *
   *  bit_depth ::
   *    The bit depth.  Valid values are 1, 2, 4, and 8.
   *
   *  flags ::
   *    Is this a vertical or horizontal strike?  For details, please see
   *
   *    https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html
   */
  typedef struct  TT_SBit_StrikeRec_
  {
    FT_Int                  num_ranges;
    TT_SBit_Range           sbit_ranges;
    FT_ULong                ranges_offset;

    FT_ULong                color_ref;

    TT_SBit_LineMetricsRec  hori;
    TT_SBit_LineMetricsRec  vert;

    FT_UShort               start_glyph;
    FT_UShort               end_glyph;

    FT_Byte                 x_ppem;
    FT_Byte                 y_ppem;

    FT_Byte                 bit_depth;
    FT_Char                 flags;

  } TT_SBit_StrikeRec, *TT_SBit_Strike;

  /**************************************************************************
   *
   * @struct:
   *   TT_SBit_ComponentRec
   *
   * @description:
   *   A simple structure to describe a compound sbit element.
   *
   * @fields:
   *   glyph_code ::
   *     The element's glyph index.
   *
   *   x_offset ::
   *     The element's left bearing.
   *
   *   y_offset ::
   *     The element's top bearing.
   */
  typedef struct  TT_SBit_ComponentRec_
  {
    FT_UShort  glyph_code;
    FT_Char    x_offset;
    FT_Char    y_offset;

  } TT_SBit_ComponentRec, *TT_SBit_Component;

  /**************************************************************************
   *
   * @struct:
   *   TT_SBit_ScaleRec
   *
   * @description:
   *   A structure used describe a given bitmap scaling table, as defined in
   *   the 'EBSC' table.
   *
   * @fields:
   *   hori ::
   *     The horizontal line metrics.
   *
   *   vert ::
   *     The vertical line metrics.
   *
   *   x_ppem ::
   *     The number of horizontal pixels per EM.
   *
   *   y_ppem ::
   *     The number of vertical pixels per EM.
   *
   *   x_ppem_substitute ::
   *     Substitution x_ppem value.
   *
   *   y_ppem_substitute ::
   *     Substitution y_ppem value.
   */
  typedef struct  TT_SBit_ScaleRec_
  {
    TT_SBit_LineMetricsRec  hori;
    TT_SBit_LineMetricsRec  vert;

    FT_Byte                 x_ppem;
    FT_Byte                 y_ppem;

    FT_Byte                 x_ppem_substitute;
    FT_Byte                 y_ppem_substitute;

  } TT_SBit_ScaleRec, *TT_SBit_Scale;

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /***                                                                   ***/
  /***                                                                   ***/
  /***                  POSTSCRIPT GLYPH NAMES SUPPORT                   ***/
  /***                                                                   ***/
  /***                                                                   ***/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /**************************************************************************
   *
   * @struct:
   *   TT_Post_20Rec
   *
   * @description:
   *   Postscript names sub-table, format 2.0.  Stores the PS name of each
   *   glyph in the font face.
   *
   * @fields:
   *   num_glyphs ::
   *     The number of named glyphs in the table.
   *
   *   num_names ::
   *     The number of PS names stored in the table.
   *
   *   glyph_indices ::
   *     The indices of the glyphs in the names arrays.
   *
   *   glyph_names ::
   *     The PS names not in Mac Encoding.
   */
  typedef struct  TT_Post_20Rec_
  {
    FT_UShort   num_glyphs;
    FT_UShort   num_names;
    FT_UShort*  glyph_indices;
    FT_Char**   glyph_names;

  } TT_Post_20Rec, *TT_Post_20;

  /**************************************************************************
   *
   * @struct:
   *   TT_Post_25Rec
   *
   * @description:
   *   Postscript names sub-table, format 2.5.  Stores the PS name of each
   *   glyph in the font face.
   *
   * @fields:
   *   num_glyphs ::
   *     The number of glyphs in the table.
   *
   *   offsets ::
   *     An array of signed offsets in a normal Mac Postscript name encoding.
   */
  typedef struct  TT_Post_25_
  {
    FT_UShort  num_glyphs;
    FT_Char*   offsets;

  } TT_Post_25Rec, *TT_Post_25;

  /**************************************************************************
   *
   * @struct:
   *   TT_Post_NamesRec
   *
   * @description:
   *   Postscript names table, either format 2.0 or 2.5.
   *
   * @fields:
   *   loaded ::
   *     A flag to indicate whether the PS names are loaded.
   *
   *   format_20 ::
   *     The sub-table used for format 2.0.
   *
   *   format_25 ::
   *     The sub-table used for format 2.5.
   */
  typedef struct  TT_Post_NamesRec_
  {
    FT_Bool  loaded;

    union
    {
      TT_Post_20Rec  format_20;
      TT_Post_25Rec  format_25;

    } names;

  } TT_Post_NamesRec, *TT_Post_Names;

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /***                                                                   ***/
  /***                                                                   ***/
  /***                    GX VARIATION TABLE SUPPORT                     ***/
  /***                                                                   ***/
  /***                                                                   ***/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
  typedef struct GX_BlendRec_  *GX_Blend;
#endif

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /***                                                                   ***/
  /***                                                                   ***/
  /***              EMBEDDED BDF PROPERTIES TABLE SUPPORT                ***/
  /***                                                                   ***/
  /***                                                                   ***/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /*
   * These types are used to support a `BDF ' table that isn't part of the
   * official TrueType specification.  It is mainly used in SFNT-based bitmap
   * fonts that were generated from a set of BDF fonts.
   *
   * The format of the table is as follows.
   *
   *   USHORT version `BDF ' table version number, should be 0x0001.  USHORT
   *   strikeCount Number of strikes (bitmap sizes) in this table.  ULONG
   *   stringTable Offset (from start of BDF table) to string
   *                         table.
   *
   * This is followed by an array of `strikeCount' descriptors, having the
   * following format.
   *
   *   USHORT ppem Vertical pixels per EM for this strike.  USHORT numItems
   *   Number of items for this strike (properties and
   *                         atoms).  Maximum is 255.
   *
   * This array in turn is followed by `strikeCount' value sets.  Each `value
   * set' is an array of `numItems' items with the following format.
   *
   *   ULONG    item_name    Offset in string table to item name.
   *   USHORT   item_type    The item type.  Possible values are
   *                            0 => string (e.g., COMMENT)
   *                            1 => atom   (e.g., FONT or even SIZE)
   *                            2 => int32
   *                            3 => uint32
   *                         0x10 => A flag to indicate a properties.  This
   *                                 is ORed with the above values.
   *   ULONG    item_value   For strings  => Offset into string table without
   *                                         the corresponding double quotes.
   *                         For atoms    => Offset into string table.
   *                         For integers => Direct value.
   *
   * All strings in the string table consist of bytes and are
   * zero-terminated.
   *
   */

#ifdef TT_CONFIG_OPTION_BDF

  typedef struct  TT_BDFRec_
  {
    FT_Byte*   table;
    FT_Byte*   table_end;
    FT_Byte*   strings;
    FT_ULong   strings_size;
    FT_UInt    num_strikes;
    FT_Bool    loaded;

  } TT_BDFRec, *TT_BDF;

#endif /* TT_CONFIG_OPTION_BDF */

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /***                                                                   ***/
  /***                                                                   ***/
  /***                  ORIGINAL TT_FACE CLASS DEFINITION                ***/
  /***                                                                   ***/
  /***                                                                   ***/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /**************************************************************************
   *
   * This structure/class is defined here because it is common to the
   * following formats: TTF, OpenType-TT, and OpenType-CFF.
   *
   * Note, however, that the classes TT_Size and TT_GlyphSlot are not shared
   * between font drivers, and are thus defined in `ttobjs.h`.
   *
   */

  /**************************************************************************
   *
   * @type:
   *   TT_Face
   *
   * @description:
   *   A handle to a TrueType face/font object.  A TT_Face encapsulates the
   *   resolution and scaling independent parts of a TrueType font resource.
   *
   * @note:
   *   The TT_Face structure is also used as a 'parent class' for the
   *   OpenType-CFF class (T2_Face).
   */
  typedef struct TT_FaceRec_*  TT_Face;

  /* a function type used for the truetype bytecode interpreter hooks */
  typedef FT_Error
  (*TT_Interpreter)( void*  exec_context );

  /* forward declaration */
  typedef struct TT_LoaderRec_*  TT_Loader;

  /**************************************************************************
   *
   * @functype:
   *   TT_Loader_GotoTableFunc
   *
   * @description:
   *   Seeks a stream to the start of a given TrueType table.
   *
   * @input:
   *   face ::
   *     A handle to the target face object.
   *
   *   tag ::
   *     A 4-byte tag used to name the table.
   *
   *   stream ::
   *     The input stream.
   *
   * @output:
   *   length ::
   *     The length of the table in bytes.  Set to 0 if not needed.
   *
   * @return:
   *   FreeType error code.  0 means success.
   *
   * @note:
   *   The stream cursor must be at the font file's origin.
   */
  typedef FT_Error
  (*TT_Loader_GotoTableFunc)( TT_Face    face,
                              FT_ULong   tag,
                              FT_Stream  stream,
                              FT_ULong*  length );

  /**************************************************************************
   *
   * @functype:
   *   TT_Loader_StartGlyphFunc
   *
   * @description:
   *   Seeks a stream to the start of a given glyph element, and opens a
   *   frame for it.
   *
   * @input:
   *   loader ::
   *     The current TrueType glyph loader object.
   *
   *     glyph index :: The index of the glyph to access.
   *
   *   offset ::
   *     The offset of the glyph according to the 'locations' table.
   *
   *   byte_count ::
   *     The size of the frame in bytes.
   *
   * @return:
   *   FreeType error code.  0 means success.
   *
   * @note:
   *   This function is normally equivalent to FT_STREAM_SEEK(offset)
   *   followed by FT_FRAME_ENTER(byte_count) with the loader's stream, but
   *   alternative formats (e.g. compressed ones) might use something
   *   different.
   */
  typedef FT_Error
  (*TT_Loader_StartGlyphFunc)( TT_Loader  loader,
                               FT_UInt    glyph_index,
                               FT_ULong   offset,
                               FT_UInt    byte_count );

  /**************************************************************************
   *
   * @functype:
   *   TT_Loader_ReadGlyphFunc
   *
   * @description:
   *   Reads one glyph element (its header, a simple glyph, or a composite)
   *   from the loader's current stream frame.
   *
   * @input:
   *   loader ::
   *     The current TrueType glyph loader object.
   *
   * @return:
   *   FreeType error code.  0 means success.
   */
  typedef FT_Error
  (*TT_Loader_ReadGlyphFunc)( TT_Loader  loader );

  /**************************************************************************
   *
   * @functype:
   *   TT_Loader_EndGlyphFunc
   *
   * @description:
   *   Closes the current loader stream frame for the glyph.
   *
   * @input:
   *   loader ::
   *     The current TrueType glyph loader object.
   */
  typedef void
  (*TT_Loader_EndGlyphFunc)( TT_Loader  loader );

  typedef enum TT_SbitTableType_
  {
    TT_SBIT_TABLE_TYPE_NONE = 0,
    TT_SBIT_TABLE_TYPE_EBLC, /* `EBLC' (Microsoft), */
                             /* `bloc' (Apple)      */
    TT_SBIT_TABLE_TYPE_CBLC, /* `CBLC' (Google)     */
    TT_SBIT_TABLE_TYPE_SBIX, /* `sbix' (Apple)      */

    /* do not remove */
    TT_SBIT_TABLE_TYPE_MAX

  } TT_SbitTableType;

  /* OpenType 1.8 brings new tables for variation font support;  */
  /* to make the old MM and GX fonts still work we need to check */
  /* the presence (and validity) of the functionality provided   */
  /* by those tables.  The following flag macros are for the     */
  /* field `variation_support'.                                  */
  /*                                                             */
  /* Note that `fvar' gets checked immediately at font loading,  */
  /* while the other features are only loaded if MM support is   */
  /* actually requested.                                         */

  /* FVAR */
#define TT_FACE_FLAG_VAR_FVAR  ( 1 << 0 )

  /* HVAR */
#define TT_FACE_FLAG_VAR_HADVANCE  ( 1 << 1 )
#define TT_FACE_FLAG_VAR_LSB       ( 1 << 2 )
#define TT_FACE_FLAG_VAR_RSB       ( 1 << 3 )

  /* VVAR */
#define TT_FACE_FLAG_VAR_VADVANCE  ( 1 << 4 )
#define TT_FACE_FLAG_VAR_TSB       ( 1 << 5 )
#define TT_FACE_FLAG_VAR_BSB       ( 1 << 6 )
#define TT_FACE_FLAG_VAR_VORG      ( 1 << 7 )

  /* MVAR */
#define TT_FACE_FLAG_VAR_MVAR  ( 1 << 8 )

  /**************************************************************************
   *
   *                        TrueType Face Type
   *
   * @struct:
   *   TT_Face
   *
   * @description:
   *   The TrueType face class.  These objects model the resolution and
   *   point-size independent data found in a TrueType font file.
   *
   * @fields:
   *   root ::
   *     The base FT_Face structure, managed by the base layer.
   *
   *   ttc_header ::
   *     The TrueType collection header, used when the file is a 'ttc' rather
   *     than a 'ttf'.  For ordinary font files, the field `ttc_header.count`
   *     is set to 0.
   *
   *   format_tag ::
   *     The font format tag.
   *
   *   num_tables ::
   *     The number of TrueType tables in this font file.
   *
   *   dir_tables ::
   *     The directory of TrueType tables for this font file.
   *
   *   header ::
   *     The font's font header ('head' table).  Read on font opening.
   *
   *   horizontal ::
   *     The font's horizontal header ('hhea' table).  This field also
   *     contains the associated horizontal metrics table ('hmtx').
   *
   *   max_profile ::
   *     The font's maximum profile table.  Read on font opening.  Note that
   *     some maximum values cannot be taken directly from this table.  We
   *     thus define additional fields below to hold the computed maxima.
   *
   *   vertical_info ::
   *     A boolean which is set when the font file contains vertical metrics.
   *     If not, the value of the 'vertical' field is undefined.
   *
   *   vertical ::
   *     The font's vertical header ('vhea' table).  This field also contains
   *     the associated vertical metrics table ('vmtx'), if found.
   *     IMPORTANT: The contents of this field is undefined if the
   *     `vertical_info` field is unset.
   *
   *   num_names ::
   *     The number of name records within this TrueType font.
   *
   *   name_table ::
   *     The table of name records ('name').
   *
   *   os2 ::
   *     The font's OS/2 table ('OS/2').
   *
   *   postscript ::
   *     The font's PostScript table ('post' table).  The PostScript glyph
   *     names are not loaded by the driver on face opening.  See the
   *     'ttpost' module for more details.
   *
   *   cmap_table ::
   *     Address of the face's 'cmap' SFNT table in memory (it's an extracted
   *     frame).
   *
   *   cmap_size ::
   *     The size in bytes of the `cmap_table` described above.
   *
   *   goto_table ::
   *     A function called by each TrueType table loader to position a
   *     stream's cursor to the start of a given table according to its tag.
   *     It defaults to TT_Goto_Face but can be different for strange formats
   *     (e.g.  Type 42).
   *
   *   access_glyph_frame ::
   *     A function used to access the frame of a given glyph within the
   *     face's font file.
   *
   *   forget_glyph_frame ::
   *     A function used to forget the frame of a given glyph when all data
   *     has been loaded.
   *
   *   read_glyph_header ::
   *     A function used to read a glyph header.  It must be called between
   *     an 'access' and 'forget'.
   *
   *   read_simple_glyph ::
   *     A function used to read a simple glyph.  It must be called after the
   *     header was read, and before the 'forget'.
   *
   *   read_composite_glyph ::
   *     A function used to read a composite glyph.  It must be called after
   *     the header was read, and before the 'forget'.
   *
   *   sfnt ::
   *     A pointer to the SFNT service.
   *
   *   psnames ::
   *     A pointer to the PostScript names service.
   *
   *   mm ::
   *     A pointer to the Multiple Masters service.
   *
   *   var ::
   *     A pointer to the Metrics Variations service.
   *
   *   hdmx ::
   *     The face's horizontal device metrics ('hdmx' table).  This table is
   *     optional in TrueType/OpenType fonts.
   *
   *   gasp ::
   *     The grid-fitting and scaling properties table ('gasp').  This table
   *     is optional in TrueType/OpenType fonts.
   *
   *   pclt ::
   *     The 'pclt' SFNT table.
   *
   *   num_sbit_scales ::
   *     The number of sbit scales for this font.
   *
   *   sbit_scales ::
   *     Array of sbit scales embedded in this font.  This table is optional
   *     in a TrueType/OpenType font.
   *
   *   postscript_names ::
   *     A table used to store the Postscript names of the glyphs for this
   *     font.  See the file `ttconfig.h` for comments on the
   *     TT_CONFIG_OPTION_POSTSCRIPT_NAMES option.
   *
   *   palette_data ::
   *     Some fields from the 'CPAL' table that are directly indexed.
   *
   *   palette_index ::
   *     The current palette index, as set by @FT_Palette_Select.
   *
   *   palette ::
   *     An array containing the current palette's colors.
   *
   *   have_foreground_color ::
   *     There was a call to @FT_Palette_Set_Foreground_Color.
   *
   *   foreground_color ::
   *     The current foreground color corresponding to 'CPAL' color index
   *     0xFFFF.  Only valid if `have_foreground_color` is set.
   *
   *   font_program_size ::
   *     Size in bytecodes of the face's font program.  0 if none defined.
   *     Ignored for Type 2 fonts.
   *
   *   font_program ::
   *     The face's font program (bytecode stream) executed at load time,
   *     also used during glyph rendering.  Comes from the 'fpgm' table.
   *     Ignored for Type 2 font fonts.
   *
   *   cvt_program_size ::
   *     The size in bytecodes of the face's cvt program.  Ignored for Type 2
   *     fonts.
   *
   *   cvt_program ::
   *     The face's cvt program (bytecode stream) executed each time an
   *     instance/size is changed/reset.  Comes from the 'prep' table.
   *     Ignored for Type 2 fonts.
   *
   *   cvt_size ::
   *     Size of the control value table (in entries).  Ignored for Type 2
   *     fonts.
   *
   *   cvt ::
   *     The face's original control value table.  Coordinates are expressed
   *     in unscaled font units (in 26.6 format).  Comes from the 'cvt~'
   *     table.  Ignored for Type 2 fonts.
   *
   *     If varied by the `CVAR' table, non-integer values are possible.
   *
   *   interpreter ::
   *     A pointer to the TrueType bytecode interpreters field is also used
   *     to hook the debugger in 'ttdebug'.
   *
   *   extra ::
   *     Reserved for third-party font drivers.
   *
   *   postscript_name ::
   *     The PS name of the font.  Used by the postscript name service.
   *
   *   glyf_len ::
   *     The length of the 'glyf' table.  Needed for malformed 'loca' tables.
   *
   *   glyf_offset ::
   *     The file offset of the 'glyf' table.
   *
   *   is_cff2 ::
   *     Set if the font format is CFF2.
   *
   *   doblend ::
   *     A boolean which is set if the font should be blended (this is for GX
   *     var).
   *
   *   blend ::
   *     Contains the data needed to control GX variation tables (rather like
   *     Multiple Master data).
   *
   *   variation_support ::
   *     Flags that indicate which OpenType functionality related to font
   *     variation support is present, valid, and usable.  For example,
   *     TT_FACE_FLAG_VAR_FVAR is only set if we have at least one design
   *     axis.
   *
   *   var_postscript_prefix ::
   *     The PostScript name prefix needed for constructing a variation font
   *     instance's PS name .
   *
   *   var_postscript_prefix_len ::
   *     The length of the `var_postscript_prefix` string.
   *
   *   horz_metrics_size ::
   *     The size of the 'hmtx' table.
   *
   *   vert_metrics_size ::
   *     The size of the 'vmtx' table.
   *
   *   num_locations ::
   *     The number of glyph locations in this TrueType file.  This should be
   *     identical to the number of glyphs.  Ignored for Type 2 fonts.
   *
   *   glyph_locations ::
   *     An array of longs.  These are offsets to glyph data within the
   *     'glyf' table.  Ignored for Type 2 font faces.
   *
   *   hdmx_table ::
   *     A pointer to the 'hdmx' table.
   *
   *   hdmx_table_size ::
   *     The size of the 'hdmx' table.
   *
   *   hdmx_record_count ::
   *     The number of hdmx records.
   *
   *   hdmx_record_size ::
   *     The size of a single hdmx record.
   *
   *   hdmx_record_sizes ::
   *     An array holding the ppem sizes available in the 'hdmx' table.
   *
   *   sbit_table ::
   *     A pointer to the font's embedded bitmap location table.
   *
   *   sbit_table_size ::
   *     The size of `sbit_table`.
   *
   *   sbit_table_type ::
   *     The sbit table type (CBLC, sbix, etc.).
   *
   *   sbit_num_strikes ::
   *     The number of sbit strikes exposed by FreeType's API, omitting
   *     invalid strikes.
   *
   *   sbit_strike_map ::
   *     A mapping between the strike indices exposed by the API and the
   *     indices used in the font's sbit table.
   *
   *   cpal ::
   *     A pointer to data related to the 'CPAL' table.  `NULL` if the table
   *     is not available.
   *
   *   colr ::
   *     A pointer to data related to the 'COLR' table.  `NULL` if the table
   *     is not available.
   *
   *   kern_table ::
   *     A pointer to the 'kern' table.
   *
   *   kern_table_size ::
   *     The size of the 'kern' table.
   *
   *   num_kern_tables ::
   *     The number of supported kern subtables (up to 32; FreeType
   *     recognizes only horizontal ones with format 0).
   *
   *   kern_avail_bits ::
   *     The availability status of kern subtables; if bit n is set, table n
   *     is available.
   *
   *   kern_order_bits ::
   *     The sortedness status of kern subtables; if bit n is set, table n is
   *     sorted.
   *
   *   bdf ::
   *     Data related to an SFNT font's 'bdf' table; see `tttypes.h`.
   *
   *   horz_metrics_offset ::
   *     The file offset of the 'hmtx' table.
   *
   *   vert_metrics_offset ::
   *     The file offset of the 'vmtx' table.
   *
   *   sph_found_func_flags ::
   *     Flags identifying special bytecode functions (used by the v38
   *     implementation of the bytecode interpreter).
   *
   *   sph_compatibility_mode ::
   *     This flag is set if we are in ClearType backward compatibility mode
   *     (used by the v38 implementation of the bytecode interpreter).
   *
   *   ebdt_start ::
   *     The file offset of the sbit data table (CBDT, bdat, etc.).
   *
   *   ebdt_size ::
   *     The size of the sbit data table.
   */
  typedef struct  TT_FaceRec_
  {
    FT_FaceRec            root;

    TTC_HeaderRec         ttc_header;

    FT_ULong              format_tag;
    FT_UShort             num_tables;
    TT_Table              dir_tables;

    TT_Header             header;       /* TrueType header table          */
    TT_HoriHeader         horizontal;   /* TrueType horizontal header     */

    TT_MaxProfile         max_profile;

    FT_Bool               vertical_info;
    TT_VertHeader         vertical;     /* TT Vertical header, if present */

    FT_UShort             num_names;    /* number of name records  */
    TT_NameTableRec       name_table;   /* name table              */

    TT_OS2                os2;          /* TrueType OS/2 table            */
    TT_Postscript         postscript;   /* TrueType Postscript table      */

    FT_Byte*              cmap_table;   /* extracted `cmap' table */
    FT_ULong              cmap_size;

    TT_Loader_GotoTableFunc   goto_table;

    TT_Loader_StartGlyphFunc  access_glyph_frame;
    TT_Loader_EndGlyphFunc    forget_glyph_frame;
    TT_Loader_ReadGlyphFunc   read_glyph_header;
    TT_Loader_ReadGlyphFunc   read_simple_glyph;
    TT_Loader_ReadGlyphFunc   read_composite_glyph;

    /* a typeless pointer to the SFNT_Interface table used to load */
    /* the basic TrueType tables in the face object                */
    void*                 sfnt;

    /* a typeless pointer to the FT_Service_PsCMapsRec table used to */
    /* handle glyph names <-> unicode & Mac values                   */
    void*                 psnames;

#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    /* a typeless pointer to the FT_Service_MultiMasters table used to */
    /* handle variation fonts                                          */
    void*                 mm;

    /* a typeless pointer to the FT_Service_MetricsVariationsRec table */
    /* used to handle the HVAR, VVAR, and MVAR OpenType tables         */
    void*                 var;
#endif

    /* a typeless pointer to the PostScript Aux service */
    void*                 psaux;

    /************************************************************************
     *
     * Optional TrueType/OpenType tables
     *
     */

    /* grid-fitting and scaling table */
    TT_GaspRec            gasp;                 /* the `gasp' table */

    /* PCL 5 table */
    TT_PCLT               pclt;

    /* embedded bitmaps support */
    FT_ULong              num_sbit_scales;
    TT_SBit_Scale         sbit_scales;

    /* postscript names table */
    TT_Post_NamesRec      postscript_names;

    /* glyph colors */
    FT_Palette_Data       palette_data;         /* since 2.10 */
    FT_UShort             palette_index;
    FT_Color*             palette;
    FT_Bool               have_foreground_color;
    FT_Color              foreground_color;

    /************************************************************************
     *
     * TrueType-specific fields (ignored by the CFF driver)
     *
     */

    /* the font program, if any */
    FT_ULong              font_program_size;
    FT_Byte*              font_program;

    /* the cvt program, if any */
    FT_ULong              cvt_program_size;
    FT_Byte*              cvt_program;

    /* the original, unscaled, control value table */
    FT_ULong              cvt_size;
    FT_Int32*             cvt;

    /* A pointer to the bytecode interpreter to use.  This is also */
    /* used to hook the debugger for the `ttdebug' utility.        */
    TT_Interpreter        interpreter;

    /************************************************************************
     *
     * Other tables or fields. This is used by derivative formats like
     * OpenType.
     *
     */

    FT_Generic            extra;

    const char*           postscript_name;

    FT_ULong              glyf_len;
    FT_ULong              glyf_offset;    /* since 2.7.1 */

    FT_Bool               is_cff2;        /* since 2.7.1 */

#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    FT_Bool               doblend;
    GX_Blend              blend;

    FT_UInt32             variation_support;     /* since 2.7.1 */

    const char*           var_postscript_prefix;     /* since 2.7.2 */
    FT_UInt               var_postscript_prefix_len; /* since 2.7.2 */

#endif

    /* since version 2.2 */

    FT_ULong              horz_metrics_size;
    FT_ULong              vert_metrics_size;

    FT_ULong              num_locations; /* in broken TTF, gid > 0xFFFF */
    FT_Byte*              glyph_locations;

    FT_Byte*              hdmx_table;
    FT_ULong              hdmx_table_size;
    FT_UInt               hdmx_record_count;
    FT_ULong              hdmx_record_size;
    FT_Byte*              hdmx_record_sizes;

    FT_Byte*              sbit_table;
    FT_ULong              sbit_table_size;
    TT_SbitTableType      sbit_table_type;
    FT_UInt               sbit_num_strikes;
    FT_UInt*              sbit_strike_map;

    FT_Byte*              kern_table;
    FT_ULong              kern_table_size;
    FT_UInt               num_kern_tables;
    FT_UInt32             kern_avail_bits;
    FT_UInt32             kern_order_bits;

#ifdef TT_CONFIG_OPTION_BDF
    TT_BDFRec             bdf;
#endif /* TT_CONFIG_OPTION_BDF */

    /* since 2.3.0 */
    FT_ULong              horz_metrics_offset;
    FT_ULong              vert_metrics_offset;

#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
    /* since 2.4.12 */
    FT_ULong              sph_found_func_flags; /* special functions found */
                                                /* for this face           */
    FT_Bool               sph_compatibility_mode;
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */

#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
    /* since 2.7 */
    FT_ULong              ebdt_start;  /* either `CBDT', `EBDT', or `bdat' */
    FT_ULong              ebdt_size;
#endif

    /* since 2.10 */
    void*                 cpal;
    void*                 colr;

  } TT_FaceRec;

  /**************************************************************************
   *
   * @struct:
   *    TT_GlyphZoneRec
   *
   * @description:
   *   A glyph zone is used to load, scale and hint glyph outline
   *   coordinates.
   *
   * @fields:
   *   memory ::
   *     A handle to the memory manager.
   *
   *   max_points ::
   *     The maximum size in points of the zone.
   *
   *   max_contours ::
   *     Max size in links contours of the zone.
   *
   *   n_points ::
   *     The current number of points in the zone.
   *
   *   n_contours ::
   *     The current number of contours in the zone.
   *
   *   org ::
   *     The original glyph coordinates (font units/scaled).
   *
   *   cur ::
   *     The current glyph coordinates (scaled/hinted).
   *
   *   tags ::
   *     The point control tags.
   *
   *   contours ::
   *     The contours end points.
   *
   *   first_point ::
   *     Offset of the current subglyph's first point.
   */
  typedef struct  TT_GlyphZoneRec_
  {
    FT_Memory   memory;
    FT_UShort   max_points;
    FT_Short    max_contours;
    FT_UShort   n_points;    /* number of points in zone    */
    FT_Short    n_contours;  /* number of contours          */

    FT_Vector*  org;         /* original point coordinates  */
    FT_Vector*  cur;         /* current point coordinates   */
    FT_Vector*  orus;        /* original (unscaled) point coordinates */

    FT_Byte*    tags;        /* current touch flags         */
    FT_UShort*  contours;    /* contour end points          */

    FT_UShort   first_point; /* offset of first (#0) point  */

  } TT_GlyphZoneRec, *TT_GlyphZone;

  /* handle to execution context */
  typedef struct TT_ExecContextRec_*  TT_ExecContext;

  /**************************************************************************
   *
   * @type:
   *   TT_Size
   *
   * @description:
   *   A handle to a TrueType size object.
   */
  typedef struct TT_SizeRec_*  TT_Size;

  /* glyph loader structure */
  typedef struct  TT_LoaderRec_
  {
    TT_Face          face;
    TT_Size          size;
    FT_GlyphSlot     glyph;
    FT_GlyphLoader   gloader;

    FT_ULong         load_flags;
    FT_UInt          glyph_index;

    FT_Stream        stream;
    FT_Int           byte_len;

    FT_Short         n_contours;
    FT_BBox          bbox;
    FT_Int           left_bearing;
    FT_Int           advance;
    FT_Int           linear;
    FT_Bool          linear_def;
    FT_Vector        pp1;
    FT_Vector        pp2;

    /* the zone where we load our glyphs */
    TT_GlyphZoneRec  base;
    TT_GlyphZoneRec  zone;

    TT_ExecContext   exec;
    FT_Byte*         instructions;
    FT_ULong         ins_pos;

    /* for possible extensibility in other formats */
    void*            other;

    /* since version 2.1.8 */
    FT_Int           top_bearing;
    FT_Int           vadvance;
    FT_Vector        pp3;
    FT_Vector        pp4;

    /* since version 2.2.1 */
    FT_Byte*         cursor;
    FT_Byte*         limit;

    /* since version 2.6.2 */
    FT_ListRec       composites;

  } TT_LoaderRec;

FT_END_HEADER

#endif /* TTTYPES_H_ */

/* END */


text:
/****************************************************************************
 *
 * ftpsprop.h
 *
 *   Get and set properties of PostScript drivers (specification).
 *
 * Copyright (C) 2017-2020 by
 * David Turner, Robert Wilhelm, and Werner Lemberg.
 *
 * This file is part of the FreeType project, and may only be used,
 * modified, and distributed under the terms of the FreeType project
 * license, LICENSE.TXT.  By continuing to use, modify, or distribute
 * this file you indicate that you have read the license and
 * understand and accept it fully.
 *
 */

#ifndef FTPSPROP_H_
#define FTPSPROP_H_

#include <ft2build.h>
#include FT_FREETYPE_H

FT_BEGIN_HEADER

  FT_BASE_CALLBACK( FT_Error )
  ps_property_set( FT_Module    module,         /* PS_Driver */
                   const char*  property_name,
                   const void*  value,
                   FT_Bool      value_is_string );

  FT_BASE_CALLBACK( FT_Error )
  ps_property_get( FT_Module    module,         /* PS_Driver */
                   const char*  property_name,
                   void*        value );

FT_END_HEADER

#endif /* FTPSPROP_H_ */

/* END */

repo_language: C

mime_type: text/x-c


text:
/****************************************************************************
 *
 * ftobjs.h
 *
 *   The FreeType private base classes (specification).
 *
 * Copyright (C) 1996-2020 by
 * David Turner, Robert Wilhelm, and Werner Lemberg.
 *
 * This file is part of the FreeType project, and may only be used,
 * modified, and distributed under the terms of the FreeType project
 * license, LICENSE.TXT.  By continuing to use, modify, or distribute
 * this file you indicate that you have read the license and
 * understand and accept it fully.
 *
 */

  /**************************************************************************
   *
   * This file contains the definition of all internal FreeType classes.
   *
   */

#ifndef FTOBJS_H_
#define FTOBJS_H_

#include <ft2build.h>
#include FT_RENDER_H
#include FT_SIZES_H
#include FT_LCD_FILTER_H
#include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_GLYPH_LOADER_H
#include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_AUTOHINT_H
#include FT_INTERNAL_SERVICE_H
#include FT_INTERNAL_CALC_H

#ifdef FT_CONFIG_OPTION_INCREMENTAL
#include FT_INCREMENTAL_H
#endif

FT_BEGIN_HEADER

  /**************************************************************************
   *
   * Some generic definitions.
   */
#ifndef TRUE
#define TRUE  1
#endif

#ifndef FALSE
#define FALSE  0
#endif

#ifndef NULL
#define NULL  (void*)0
#endif

  /**************************************************************************
   *
   * The min and max functions missing in C.  As usual, be careful not to
   * write things like FT_MIN( a++, b++ ) to avoid side effects.
   */
#define FT_MIN( a, b )  ( (a) < (b) ? (a) : (b) )
#define FT_MAX( a, b )  ( (a) > (b) ? (a) : (b) )

#define FT_ABS( a )     ( (a) < 0 ? -(a) : (a) )

  /*
   * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' algorithm.
   * We use alpha = 1, beta = 3/8, giving us results with a largest error
   * less than 7% compared to the exact value.
   */
#define FT_HYPOT( x, y )                 \
          ( x = FT_ABS( x ),             \
            y = FT_ABS( y ),             \
            x > y ? x + ( 3 * y >> 3 )   \
                  : y + ( 3 * x >> 3 ) )

  /* we use FT_TYPEOF to suppress signedness compilation warnings */
#define FT_PAD_FLOOR( x, n )  ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) )
#define FT_PAD_ROUND( x, n )  FT_PAD_FLOOR( (x) + (n) / 2, n )
#define FT_PAD_CEIL( x, n )   FT_PAD_FLOOR( (x) + (n) - 1, n )

#define FT_PIX_FLOOR( x )     ( (x) & ~FT_TYPEOF( x )63 )
#define FT_PIX_ROUND( x )     FT_PIX_FLOOR( (x) + 32 )
#define FT_PIX_CEIL( x )      FT_PIX_FLOOR( (x) + 63 )

  /* specialized versions (for signed values)                   */
  /* that don't produce run-time errors due to integer overflow */
#define FT_PAD_ROUND_LONG( x, n )  FT_PAD_FLOOR( ADD_LONG( (x), (n) / 2 ), \
                                                 n )
#define FT_PAD_CEIL_LONG( x, n )   FT_PAD_FLOOR( ADD_LONG( (x), (n) - 1 ), \
                                                 n )
#define FT_PIX_ROUND_LONG( x )     FT_PIX_FLOOR( ADD_LONG( (x), 32 ) )
#define FT_PIX_CEIL_LONG( x )      FT_PIX_FLOOR( ADD_LONG( (x), 63 ) )

#define FT_PAD_ROUND_INT32( x, n )  FT_PAD_FLOOR( ADD_INT32( (x), (n) / 2 ), \
                                                  n )
#define FT_PAD_CEIL_INT32( x, n )   FT_PAD_FLOOR( ADD_INT32( (x), (n) - 1 ), \
                                                  n )
#define FT_PIX_ROUND_INT32( x )     FT_PIX_FLOOR( ADD_INT32( (x), 32 ) )
#define FT_PIX_CEIL_INT32( x )      FT_PIX_FLOOR( ADD_INT32( (x), 63 ) )

  /*
   * character classification functions -- since these are used to parse font
   * files, we must not use those in <ctypes.h> which are locale-dependent
   */
#define  ft_isdigit( x )   ( ( (unsigned)(x) - '0' ) < 10U )

#define  ft_isxdigit( x )  ( ( (unsigned)(x) - '0' ) < 10U || \
                             ( (unsigned)(x) - 'a' ) < 6U  || \
                             ( (unsigned)(x) - 'A' ) < 6U  )

  /* the next two macros assume ASCII representation */
#define  ft_isupper( x )  ( ( (unsigned)(x) - 'A' ) < 26U )
#define  ft_islower( x )  ( ( (unsigned)(x) - 'a' ) < 26U )

#define  ft_isalpha( x )  ( ft_isupper( x ) || ft_islower( x ) )
#define  ft_isalnum( x )  ( ft_isdigit( x ) || ft_isalpha( x ) )

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                       C H A R M A P S                           ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /* handle to internal charmap object */
  typedef struct FT_CMapRec_*              FT_CMap;

  /* handle to charmap class structure */
  typedef const struct FT_CMap_ClassRec_*  FT_CMap_Class;

  /* internal charmap object structure */
  typedef struct  FT_CMapRec_
  {
    FT_CharMapRec  charmap;
    FT_CMap_Class  clazz;

  } FT_CMapRec;

  /* typecast any pointer to a charmap handle */
#define FT_CMAP( x )  ( (FT_CMap)( x ) )

  /* obvious macros */
#define FT_CMAP_PLATFORM_ID( x )  FT_CMAP( x )->charmap.platform_id
#define FT_CMAP_ENCODING_ID( x )  FT_CMAP( x )->charmap.encoding_id
#define FT_CMAP_ENCODING( x )     FT_CMAP( x )->charmap.encoding
#define FT_CMAP_FACE( x )         FT_CMAP( x )->charmap.face

  /* class method definitions */
  typedef FT_Error
  (*FT_CMap_InitFunc)( FT_CMap     cmap,
                       FT_Pointer  init_data );

  typedef void
  (*FT_CMap_DoneFunc)( FT_CMap  cmap );

  typedef FT_UInt
  (*FT_CMap_CharIndexFunc)( FT_CMap    cmap,
                            FT_UInt32  char_code );

  typedef FT_UInt
  (*FT_CMap_CharNextFunc)( FT_CMap     cmap,
                           FT_UInt32  *achar_code );

  typedef FT_UInt
  (*FT_CMap_CharVarIndexFunc)( FT_CMap    cmap,
                               FT_CMap    unicode_cmap,
                               FT_UInt32  char_code,
                               FT_UInt32  variant_selector );

  typedef FT_Int
  (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap    cmap,
                                   FT_UInt32  char_code,
                                   FT_UInt32  variant_selector );

  typedef FT_UInt32 *
  (*FT_CMap_VariantListFunc)( FT_CMap    cmap,
                              FT_Memory  mem );

  typedef FT_UInt32 *
  (*FT_CMap_CharVariantListFunc)( FT_CMap    cmap,
                                  FT_Memory  mem,
                                  FT_UInt32  char_code );

  typedef FT_UInt32 *
  (*FT_CMap_VariantCharListFunc)( FT_CMap    cmap,
                                  FT_Memory  mem,
                                  FT_UInt32  variant_selector );

  typedef struct  FT_CMap_ClassRec_
  {
    FT_ULong               size;

    FT_CMap_InitFunc       init;
    FT_CMap_DoneFunc       done;
    FT_CMap_CharIndexFunc  char_index;
    FT_CMap_CharNextFunc   char_next;

    /* Subsequent entries are special ones for format 14 -- the variant */
    /* selector subtable which behaves like no other                    */

    FT_CMap_CharVarIndexFunc      char_var_index;
    FT_CMap_CharVarIsDefaultFunc  char_var_default;
    FT_CMap_VariantListFunc       variant_list;
    FT_CMap_CharVariantListFunc   charvariant_list;
    FT_CMap_VariantCharListFunc   variantchar_list;

  } FT_CMap_ClassRec;

#define FT_DECLARE_CMAP_CLASS( class_ )              \
  FT_CALLBACK_TABLE const  FT_CMap_ClassRec class_;

#define FT_DEFINE_CMAP_CLASS(       \
          class_,                   \
          size_,                    \
          init_,                    \
          done_,                    \
          char_index_,              \
          char_next_,               \
          char_var_index_,          \
          char_var_default_,        \
          variant_list_,            \
          charvariant_list_,        \
          variantchar_list_ )       \
  FT_CALLBACK_TABLE_DEF             \
  const FT_CMap_ClassRec  class_ =  \
  {                                 \
    size_,                          \
    init_,                          \
    done_,                          \
    char_index_,                    \
    char_next_,                     \
    char_var_index_,                \
    char_var_default_,              \
    variant_list_,                  \
    charvariant_list_,              \
    variantchar_list_               \
  };

  /* create a new charmap and add it to charmap->face */
  FT_BASE( FT_Error )
  FT_CMap_New( FT_CMap_Class  clazz,
               FT_Pointer     init_data,
               FT_CharMap     charmap,
               FT_CMap       *acmap );

  /* destroy a charmap and remove it from face's list */
  FT_BASE( void )
  FT_CMap_Done( FT_CMap  cmap );

  /* add LCD padding to CBox */
  FT_BASE( void )
  ft_lcd_padding( FT_BBox*        cbox,
                  FT_GlyphSlot    slot,
                  FT_Render_Mode  mode );

#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING

  typedef void  (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap*      bitmap,
                                            FT_Byte*        weights );

  /* This is the default LCD filter, an in-place, 5-tap FIR filter. */
  FT_BASE( void )
  ft_lcd_filter_fir( FT_Bitmap*           bitmap,
                     FT_LcdFiveTapFilter  weights );

#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */

  /**************************************************************************
   *
   * @struct:
   *   FT_Face_InternalRec
   *
   * @description:
   *   This structure contains the internal fields of each FT_Face object.
   *   These fields may change between different releases of FreeType.
   *
   * @fields:
   *   max_points ::
   *     The maximum number of points used to store the vectorial outline of
   *     any glyph in this face.  If this value cannot be known in advance,
   *     or if the face isn't scalable, this should be set to 0.  Only
   *     relevant for scalable formats.
   *
   *   max_contours ::
   *     The maximum number of contours used to store the vectorial outline
   *     of any glyph in this face.  If this value cannot be known in
   *     advance, or if the face isn't scalable, this should be set to 0.
   *     Only relevant for scalable formats.
   *
   *   transform_matrix ::
   *     A 2x2 matrix of 16.16 coefficients used to transform glyph outlines
   *     after they are loaded from the font.  Only used by the convenience
   *     functions.
   *
   *   transform_delta ::
   *     A translation vector used to transform glyph outlines after they are
   *     loaded from the font.  Only used by the convenience functions.
   *
   *   transform_flags ::
   *     Some flags used to classify the transform.  Only used by the
   *     convenience functions.
   *
   *   services ::
   *     A cache for frequently used services.  It should be only accessed
   *     with the macro `FT_FACE_LOOKUP_SERVICE`.
   *
   *   incremental_interface ::
   *     If non-null, the interface through which glyph data and metrics are
   *     loaded incrementally for faces that do not provide all of this data
   *     when first opened.  This field exists only if
   *     @FT_CONFIG_OPTION_INCREMENTAL is defined.
   *
   *   no_stem_darkening ::
   *     Overrides the module-level default, see @stem-darkening[cff], for
   *     example.  FALSE and TRUE toggle stem darkening on and off,
   *     respectively, value~-1 means to use the module/driver default.
   *
   *   random_seed ::
   *     If positive, override the seed value for the CFF 'random' operator.
   *     Value~0 means to use the font's value.  Value~-1 means to use the
   *     CFF driver's default.
   *
   *   lcd_weights ::
   *   lcd_filter_func ::
   *     These fields specify the LCD filtering weights and callback function
   *     for ClearType-style subpixel rendering.
   *
   *   refcount ::
   *     A counter initialized to~1 at the time an @FT_Face structure is
   *     created.  @FT_Reference_Face increments this counter, and
   *     @FT_Done_Face only destroys a face if the counter is~1, otherwise it
   *     simply decrements it.
   */
  typedef struct  FT_Face_InternalRec_
  {
    FT_Matrix  transform_matrix;
    FT_Vector  transform_delta;
    FT_Int     transform_flags;

    FT_ServiceCacheRec  services;

#ifdef FT_CONFIG_OPTION_INCREMENTAL
    FT_Incremental_InterfaceRec*  incremental_interface;
#endif

    FT_Char              no_stem_darkening;
    FT_Int32             random_seed;

#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    FT_LcdFiveTapFilter      lcd_weights;      /* filter weights, if any */
    FT_Bitmap_LcdFilterFunc  lcd_filter_func;  /* filtering callback     */
#endif

    FT_Int  refcount;

  } FT_Face_InternalRec;

  /**************************************************************************
   *
   * @struct:
   *   FT_Slot_InternalRec
   *
   * @description:
   *   This structure contains the internal fields of each FT_GlyphSlot
   *   object.  These fields may change between different releases of
   *   FreeType.
   *
   * @fields:
   *   loader ::
   *     The glyph loader object used to load outlines into the glyph slot.
   *
   *   flags ::
   *     Possible values are zero or FT_GLYPH_OWN_BITMAP.  The latter
   *     indicates that the FT_GlyphSlot structure owns the bitmap buffer.
   *
   *   glyph_transformed ::
   *     Boolean.  Set to TRUE when the loaded glyph must be transformed
   *     through a specific font transformation.  This is _not_ the same as
   *     the face transform set through FT_Set_Transform().
   *
   *   glyph_matrix ::
   *     The 2x2 matrix corresponding to the glyph transformation, if
   *     necessary.
   *
   *   glyph_delta ::
   *     The 2d translation vector corresponding to the glyph transformation,
   *     if necessary.
   *
   *   glyph_hints ::
   *     Format-specific glyph hints management.
   *
   *   load_flags ::
   *     The load flags passed as an argument to @FT_Load_Glyph while
   *     initializing the glyph slot.
   */

#define FT_GLYPH_OWN_BITMAP  0x1U

  typedef struct  FT_Slot_InternalRec_
  {
    FT_GlyphLoader  loader;
    FT_UInt         flags;
    FT_Bool         glyph_transformed;
    FT_Matrix       glyph_matrix;
    FT_Vector       glyph_delta;
    void*           glyph_hints;

    FT_Int32        load_flags;

  } FT_GlyphSlot_InternalRec;

  /**************************************************************************
   *
   * @struct:
   *   FT_Size_InternalRec
   *
   * @description:
   *   This structure contains the internal fields of each FT_Size object.
   *
   * @fields:
   *   module_data ::
   *     Data specific to a driver module.
   *
   *   autohint_mode ::
   *     The used auto-hinting mode.
   *
   *   autohint_metrics ::
   *     Metrics used by the auto-hinter.
   *
   */

  typedef struct  FT_Size_InternalRec_
  {
    void*  module_data;

    FT_Render_Mode   autohint_mode;
    FT_Size_Metrics  autohint_metrics;

  } FT_Size_InternalRec;

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                         M O D U L E S                           ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /**************************************************************************
   *
   * @struct:
   *   FT_ModuleRec
   *
   * @description:
   *   A module object instance.
   *
   * @fields:
   *   clazz ::
   *     A pointer to the module's class.
   *
   *   library ::
   *     A handle to the parent library object.
   *
   *   memory ::
   *     A handle to the memory manager.
   */
  typedef struct  FT_ModuleRec_
  {
    FT_Module_Class*  clazz;
    FT_Library        library;
    FT_Memory         memory;

  } FT_ModuleRec;

  /* typecast an object to an FT_Module */
#define FT_MODULE( x )  ( (FT_Module)(x) )

#define FT_MODULE_CLASS( x )    FT_MODULE( x )->clazz
#define FT_MODULE_LIBRARY( x )  FT_MODULE( x )->library
#define FT_MODULE_MEMORY( x )   FT_MODULE( x )->memory

#define FT_MODULE_IS_DRIVER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
                                    FT_MODULE_FONT_DRIVER )

#define FT_MODULE_IS_RENDERER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
                                      FT_MODULE_RENDERER )

#define FT_MODULE_IS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
                                    FT_MODULE_HINTER )

#define FT_MODULE_IS_STYLER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
                                    FT_MODULE_STYLER )

#define FT_DRIVER_IS_SCALABLE( x )  ( FT_MODULE_CLASS( x )->module_flags & \
                                      FT_MODULE_DRIVER_SCALABLE )

#define FT_DRIVER_USES_OUTLINES( x )  !( FT_MODULE_CLASS( x )->module_flags & \
                                         FT_MODULE_DRIVER_NO_OUTLINES )

#define FT_DRIVER_HAS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
                                     FT_MODULE_DRIVER_HAS_HINTER )

#define FT_DRIVER_HINTS_LIGHTLY( x )  ( FT_MODULE_CLASS( x )->module_flags & \
                                        FT_MODULE_DRIVER_HINTS_LIGHTLY )

  /**************************************************************************
   *
   * @function:
   *   FT_Get_Module_Interface
   *
   * @description:
   *   Finds a module and returns its specific interface as a typeless
   *   pointer.
   *
   * @input:
   *   library ::
   *     A handle to the library object.
   *
   *   module_name ::
   *     The module's name (as an ASCII string).
   *
   * @return:
   *   A module-specific interface if available, 0 otherwise.
   *
   * @note:
   *   You should better be familiar with FreeType internals to know which
   *   module to look for, and what its interface is :-)
   */
  FT_BASE( const void* )
  FT_Get_Module_Interface( FT_Library   library,
                           const char*  mod_name );

  FT_BASE( FT_Pointer )
  ft_module_get_service( FT_Module    module,
                         const char*  service_id,
                         FT_Bool      global );

#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
  FT_BASE( FT_Error )
  ft_property_string_set( FT_Library        library,
                          const FT_String*  module_name,
                          const FT_String*  property_name,
                          FT_String*        value );
#endif

  /* */

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****   F A C E,   S I Z E   &   G L Y P H   S L O T   O B J E C T S  ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /* a few macros used to perform easy typecasts with minimal brain damage */

#define FT_FACE( x )          ( (FT_Face)(x) )
#define FT_SIZE( x )          ( (FT_Size)(x) )
#define FT_SLOT( x )          ( (FT_GlyphSlot)(x) )

#define FT_FACE_DRIVER( x )   FT_FACE( x )->driver
#define FT_FACE_LIBRARY( x )  FT_FACE_DRIVER( x )->root.library
#define FT_FACE_MEMORY( x )   FT_FACE( x )->memory
#define FT_FACE_STREAM( x )   FT_FACE( x )->stream

#define FT_SIZE_FACE( x )     FT_SIZE( x )->face
#define FT_SLOT_FACE( x )     FT_SLOT( x )->face

#define FT_FACE_SLOT( x )     FT_FACE( x )->glyph
#define FT_FACE_SIZE( x )     FT_FACE( x )->size

  /**************************************************************************
   *
   * @function:
   *   FT_New_GlyphSlot
   *
   * @description:
   *   It is sometimes useful to have more than one glyph slot for a given
   *   face object.  This function is used to create additional slots.  All
   *   of them are automatically discarded when the face is destroyed.
   *
   * @input:
   *   face ::
   *     A handle to a parent face object.
   *
   * @output:
   *   aslot ::
   *     A handle to a new glyph slot object.
   *
   * @return:
   *   FreeType error code.  0 means success.
   */
  FT_BASE( FT_Error )
  FT_New_GlyphSlot( FT_Face        face,
                    FT_GlyphSlot  *aslot );

  /**************************************************************************
   *
   * @function:
   *   FT_Done_GlyphSlot
   *
   * @description:
   *   Destroys a given glyph slot.  Remember however that all slots are
   *   automatically destroyed with its parent.  Using this function is not
   *   always mandatory.
   *
   * @input:
   *   slot ::
   *     A handle to a target glyph slot.
   */
  FT_BASE( void )
  FT_Done_GlyphSlot( FT_GlyphSlot  slot );

 /* */

#define FT_REQUEST_WIDTH( req )                                            \
          ( (req)->horiResolution                                          \
              ? ( (req)->width * (FT_Pos)(req)->horiResolution + 36 ) / 72 \
              : (req)->width )

#define FT_REQUEST_HEIGHT( req )                                            \
          ( (req)->vertResolution                                           \
              ? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \
              : (req)->height )

  /* Set the metrics according to a bitmap strike. */
  FT_BASE( void )
  FT_Select_Metrics( FT_Face   face,
                     FT_ULong  strike_index );

  /* Set the metrics according to a size request. */
  FT_BASE( void )
  FT_Request_Metrics( FT_Face          face,
                      FT_Size_Request  req );

  /* Match a size request against `available_sizes'. */
  FT_BASE( FT_Error )
  FT_Match_Size( FT_Face          face,
                 FT_Size_Request  req,
                 FT_Bool          ignore_width,
                 FT_ULong*        size_index );

  /* Use the horizontal metrics to synthesize the vertical metrics. */
  /* If `advance' is zero, it is also synthesized.                  */
  FT_BASE( void )
  ft_synthesize_vertical_metrics( FT_Glyph_Metrics*  metrics,
                                  FT_Pos             advance );

  /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
  /* was allocated with ft_glyphslot_alloc_bitmap).                       */
  FT_BASE( void )
  ft_glyphslot_free_bitmap( FT_GlyphSlot  slot );

  /* Preset bitmap metrics of an outline glyphslot prior to rendering */
  /* and check whether the truncated bbox is too large for rendering. */
  FT_BASE( FT_Bool )
  ft_glyphslot_preset_bitmap( FT_GlyphSlot      slot,
                              FT_Render_Mode    mode,
                              const FT_Vector*  origin );

  /* Allocate a new bitmap buffer in a glyph slot. */
  FT_BASE( FT_Error )
  ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot,
                             FT_ULong      size );

  /* Set the bitmap buffer in a glyph slot to a given pointer.  The buffer */
  /* will not be freed by a later call to ft_glyphslot_free_bitmap.        */
  FT_BASE( void )
  ft_glyphslot_set_bitmap( FT_GlyphSlot  slot,
                           FT_Byte*      buffer );

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                        R E N D E R E R S                        ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

#define FT_RENDERER( x )       ( (FT_Renderer)(x) )
#define FT_GLYPH( x )          ( (FT_Glyph)(x) )
#define FT_BITMAP_GLYPH( x )   ( (FT_BitmapGlyph)(x) )
#define FT_OUTLINE_GLYPH( x )  ( (FT_OutlineGlyph)(x) )

  typedef struct  FT_RendererRec_
  {
    FT_ModuleRec            root;
    FT_Renderer_Class*      clazz;
    FT_Glyph_Format         glyph_format;
    FT_Glyph_Class          glyph_class;

    FT_Raster               raster;
    FT_Raster_Render_Func   raster_render;
    FT_Renderer_RenderFunc  render;

  } FT_RendererRec;

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                    F O N T   D R I V E R S                      ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /* typecast a module into a driver easily */
#define FT_DRIVER( x )  ( (FT_Driver)(x) )

  /* typecast a module as a driver, and get its driver class */
#define FT_DRIVER_CLASS( x )  FT_DRIVER( x )->clazz

  /**************************************************************************
   *
   * @struct:
   *   FT_DriverRec
   *
   * @description:
   *   The root font driver class.  A font driver is responsible for managing
   *   and loading font files of a given format.
   *
   * @fields:
   *   root ::
   *     Contains the fields of the root module class.
   *
   *   clazz ::
   *     A pointer to the font driver's class.  Note that this is NOT
   *     root.clazz.  'class' wasn't used as it is a reserved word in C++.
   *
   *   faces_list ::
   *     The list of faces currently opened by this driver.
   *
   *   glyph_loader ::
   *     Unused.  Used to be glyph loader for all faces managed by this
   *     driver.
   */
  typedef struct  FT_DriverRec_
  {
    FT_ModuleRec     root;
    FT_Driver_Class  clazz;
    FT_ListRec       faces_list;
    FT_GlyphLoader   glyph_loader;

  } FT_DriverRec;

  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                       L I B R A R I E S                         ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /**************************************************************************
   *
   * @struct:
   *   FT_LibraryRec
   *
   * @description:
   *   The FreeType library class.  This is the root of all FreeType data.
   *   Use FT_New_Library() to create a library object, and FT_Done_Library()
   *   to discard it and all child objects.
   *
   * @fields:
   *   memory ::
   *     The library's memory object.  Manages memory allocation.
   *
   *   version_major ::
   *     The major version number of the library.
   *
   *   version_minor ::
   *     The minor version number of the library.
   *
   *   version_patch ::
   *     The current patch level of the library.
   *
   *   num_modules ::
   *     The number of modules currently registered within this library.
   *     This is set to 0 for new libraries.  New modules are added through
   *     the FT_Add_Module() API function.
   *
   *   modules ::
   *     A table used to store handles to the currently registered
   *     modules. Note that each font driver contains a list of its opened
   *     faces.
   *
   *   renderers ::
   *     The list of renderers currently registered within the library.
   *
   *   cur_renderer ::
   *     The current outline renderer.  This is a shortcut used to avoid
   *     parsing the list on each call to FT_Outline_Render().  It is a
   *     handle to the current renderer for the FT_GLYPH_FORMAT_OUTLINE
   *     format.
   *
   *   auto_hinter ::
   *     The auto-hinter module interface.
   *
   *   debug_hooks ::
   *     An array of four function pointers that allow debuggers to hook into
   *     a font format's interpreter.  Currently, only the TrueType bytecode
   *     debugger uses this.
   *
   *   lcd_weights ::
   *     The LCD filter weights for ClearType-style subpixel rendering.
   *
   *   lcd_filter_func ::
   *     The LCD filtering callback function for for ClearType-style subpixel
   *     rendering.
   *
   *   lcd_geometry ::
   *     This array specifies LCD subpixel geometry and controls Harmony LCD
   *     rendering technique, alternative to ClearType.
   *
   *   pic_container ::
   *     Contains global structs and tables, instead of defining them
   *     globally.
   *
   *   refcount ::
   *     A counter initialized to~1 at the time an @FT_Library structure is
   *     created.  @FT_Reference_Library increments this counter, and
   *     @FT_Done_Library only destroys a library if the counter is~1,
   *     otherwise it simply decrements it.
   */
  typedef struct  FT_LibraryRec_
  {
    FT_Memory          memory;           /* library's memory manager */

    FT_Int             version_major;
    FT_Int             version_minor;
    FT_Int             version_patch;

    FT_UInt            num_modules;
    FT_Module          modules[FT_MAX_MODULES];  /* module objects  */

    FT_ListRec         renderers;        /* list of renderers        */
    FT_Renderer        cur_renderer;     /* current outline renderer */
    FT_Module          auto_hinter;

    FT_DebugHook_Func  debug_hooks[4];

#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    FT_LcdFiveTapFilter      lcd_weights;      /* filter weights, if any */
    FT_Bitmap_LcdFilterFunc  lcd_filter_func;  /* filtering callback     */
#else
    FT_Vector                lcd_geometry[3];  /* RGB subpixel positions */
#endif

    FT_Int             refcount;

  } FT_LibraryRec;

  FT_BASE( FT_Renderer )
  FT_Lookup_Renderer( FT_Library       library,
                      FT_Glyph_Format  format,
                      FT_ListNode*     node );

  FT_BASE( FT_Error )
  FT_Render_Glyph_Internal( FT_Library      library,
                            FT_GlyphSlot    slot,
                            FT_Render_Mode  render_mode );

  typedef const char*
  (*FT_Face_GetPostscriptNameFunc)( FT_Face  face );

  typedef FT_Error
  (*FT_Face_GetGlyphNameFunc)( FT_Face     face,
                               FT_UInt     glyph_index,
                               FT_Pointer  buffer,
                               FT_UInt     buffer_max );

  typedef FT_UInt
  (*FT_Face_GetGlyphNameIndexFunc)( FT_Face           face,
                                    const FT_String*  glyph_name );

#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM

  /**************************************************************************
   *
   * @function:
   *   FT_New_Memory
   *
   * @description:
   *   Creates a new memory object.
   *
   * @return:
   *   A pointer to the new memory object.  0 in case of error.
   */
  FT_BASE( FT_Memory )
  FT_New_Memory( void );

  /**************************************************************************
   *
   * @function:
   *   FT_Done_Memory
   *
   * @description:
   *   Discards memory manager.
   *
   * @input:
   *   memory ::
   *     A handle to the memory manager.
   */
  FT_BASE( void )
  FT_Done_Memory( FT_Memory  memory );

#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */

  /* Define default raster's interface.  The default raster is located in  */
  /* `src/base/ftraster.c'.                                                */
  /*                                                                       */
  /* Client applications can register new rasters through the              */
  /* FT_Set_Raster() API.                                                  */

#ifndef FT_NO_DEFAULT_RASTER
  FT_EXPORT_VAR( FT_Raster_Funcs )  ft_default_raster;
#endif

  /**************************************************************************
   *
   * @macro:
   *   FT_DEFINE_OUTLINE_FUNCS
   *
   * @description:
   *   Used to initialize an instance of FT_Outline_Funcs struct.  The struct
   *   will be allocated in the global scope (or the scope where the macro is
   *   used).
   */
#define FT_DEFINE_OUTLINE_FUNCS(           \
          class_,                          \
          move_to_,                        \
          line_to_,                        \
          conic_to_,                       \
          cubic_to_,                       \
          shift_,                          \
          delta_ )                         \
  static const  FT_Outline_Funcs class_ =  \
  {                                        \
    move_to_,                              \
    line_to_,                              \
    conic_to_,                             \
    cubic_to_,                             \
    shift_,                                \
    delta_                                 \
  };

  /**************************************************************************
   *
   * @macro:
   *   FT_DEFINE_RASTER_FUNCS
   *
   * @description:
   *   Used to initialize an instance of FT_Raster_Funcs struct.  The struct
   *   will be allocated in the global scope (or the scope where the macro is
   *   used).
   */
#define FT_DEFINE_RASTER_FUNCS(    \
          class_,                  \
          glyph_format_,           \
          raster_new_,             \
          raster_reset_,           \
          raster_set_mode_,        \
          raster_render_,          \
          raster_done_ )           \
  const FT_Raster_Funcs  class_ =  \
  {                                \
    glyph_format_,                 \
    raster_new_,                   \
    raster_reset_,                 \
    raster_set_mode_,              \
    raster_render_,                \
    raster_done_                   \
  };

  /**************************************************************************
   *
   * @macro:
   *   FT_DEFINE_GLYPH
   *
   * @description:
   *   The struct will be allocated in the global scope (or the scope where
   *   the macro is used).
   */
#define FT_DEFINE_GLYPH(          \
          class_,                 \
          size_,                  \
          format_,                \
          init_,                  \
          done_,                  \
          copy_,                  \
          transform_,             \
          bbox_,                  \
          prepare_ )              \
  FT_CALLBACK_TABLE_DEF           \
  const FT_Glyph_Class  class_ =  \
  {                               \
    size_,                        \
    format_,                      \
    init_,                        \
    done_,                        \
    copy_,                        \
    transform_,                   \
    bbox_,                        \
    prepare_                      \
  };

  /**************************************************************************
   *
   * @macro:
   *   FT_DECLARE_RENDERER
   *
   * @description:
   *   Used to create a forward declaration of a FT_Renderer_Class struct
   *   instance.
   *
   * @macro:
   *   FT_DEFINE_RENDERER
   *
   * @description:
   *   Used to initialize an instance of FT_Renderer_Class struct.
   *
   *   The struct will be allocated in the global scope (or the scope where
   *   the macro is used).
   */
#define FT_DECLARE_RENDERER( class_ )               \
  FT_EXPORT_VAR( const FT_Renderer_Class ) class_;

#define FT_DEFINE_RENDERER(                  \
          class_,                            \
          flags_,                            \
          size_,                             \
          name_,                             \
          version_,                          \
          requires_,                         \
          interface_,                        \
          init_,                             \
          done_,                             \
          get_interface_,                    \
          glyph_format_,                     \
          render_glyph_,                     \
          transform_glyph_,                  \
          get_glyph_cbox_,                   \
          set_mode_,                         \
          raster_class_ )                    \
  FT_CALLBACK_TABLE_DEF                      \
  const FT_Renderer_Class  class_ =          \
  {                                          \
    FT_DEFINE_ROOT_MODULE( flags_,           \
                           size_,            \
                           name_,            \
                           version_,         \
                           requires_,        \
                           interface_,       \
                           init_,            \
                           done_,            \
                           get_interface_ )  \
    glyph_format_,                           \
                                             \
    render_glyph_,                           \
    transform_glyph_,                        \
    get_glyph_cbox_,                         \
    set_mode_,                               \
                                             \
    raster_class_                            \
  };

  /**************************************************************************
   *
   * @macro:
   *   FT_DECLARE_MODULE
   *
   * @description:
   *   Used to create a forward declaration of a FT_Module_Class struct
   *   instance.
   *
   * @macro:
   *   FT_DEFINE_MODULE
   *
   * @description:
   *   Used to initialize an instance of an FT_Module_Class struct.
   *
   *   The struct will be allocated in the global scope (or the scope where
   *   the macro is used).
   *
   * @macro:
   *   FT_DEFINE_ROOT_MODULE
   *
   * @description:
   *   Used to initialize an instance of an FT_Module_Class struct inside
   *   another struct that contains it or in a function that initializes that
   *   containing struct.
   */
#define FT_DECLARE_MODULE( class_ )  \
  FT_CALLBACK_TABLE                  \
  const FT_Module_Class  class_;

#define FT_DEFINE_ROOT_MODULE(  \
          flags_,               \
          size_,                \
          name_,                \
          version_,             \
          requires_,            \
          interface_,           \
          init_,                \
          done_,                \
          get_interface_ )      \
  {                             \
    flags_,                     \
    size_,                      \
                                \
    name_,                      \
    version_,                   \
    requires_,                  \
                                \
    interface_,                 \
                                \
    init_,                      \
    done_,                      \
    get_interface_,             \
  },

#define FT_DEFINE_MODULE(         \
          class_,                 \
          flags_,                 \
          size_,                  \
          name_,                  \
          version_,               \
          requires_,              \
          interface_,             \
          init_,                  \
          done_,                  \
          get_interface_ )        \
  FT_CALLBACK_TABLE_DEF           \
  const FT_Module_Class class_ =  \
  {                               \
    flags_,                       \
    size_,                        \
                                  \
    name_,                        \
    version_,                     \
    requires_,                    \
                                  \
    interface_,                   \
                                  \
    init_,                        \
    done_,                        \
    get_interface_,               \
  };

FT_END_HEADER

#endif /* FTOBJS_H_ */

/* END */