Home | History | Annotate | Download | only in cff
      1 /***************************************************************************/
      2 /*                                                                         */
      3 /*  cfftypes.h                                                             */
      4 /*                                                                         */
      5 /*    Basic OpenType/CFF type definitions and interface (specification     */
      6 /*    only).                                                               */
      7 /*                                                                         */
      8 /*  Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008 by                   */
      9 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
     10 /*                                                                         */
     11 /*  This file is part of the FreeType project, and may only be used,       */
     12 /*  modified, and distributed under the terms of the FreeType project      */
     13 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
     14 /*  this file you indicate that you have read the license and              */
     15 /*  understand and accept it fully.                                        */
     16 /*                                                                         */
     17 /***************************************************************************/
     18 
     19 
     20 #ifndef __CFFTYPES_H__
     21 #define __CFFTYPES_H__
     22 
     23 
     24 #include <ft2build.h>
     25 #include FT_FREETYPE_H
     26 #include FT_TYPE1_TABLES_H
     27 
     28 
     29 FT_BEGIN_HEADER
     30 
     31 
     32   /*************************************************************************/
     33   /*                                                                       */
     34   /* <Struct>                                                              */
     35   /*    CFF_IndexRec                                                       */
     36   /*                                                                       */
     37   /* <Description>                                                         */
     38   /*    A structure used to model a CFF Index table.                       */
     39   /*                                                                       */
     40   /* <Fields>                                                              */
     41   /*    stream      :: The source input stream.                            */
     42   /*                                                                       */
     43   /*    start       :: The position of the first index byte in the         */
     44   /*                   input stream.                                       */
     45   /*                                                                       */
     46   /*    count       :: The number of elements in the index.                */
     47   /*                                                                       */
     48   /*    off_size    :: The size in bytes of object offsets in index.       */
     49   /*                                                                       */
     50   /*    data_offset :: The position of first data byte in the index's      */
     51   /*                   bytes.                                              */
     52   /*                                                                       */
     53   /*    data_size   :: The size of the data table in this index.           */
     54   /*                                                                       */
     55   /*    offsets     :: A table of element offsets in the index.  Must be   */
     56   /*                   loaded explicitly.                                  */
     57   /*                                                                       */
     58   /*    bytes       :: If the index is loaded in memory, its bytes.        */
     59   /*                                                                       */
     60   typedef struct  CFF_IndexRec_
     61   {
     62     FT_Stream  stream;
     63     FT_ULong   start;
     64     FT_UInt    count;
     65     FT_Byte    off_size;
     66     FT_ULong   data_offset;
     67     FT_ULong   data_size;
     68 
     69     FT_ULong*  offsets;
     70     FT_Byte*   bytes;
     71 
     72   } CFF_IndexRec, *CFF_Index;
     73 
     74 
     75   typedef struct  CFF_EncodingRec_
     76   {
     77     FT_UInt     format;
     78     FT_ULong    offset;
     79 
     80     FT_UInt     count;
     81     FT_UShort   sids [256];  /* avoid dynamic allocations */
     82     FT_UShort   codes[256];
     83 
     84   } CFF_EncodingRec, *CFF_Encoding;
     85 
     86 
     87   typedef struct  CFF_CharsetRec_
     88   {
     89 
     90     FT_UInt     format;
     91     FT_ULong    offset;
     92 
     93     FT_UShort*  sids;
     94     FT_UShort*  cids;       /* the inverse mapping of `sids'; only needed */
     95                             /* for CID-keyed fonts                        */
     96     FT_UInt     max_cid;
     97     FT_UInt     num_glyphs;
     98 
     99   } CFF_CharsetRec, *CFF_Charset;
    100 
    101 
    102   typedef struct  CFF_FontRecDictRec_
    103   {
    104     FT_UInt    version;
    105     FT_UInt    notice;
    106     FT_UInt    copyright;
    107     FT_UInt    full_name;
    108     FT_UInt    family_name;
    109     FT_UInt    weight;
    110     FT_Bool    is_fixed_pitch;
    111     FT_Fixed   italic_angle;
    112     FT_Fixed   underline_position;
    113     FT_Fixed   underline_thickness;
    114     FT_Int     paint_type;
    115     FT_Int     charstring_type;
    116     FT_Matrix  font_matrix;
    117     FT_ULong   units_per_em;  /* temporarily used as scaling value also */
    118     FT_Vector  font_offset;
    119     FT_ULong   unique_id;
    120     FT_BBox    font_bbox;
    121     FT_Pos     stroke_width;
    122     FT_ULong   charset_offset;
    123     FT_ULong   encoding_offset;
    124     FT_ULong   charstrings_offset;
    125     FT_ULong   private_offset;
    126     FT_ULong   private_size;
    127     FT_Long    synthetic_base;
    128     FT_UInt    embedded_postscript;
    129 
    130     /* these should only be used for the top-level font dictionary */
    131     FT_UInt    cid_registry;
    132     FT_UInt    cid_ordering;
    133     FT_Long    cid_supplement;
    134 
    135     FT_Long    cid_font_version;
    136     FT_Long    cid_font_revision;
    137     FT_Long    cid_font_type;
    138     FT_ULong   cid_count;
    139     FT_ULong   cid_uid_base;
    140     FT_ULong   cid_fd_array_offset;
    141     FT_ULong   cid_fd_select_offset;
    142     FT_UInt    cid_font_name;
    143 
    144   } CFF_FontRecDictRec, *CFF_FontRecDict;
    145 
    146 
    147   typedef struct  CFF_PrivateRec_
    148   {
    149     FT_Byte   num_blue_values;
    150     FT_Byte   num_other_blues;
    151     FT_Byte   num_family_blues;
    152     FT_Byte   num_family_other_blues;
    153 
    154     FT_Pos    blue_values[14];
    155     FT_Pos    other_blues[10];
    156     FT_Pos    family_blues[14];
    157     FT_Pos    family_other_blues[10];
    158 
    159     FT_Fixed  blue_scale;
    160     FT_Pos    blue_shift;
    161     FT_Pos    blue_fuzz;
    162     FT_Pos    standard_width;
    163     FT_Pos    standard_height;
    164 
    165     FT_Byte   num_snap_widths;
    166     FT_Byte   num_snap_heights;
    167     FT_Pos    snap_widths[13];
    168     FT_Pos    snap_heights[13];
    169     FT_Bool   force_bold;
    170     FT_Fixed  force_bold_threshold;
    171     FT_Int    lenIV;
    172     FT_Int    language_group;
    173     FT_Fixed  expansion_factor;
    174     FT_Long   initial_random_seed;
    175     FT_ULong  local_subrs_offset;
    176     FT_Pos    default_width;
    177     FT_Pos    nominal_width;
    178 
    179   } CFF_PrivateRec, *CFF_Private;
    180 
    181 
    182   typedef struct  CFF_FDSelectRec_
    183   {
    184     FT_Byte   format;
    185     FT_UInt   range_count;
    186 
    187     /* that's the table, taken from the file `as is' */
    188     FT_Byte*  data;
    189     FT_UInt   data_size;
    190 
    191     /* small cache for format 3 only */
    192     FT_UInt   cache_first;
    193     FT_UInt   cache_count;
    194     FT_Byte   cache_fd;
    195 
    196   } CFF_FDSelectRec, *CFF_FDSelect;
    197 
    198 
    199   /* A SubFont packs a font dict and a private dict together.  They are */
    200   /* needed to support CID-keyed CFF fonts.                             */
    201   typedef struct  CFF_SubFontRec_
    202   {
    203     CFF_FontRecDictRec  font_dict;
    204     CFF_PrivateRec      private_dict;
    205 
    206     CFF_IndexRec        local_subrs_index;
    207     FT_UInt             num_local_subrs;
    208     FT_Byte**           local_subrs;
    209 
    210   } CFF_SubFontRec, *CFF_SubFont;
    211 
    212 
    213   /* maximum number of sub-fonts in a CID-keyed file */
    214 #define CFF_MAX_CID_FONTS  32
    215 
    216 
    217   typedef struct  CFF_FontRec_
    218   {
    219     FT_Stream        stream;
    220     FT_Memory        memory;
    221     FT_UInt          num_faces;
    222     FT_UInt          num_glyphs;
    223 
    224     FT_Byte          version_major;
    225     FT_Byte          version_minor;
    226     FT_Byte          header_size;
    227     FT_Byte          absolute_offsize;
    228 
    229 
    230     CFF_IndexRec     name_index;
    231     CFF_IndexRec     top_dict_index;
    232     CFF_IndexRec     string_index;
    233     CFF_IndexRec     global_subrs_index;
    234 
    235     CFF_EncodingRec  encoding;
    236     CFF_CharsetRec   charset;
    237 
    238     CFF_IndexRec     charstrings_index;
    239     CFF_IndexRec     font_dict_index;
    240     CFF_IndexRec     private_index;
    241     CFF_IndexRec     local_subrs_index;
    242 
    243     FT_String*       font_name;
    244     FT_UInt          num_global_subrs;
    245     FT_Byte**        global_subrs;
    246 
    247     CFF_SubFontRec   top_font;
    248     FT_UInt          num_subfonts;
    249     CFF_SubFont      subfonts[CFF_MAX_CID_FONTS];
    250 
    251     CFF_FDSelectRec  fd_select;
    252 
    253     /* interface to PostScript hinter */
    254     void*            pshinter;
    255 
    256     /* interface to Postscript Names service */
    257     void*            psnames;
    258 
    259     /* since version 2.3.0 */
    260     PS_FontInfoRec*  font_info;   /* font info dictionary */
    261 
    262     /* since version 2.3.6 */
    263     FT_String*       registry;
    264     FT_String*       ordering;
    265 
    266   } CFF_FontRec, *CFF_Font;
    267 
    268 
    269 FT_END_HEADER
    270 
    271 #endif /* __CFFTYPES_H__ */
    272 
    273 
    274 /* END */
    275