• 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_ULong   units_per_em;  /* temporarily used as scaling value also */
121     FT_Vector  font_offset;
122     FT_ULong   unique_id;
123     FT_BBox    font_bbox;
124     FT_Pos     stroke_width;
125     FT_ULong   charset_offset;
126     FT_ULong   encoding_offset;
127     FT_ULong   charstrings_offset;
128     FT_ULong   private_offset;
129     FT_ULong   private_size;
130     FT_Long    synthetic_base;
131     FT_UInt    embedded_postscript;
132 
133     /* these should only be used for the top-level font dictionary */
134     FT_UInt    cid_registry;
135     FT_UInt    cid_ordering;
136     FT_Long    cid_supplement;
137 
138     FT_Long    cid_font_version;
139     FT_Long    cid_font_revision;
140     FT_Long    cid_font_type;
141     FT_ULong   cid_count;
142     FT_ULong   cid_uid_base;
143     FT_ULong   cid_fd_array_offset;
144     FT_ULong   cid_fd_select_offset;
145     FT_UInt    cid_font_name;
146 
147   } CFF_FontRecDictRec, *CFF_FontRecDict;
148 
149 
150   typedef struct  CFF_PrivateRec_
151   {
152     FT_Byte   num_blue_values;
153     FT_Byte   num_other_blues;
154     FT_Byte   num_family_blues;
155     FT_Byte   num_family_other_blues;
156 
157     FT_Pos    blue_values[14];
158     FT_Pos    other_blues[10];
159     FT_Pos    family_blues[14];
160     FT_Pos    family_other_blues[10];
161 
162     FT_Fixed  blue_scale;
163     FT_Pos    blue_shift;
164     FT_Pos    blue_fuzz;
165     FT_Pos    standard_width;
166     FT_Pos    standard_height;
167 
168     FT_Byte   num_snap_widths;
169     FT_Byte   num_snap_heights;
170     FT_Pos    snap_widths[13];
171     FT_Pos    snap_heights[13];
172     FT_Bool   force_bold;
173     FT_Fixed  force_bold_threshold;
174     FT_Int    lenIV;
175     FT_Int    language_group;
176     FT_Fixed  expansion_factor;
177     FT_Long   initial_random_seed;
178     FT_ULong  local_subrs_offset;
179     FT_Pos    default_width;
180     FT_Pos    nominal_width;
181 
182   } CFF_PrivateRec, *CFF_Private;
183 
184 
185   typedef struct  CFF_FDSelectRec_
186   {
187     FT_Byte   format;
188     FT_UInt   range_count;
189 
190     /* that's the table, taken from the file `as is' */
191     FT_Byte*  data;
192     FT_UInt   data_size;
193 
194     /* small cache for format 3 only */
195     FT_UInt   cache_first;
196     FT_UInt   cache_count;
197     FT_Byte   cache_fd;
198 
199   } CFF_FDSelectRec, *CFF_FDSelect;
200 
201 
202   /* A SubFont packs a font dict and a private dict together.  They are */
203   /* needed to support CID-keyed CFF fonts.                             */
204   typedef struct  CFF_SubFontRec_
205   {
206     CFF_FontRecDictRec  font_dict;
207     CFF_PrivateRec      private_dict;
208 
209     CFF_IndexRec        local_subrs_index;
210     FT_Byte**           local_subrs; /* array of pointers into Local Subrs INDEX data */
211 
212   } CFF_SubFontRec, *CFF_SubFont;
213 
214 
215 #define CFF_MAX_CID_FONTS  256
216 
217 
218   typedef struct  CFF_FontRec_
219   {
220     FT_Stream        stream;
221     FT_Memory        memory;
222     FT_UInt          num_faces;
223     FT_UInt          num_glyphs;
224 
225     FT_Byte          version_major;
226     FT_Byte          version_minor;
227     FT_Byte          header_size;
228     FT_Byte          absolute_offsize;
229 
230 
231     CFF_IndexRec     name_index;
232     CFF_IndexRec     top_dict_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 
245     /* array of pointers into Global Subrs INDEX data */
246     FT_Byte**        global_subrs;
247 
248     /* array of pointers into String INDEX data stored at string_pool */
249     FT_UInt          num_strings;
250     FT_Byte**        strings;
251     FT_Byte*         string_pool;
252 
253     CFF_SubFontRec   top_font;
254     FT_UInt          num_subfonts;
255     CFF_SubFont      subfonts[CFF_MAX_CID_FONTS];
256 
257     CFF_FDSelectRec  fd_select;
258 
259     /* interface to PostScript hinter */
260     PSHinter_Service  pshinter;
261 
262     /* interface to Postscript Names service */
263     FT_Service_PsCMaps  psnames;
264 
265     /* since version 2.3.0 */
266     PS_FontInfoRec*  font_info;   /* font info dictionary */
267 
268     /* since version 2.3.6 */
269     FT_String*       registry;
270     FT_String*       ordering;
271 
272   } CFF_FontRec, *CFF_Font;
273 
274 
275 FT_END_HEADER
276 
277 #endif /* __CFFTYPES_H__ */
278 
279 
280 /* END */
281