1 /***************************************************************************/
5 /* Basic OpenType/CFF type definitions and interface (specification */
8 /* Copyright 1996-2018 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
17 /***************************************************************************/
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 #include FT_INTERNAL_TYPE1_TYPES_H
36 /*************************************************************************/
42 /* A structure used to model a CFF Index table. */
45 /* stream :: The source input stream. */
47 /* start :: The position of the first index byte in the */
50 /* count :: The number of elements in the index. */
52 /* off_size :: The size in bytes of object offsets in index. */
54 /* data_offset :: The position of first data byte in the index's */
57 /* data_size :: The size of the data table in this index. */
59 /* offsets :: A table of element offsets in the index. Must be */
60 /* loaded explicitly. */
62 /* bytes :: If the index is loaded in memory, its bytes. */
64 typedef struct CFF_IndexRec_
77 } CFF_IndexRec
, *CFF_Index
;
80 typedef struct CFF_EncodingRec_
86 FT_UShort sids
[256]; /* avoid dynamic allocations */
89 } CFF_EncodingRec
, *CFF_Encoding
;
92 typedef struct CFF_CharsetRec_
99 FT_UShort
* cids
; /* the inverse mapping of `sids'; only needed */
100 /* for CID-keyed fonts */
104 } CFF_CharsetRec
, *CFF_Charset
;
107 /* cf. similar fields in file `ttgxvar.h' from the `truetype' module */
109 typedef struct CFF_VarData_
112 FT_UInt itemCount
; /* not used; always zero */
113 FT_UInt shortDeltaCount
; /* not used; always zero */
116 FT_UInt regionIdxCount
; /* number of region indexes */
117 FT_UInt
* regionIndices
; /* array of `regionIdxCount' indices; */
118 /* these index `varRegionList' */
122 /* contribution of one axis to a region */
123 typedef struct CFF_AxisCoords_
126 FT_Fixed peakCoord
; /* zero peak means no effect (factor = 1) */
132 typedef struct CFF_VarRegion_
134 CFF_AxisCoords
* axisList
; /* array of axisCount records */
139 typedef struct CFF_VStoreRec_
142 CFF_VarData
* varData
; /* array of dataCount records */
143 /* vsindex indexes this array */
145 FT_UInt regionCount
; /* total number of regions defined */
146 CFF_VarRegion
* varRegionList
;
148 } CFF_VStoreRec
, *CFF_VStore
;
151 /* forward reference */
152 typedef struct CFF_FontRec_
* CFF_Font
;
155 /* This object manages one cached blend vector. */
157 /* There is a BlendRec for Private DICT parsing in each subfont */
158 /* and a BlendRec for charstrings in CF2_Font instance data. */
159 /* A cached BV may be used across DICTs or Charstrings if inputs */
160 /* have not changed. */
162 /* `usedBV' is reset at the start of each parse or charstring. */
163 /* vsindex cannot be changed after a BV is used. */
165 /* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */
166 typedef struct CFF_BlendRec_
168 FT_Bool builtBV
; /* blendV has been built */
169 FT_Bool usedBV
; /* blendV has been used */
170 CFF_Font font
; /* top level font struct */
171 FT_UInt lastVsindex
; /* last vsindex used */
172 FT_UInt lenNDV
; /* normDV length (aka numAxes) */
173 FT_Fixed
* lastNDV
; /* last NDV used */
174 FT_UInt lenBV
; /* BlendV length (aka numMasters) */
175 FT_Int32
* BV
; /* current blendV (per DICT/glyph) */
177 } CFF_BlendRec
, *CFF_Blend
;
180 typedef struct CFF_FontRecDictRec_
188 FT_Bool is_fixed_pitch
;
189 FT_Fixed italic_angle
;
190 FT_Fixed underline_position
;
191 FT_Fixed underline_thickness
;
193 FT_Int charstring_type
;
194 FT_Matrix font_matrix
;
195 FT_Bool has_font_matrix
;
196 FT_ULong units_per_em
; /* temporarily used as scaling value also */
197 FT_Vector font_offset
;
201 FT_ULong charset_offset
;
202 FT_ULong encoding_offset
;
203 FT_ULong charstrings_offset
;
204 FT_ULong private_offset
;
205 FT_ULong private_size
;
206 FT_Long synthetic_base
;
207 FT_UInt embedded_postscript
;
209 /* these should only be used for the top-level font dictionary */
210 FT_UInt cid_registry
;
211 FT_UInt cid_ordering
;
212 FT_Long cid_supplement
;
214 FT_Long cid_font_version
;
215 FT_Long cid_font_revision
;
216 FT_Long cid_font_type
;
218 FT_ULong cid_uid_base
;
219 FT_ULong cid_fd_array_offset
;
220 FT_ULong cid_fd_select_offset
;
221 FT_UInt cid_font_name
;
223 /* the next fields come from the data of the deprecated */
224 /* `MultipleMaster' operator; they are needed to parse the (also */
225 /* deprecated) `blend' operator in Type 2 charstrings */
226 FT_UShort num_designs
;
229 /* fields for CFF2 */
230 FT_ULong vstore_offset
;
233 } CFF_FontRecDictRec
, *CFF_FontRecDict
;
236 /* forward reference */
237 typedef struct CFF_SubFontRec_
* CFF_SubFont
;
240 typedef struct CFF_PrivateRec_
242 FT_Byte num_blue_values
;
243 FT_Byte num_other_blues
;
244 FT_Byte num_family_blues
;
245 FT_Byte num_family_other_blues
;
247 FT_Pos blue_values
[14];
248 FT_Pos other_blues
[10];
249 FT_Pos family_blues
[14];
250 FT_Pos family_other_blues
[10];
255 FT_Pos standard_width
;
256 FT_Pos standard_height
;
258 FT_Byte num_snap_widths
;
259 FT_Byte num_snap_heights
;
260 FT_Pos snap_widths
[13];
261 FT_Pos snap_heights
[13];
263 FT_Fixed force_bold_threshold
;
265 FT_Int language_group
;
266 FT_Fixed expansion_factor
;
267 FT_Long initial_random_seed
;
268 FT_ULong local_subrs_offset
;
269 FT_Pos default_width
;
270 FT_Pos nominal_width
;
272 /* fields for CFF2 */
276 } CFF_PrivateRec
, *CFF_Private
;
279 typedef struct CFF_FDSelectRec_
284 /* that's the table, taken from the file `as is' */
288 /* small cache for format 3 only */
293 } CFF_FDSelectRec
, *CFF_FDSelect
;
296 /* A SubFont packs a font dict and a private dict together. They are */
297 /* needed to support CID-keyed CFF fonts. */
298 typedef struct CFF_SubFontRec_
300 CFF_FontRecDictRec font_dict
;
301 CFF_PrivateRec private_dict
;
303 /* fields for CFF2 */
304 CFF_BlendRec blend
; /* current blend vector */
305 FT_UInt lenNDV
; /* current length NDV or zero */
306 FT_Fixed
* NDV
; /* ptr to current NDV or NULL */
308 /* `blend_stack' is a writable buffer to hold blend results. */
309 /* This buffer is to the side of the normal cff parser stack; */
310 /* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */
311 /* The normal stack then points to these values instead of the DICT */
312 /* because all other operators in Private DICT clear the stack. */
313 /* `blend_stack' could be cleared at each operator other than blend. */
314 /* Blended values are stored as 5-byte fixed point values. */
316 FT_Byte
* blend_stack
; /* base of stack allocation */
317 FT_Byte
* blend_top
; /* first empty slot */
318 FT_UInt blend_used
; /* number of bytes in use */
319 FT_UInt blend_alloc
; /* number of bytes allocated */
321 CFF_IndexRec local_subrs_index
;
322 FT_Byte
** local_subrs
; /* array of pointers */
323 /* into Local Subrs INDEX data */
330 #define CFF_MAX_CID_FONTS 256
333 typedef struct CFF_FontRec_
337 FT_Memory memory
; /* TODO: take this from stream->memory? */
338 FT_ULong base_offset
; /* offset to start of CFF */
342 FT_Byte version_major
;
343 FT_Byte version_minor
;
346 FT_UInt top_dict_length
; /* cff2 only */
350 CFF_IndexRec name_index
;
351 CFF_IndexRec top_dict_index
;
352 CFF_IndexRec global_subrs_index
;
354 CFF_EncodingRec encoding
;
355 CFF_CharsetRec charset
;
357 CFF_IndexRec charstrings_index
;
358 CFF_IndexRec font_dict_index
;
359 CFF_IndexRec private_index
;
360 CFF_IndexRec local_subrs_index
;
362 FT_String
* font_name
;
364 /* array of pointers into Global Subrs INDEX data */
365 FT_Byte
** global_subrs
;
367 /* array of pointers into String INDEX data stored at string_pool */
370 FT_Byte
* string_pool
;
371 FT_ULong string_pool_size
;
373 CFF_SubFontRec top_font
;
374 FT_UInt num_subfonts
;
375 CFF_SubFont subfonts
[CFF_MAX_CID_FONTS
];
377 CFF_FDSelectRec fd_select
;
379 /* interface to PostScript hinter */
380 PSHinter_Service pshinter
;
382 /* interface to Postscript Names service */
383 FT_Service_PsCMaps psnames
;
385 /* interface to CFFLoad service */
388 /* since version 2.3.0 */
389 PS_FontInfoRec
* font_info
; /* font info dictionary */
391 /* since version 2.3.6 */
395 /* since version 2.4.12 */
396 FT_Generic cf2_instance
;
398 /* since version 2.7.1 */
399 CFF_VStoreRec vstore
; /* parsed vstore structure */
401 /* since version 2.9 */
402 PS_FontExtraRec
* font_extra
;
409 #endif /* CFFTYPES_H_ */