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