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