forsyth20121205-174063a80cc13 years agoHistory
1669 lines · 90.2 KB · C
RawDownload
/***************************************************************************//*                                                                         *//*  tttypes.h                                                              *//*                                                                         *//*    Basic SFNT/TrueType type definitions and interface (specification    *//*    only).                                                               *//*                                                                         *//*  Copyright 1996-2001, 2002 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  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_TableDirRec                                                     */  /*                                                                       */  /* <Description>                                                         */  /*    This structure models a TrueType table directory.  It is used to   */  /*    access the various tables of the font face.                        */  /*                                                                       */  /* <Fields>                                                              */  /*    version       :: The version number; starts with 0x00010000.       */  /*                                                                       */  /*    numTables     :: The number of tables.                             */  /*                                                                       */  /*    searchRange   :: Unused.                                           */  /*                                                                       */  /*    entrySelector :: Unused.                                           */  /*                                                                       */  /*    rangeShift    :: Unused.                                           */  /*                                                                       */  /* <Note>                                                                */  /*    This structure is only used during font opening.                   */  /*                                                                       */  typedef struct  TT_TableDirRec_  {    FT_Fixed   version;        /* should be 0x10000 */    FT_UShort  numTables;      /* number of tables  */     FT_UShort  searchRange;    /* These parameters are only used  */    FT_UShort  entrySelector;  /* for a dichotomy search in the   */    FT_UShort  rangeShift;     /* directory.  We ignore them.     */   } TT_TableDirRec;    /*************************************************************************/  /*                                                                       */  /* <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_CMapDirRec                                                      */  /*                                                                       */  /* <Description>                                                         */  /*    This structure describes the directory of the `cmap' table,        */  /*    containing the font's character mappings table.                    */  /*                                                                       */  /* <Fields>                                                              */  /*    tableVersionNumber :: The version number.                          */  /*                                                                       */  /*    numCMaps           :: The number of charmaps in the font.          */  /*                                                                       */  /* <Note>                                                                */  /*    This structure is only used during font loading.                   */  /*                                                                       */  typedef struct  TT_CMapDirRec_  {    FT_UShort  tableVersionNumber;    FT_UShort  numCMaps;   } TT_CMapDirRec, *TT_CMapDir;    /*************************************************************************/  /*                                                                       */  /* <Struct>                                                              */  /*    TT_CMapDirEntryRec                                                 */  /*                                                                       */  /* <Description>                                                         */  /*    This structure describes a charmap in a TrueType font.             */  /*                                                                       */  /* <Fields>                                                              */  /*    platformID :: An ID used to specify for which platform this        */  /*                  charmap is defined (FreeType manages all platforms). */  /*                                                                       */  /*    encodingID :: A platform-specific ID used to indicate which source */  /*                  encoding is used in this charmap.                    */  /*                                                                       */  /*    offset     :: The offset of the charmap relative to the start of   */  /*                  the `cmap' table.                                    */  /*                                                                       */  /* <Note>                                                                */  /*    This structure is only used during font loading.                   */  /*                                                                       */  typedef struct  TT_CMapDirEntryRec_  {    FT_UShort  platformID;    FT_UShort  platformEncodingID;    FT_Long    offset;   } TT_CMapDirEntryRec, *TT_CMapDirEntry;    /*************************************************************************/  /*                                                                       */  /* <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_NameEntryRec                                                    */  /*                                                                       */  /* <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_NameEntryRec_  {    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_NameEntryRec, *TT_NameEntry;    /*************************************************************************/  /*                                                                       */  /* <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.                        */  /*                                                                       */  /*    stream         :: the file's input stream.                         */  /*                                                                       */  typedef struct  TT_NameTableRec_  {    FT_UShort         format;    FT_UInt           numNameRecords;    FT_UInt           storageOffset;    TT_NameEntryRec*  names;    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;    /*************************************************************************/  /*                                                                       */  /* <Struct>                                                              */  /*    TT_HdmxEntryRec                                                    */  /*                                                                       */  /* <Description>                                                         */  /*    A small structure used to model the pre-computed widths of a given */  /*    size.  They are found in the `hdmx' table.                         */  /*                                                                       */  /* <Fields>                                                              */  /*    ppem      :: The pixels per EM value at which these metrics apply. */  /*                                                                       */  /*    max_width :: The maximum advance width for this metric.            */  /*                                                                       */  /*    widths    :: An array of widths.  Note: These are 8-bit bytes.     */  /*                                                                       */  typedef struct  TT_HdmxEntryRec_  {    FT_Byte   ppem;    FT_Byte   max_width;    FT_Byte*  widths;   } TT_HdmxEntryRec, *TT_HdmxEntry;    /*************************************************************************/  /*                                                                       */  /* <Struct>                                                              */  /*    TT_HdmxRec                                                         */  /*                                                                       */  /* <Description>                                                         */  /*    A structure used to model the `hdmx' table, which contains         */  /*    pre-computed widths for a set of given sizes/dimensions.           */  /*                                                                       */  /* <Fields>                                                              */  /*    version     :: The version number.                                 */  /*                                                                       */  /*    num_records :: The number of hdmx records.                         */  /*                                                                       */  /*    records     :: An array of hdmx records.                           */  /*                                                                       */  typedef struct  TT_HdmxRec_  {    FT_UShort     version;    FT_Short      num_records;    TT_HdmxEntry  records;   } TT_HdmxRec, *TT_Hdmx;    /*************************************************************************/  /*                                                                       */  /* <Struct>                                                              */  /*    TT_Kern0_PairRec                                                   */  /*                                                                       */  /* <Description>                                                         */  /*    A structure used to model a kerning pair for the kerning table     */  /*    format 0.  The engine now loads this table if it finds one in the  */  /*    font file.                                                         */  /*                                                                       */  /* <Fields>                                                              */  /*    left  :: The index of the left glyph in pair.                      */  /*                                                                       */  /*    right :: The index of the right glyph in pair.                     */  /*                                                                       */  /*    value :: The kerning distance.  A positive value spaces the        */  /*             glyphs, a negative one makes them closer.                 */  /*                                                                       */  typedef struct  TT_Kern0_PairRec_  {    FT_UShort  left;   /* index of left  glyph in pair */    FT_UShort  right;  /* index of right glyph in pair */    FT_FWord   value;  /* kerning value                */   } TT_Kern0_PairRec, *TT_Kern0_Pair;    /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /***                                                                   ***/  /***                                                                   ***/  /***                    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>                                                              */

Lines 1–500 of 1669.