1 /***************************************************************************/ 2 /* */ 3 /* cfftypes.h */ 4 /* */ 5 /* Basic OpenType/CFF type definitions and interface (specification */ 6 /* only). */ 7 /* */ 8 /* Copyright 1996-2016 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 /* the next fields come from the data of the deprecated */ 149 /* `MultipleMaster' operator; they are needed to parse the (also */ 150 /* deprecated) `blend' operator in Type 2 charstrings */ 151 FT_UShort num_designs; 152 FT_UShort num_axes; 153 154 } CFF_FontRecDictRec, *CFF_FontRecDict; 155 156 157 typedef struct CFF_PrivateRec_ 158 { 159 FT_Byte num_blue_values; 160 FT_Byte num_other_blues; 161 FT_Byte num_family_blues; 162 FT_Byte num_family_other_blues; 163 164 FT_Pos blue_values[14]; 165 FT_Pos other_blues[10]; 166 FT_Pos family_blues[14]; 167 FT_Pos family_other_blues[10]; 168 169 FT_Fixed blue_scale; 170 FT_Pos blue_shift; 171 FT_Pos blue_fuzz; 172 FT_Pos standard_width; 173 FT_Pos standard_height; 174 175 FT_Byte num_snap_widths; 176 FT_Byte num_snap_heights; 177 FT_Pos snap_widths[13]; 178 FT_Pos snap_heights[13]; 179 FT_Bool force_bold; 180 FT_Fixed force_bold_threshold; 181 FT_Int lenIV; 182 FT_Int language_group; 183 FT_Fixed expansion_factor; 184 FT_Long initial_random_seed; 185 FT_ULong local_subrs_offset; 186 FT_Pos default_width; 187 FT_Pos nominal_width; 188 189 } CFF_PrivateRec, *CFF_Private; 190 191 192 typedef struct CFF_FDSelectRec_ 193 { 194 FT_Byte format; 195 FT_UInt range_count; 196 197 /* that's the table, taken from the file `as is' */ 198 FT_Byte* data; 199 FT_UInt data_size; 200 201 /* small cache for format 3 only */ 202 FT_UInt cache_first; 203 FT_UInt cache_count; 204 FT_Byte cache_fd; 205 206 } CFF_FDSelectRec, *CFF_FDSelect; 207 208 209 /* A SubFont packs a font dict and a private dict together. They are */ 210 /* needed to support CID-keyed CFF fonts. */ 211 typedef struct CFF_SubFontRec_ 212 { 213 CFF_FontRecDictRec font_dict; 214 CFF_PrivateRec private_dict; 215 216 CFF_IndexRec local_subrs_index; 217 FT_Byte** local_subrs; /* array of pointers into Local Subrs INDEX data */ 218 219 } CFF_SubFontRec, *CFF_SubFont; 220 221 222 #define CFF_MAX_CID_FONTS 256 223 224 225 typedef struct CFF_FontRec_ 226 { 227 FT_Stream stream; 228 FT_Memory memory; 229 FT_UInt num_faces; 230 FT_UInt num_glyphs; 231 232 FT_Byte version_major; 233 FT_Byte version_minor; 234 FT_Byte header_size; 235 FT_Byte absolute_offsize; 236 237 238 CFF_IndexRec name_index; 239 CFF_IndexRec top_dict_index; 240 CFF_IndexRec global_subrs_index; 241 242 CFF_EncodingRec encoding; 243 CFF_CharsetRec charset; 244 245 CFF_IndexRec charstrings_index; 246 CFF_IndexRec font_dict_index; 247 CFF_IndexRec private_index; 248 CFF_IndexRec local_subrs_index; 249 250 FT_String* font_name; 251 252 /* array of pointers into Global Subrs INDEX data */ 253 FT_Byte** global_subrs; 254 255 /* array of pointers into String INDEX data stored at string_pool */ 256 FT_UInt num_strings; 257 FT_Byte** strings; 258 FT_Byte* string_pool; 259 FT_ULong string_pool_size; 260 261 CFF_SubFontRec top_font; 262 FT_UInt num_subfonts; 263 CFF_SubFont subfonts[CFF_MAX_CID_FONTS]; 264 265 CFF_FDSelectRec fd_select; 266 267 /* interface to PostScript hinter */ 268 PSHinter_Service pshinter; 269 270 /* interface to Postscript Names service */ 271 FT_Service_PsCMaps psnames; 272 273 /* since version 2.3.0 */ 274 PS_FontInfoRec* font_info; /* font info dictionary */ 275 276 /* since version 2.3.6 */ 277 FT_String* registry; 278 FT_String* ordering; 279 280 /* since version 2.4.12 */ 281 FT_Generic cf2_instance; 282 283 } CFF_FontRec, *CFF_Font; 284 285 286 FT_END_HEADER 287 288 #endif /* CFFTYPES_H_ */ 289 290 291 /* END */ 292