1 /**************************************************************************** 2 * 3 * pfrtypes.h 4 * 5 * FreeType PFR data structures (specification only). 6 * 7 * Copyright 2002-2018 by 8 * David Turner, Robert Wilhelm, and Werner Lemberg. 9 * 10 * This file is part of the FreeType project, and may only be used, 11 * modified, and distributed under the terms of the FreeType project 12 * license, LICENSE.TXT. By continuing to use, modify, or distribute 13 * this file you indicate that you have read the license and 14 * understand and accept it fully. 15 * 16 */ 17 18 19 #ifndef PFRTYPES_H_ 20 #define PFRTYPES_H_ 21 22 #include <ft2build.h> 23 #include FT_INTERNAL_OBJECTS_H 24 25 FT_BEGIN_HEADER 26 27 /************************************************************************/ 28 29 /* the PFR Header structure */ 30 typedef struct PFR_HeaderRec_ 31 { 32 FT_UInt32 signature; 33 FT_UInt version; 34 FT_UInt signature2; 35 FT_UInt header_size; 36 37 FT_UInt log_dir_size; 38 FT_UInt log_dir_offset; 39 40 FT_UInt log_font_max_size; 41 FT_UInt32 log_font_section_size; 42 FT_UInt32 log_font_section_offset; 43 44 FT_UInt32 phy_font_max_size; 45 FT_UInt32 phy_font_section_size; 46 FT_UInt32 phy_font_section_offset; 47 48 FT_UInt gps_max_size; 49 FT_UInt32 gps_section_size; 50 FT_UInt32 gps_section_offset; 51 52 FT_UInt max_blue_values; 53 FT_UInt max_x_orus; 54 FT_UInt max_y_orus; 55 56 FT_UInt phy_font_max_size_high; 57 FT_UInt color_flags; 58 59 FT_UInt32 bct_max_size; 60 FT_UInt32 bct_set_max_size; 61 FT_UInt32 phy_bct_set_max_size; 62 63 FT_UInt num_phy_fonts; 64 FT_UInt max_vert_stem_snap; 65 FT_UInt max_horz_stem_snap; 66 FT_UInt max_chars; 67 68 } PFR_HeaderRec, *PFR_Header; 69 70 71 /* used in `color_flags' field of the PFR_Header */ 72 #define PFR_FLAG_BLACK_PIXEL 0x01U 73 #define PFR_FLAG_INVERT_BITMAP 0x02U 74 75 76 /************************************************************************/ 77 78 typedef struct PFR_LogFontRec_ 79 { 80 FT_UInt32 size; 81 FT_UInt32 offset; 82 83 FT_Int32 matrix[4]; 84 FT_UInt stroke_flags; 85 FT_Int stroke_thickness; 86 FT_Int bold_thickness; 87 FT_Int32 miter_limit; 88 89 FT_UInt32 phys_size; 90 FT_UInt32 phys_offset; 91 92 } PFR_LogFontRec, *PFR_LogFont; 93 94 95 #define PFR_LINE_JOIN_MITER 0x00U 96 #define PFR_LINE_JOIN_ROUND 0x01U 97 #define PFR_LINE_JOIN_BEVEL 0x02U 98 #define PFR_LINE_JOIN_MASK ( PFR_LINE_JOIN_ROUND | PFR_LINE_JOIN_BEVEL ) 99 100 #define PFR_LOG_STROKE 0x04U 101 #define PFR_LOG_2BYTE_STROKE 0x08U 102 #define PFR_LOG_BOLD 0x10U 103 #define PFR_LOG_2BYTE_BOLD 0x20U 104 #define PFR_LOG_EXTRA_ITEMS 0x40U 105 106 107 /************************************************************************/ 108 109 #define PFR_BITMAP_2BYTE_CHARCODE 0x01U 110 #define PFR_BITMAP_2BYTE_SIZE 0x02U 111 #define PFR_BITMAP_3BYTE_OFFSET 0x04U 112 113 /*not part of the specification but used for implementation */ 114 #define PFR_BITMAP_CHARCODES_VALIDATED 0x40U 115 #define PFR_BITMAP_VALID_CHARCODES 0x80U 116 117 118 typedef struct PFR_BitmapCharRec_ 119 { 120 FT_UInt char_code; 121 FT_UInt gps_size; 122 FT_UInt32 gps_offset; 123 124 } PFR_BitmapCharRec, *PFR_BitmapChar; 125 126 127 #define PFR_STRIKE_2BYTE_XPPM 0x01U 128 #define PFR_STRIKE_2BYTE_YPPM 0x02U 129 #define PFR_STRIKE_3BYTE_SIZE 0x04U 130 #define PFR_STRIKE_3BYTE_OFFSET 0x08U 131 #define PFR_STRIKE_2BYTE_COUNT 0x10U 132 133 134 typedef struct PFR_StrikeRec_ 135 { 136 FT_UInt x_ppm; 137 FT_UInt y_ppm; 138 FT_UInt flags; 139 140 FT_UInt32 gps_size; 141 FT_UInt32 gps_offset; 142 143 FT_UInt32 bct_size; 144 FT_UInt32 bct_offset; 145 146 /* optional */ 147 FT_UInt num_bitmaps; 148 PFR_BitmapChar bitmaps; 149 150 } PFR_StrikeRec, *PFR_Strike; 151 152 153 /************************************************************************/ 154 155 typedef struct PFR_CharRec_ 156 { 157 FT_UInt char_code; 158 FT_Int advance; 159 FT_UInt gps_size; 160 FT_UInt32 gps_offset; 161 162 } PFR_CharRec, *PFR_Char; 163 164 165 /************************************************************************/ 166 167 typedef struct PFR_DimensionRec_ 168 { 169 FT_UInt standard; 170 FT_UInt num_stem_snaps; 171 FT_Int* stem_snaps; 172 173 } PFR_DimensionRec, *PFR_Dimension; 174 175 /************************************************************************/ 176 177 typedef struct PFR_KernItemRec_* PFR_KernItem; 178 179 typedef struct PFR_KernItemRec_ 180 { 181 PFR_KernItem next; 182 FT_Byte pair_count; 183 FT_Byte flags; 184 FT_Short base_adj; 185 FT_UInt pair_size; 186 FT_Offset offset; 187 FT_UInt32 pair1; 188 FT_UInt32 pair2; 189 190 } PFR_KernItemRec; 191 192 193 #define PFR_KERN_INDEX( g1, g2 ) \ 194 ( ( (FT_UInt32)(g1) << 16 ) | (FT_UInt16)(g2) ) 195 196 #define PFR_KERN_PAIR_INDEX( pair ) \ 197 PFR_KERN_INDEX( (pair)->glyph1, (pair)->glyph2 ) 198 199 #define PFR_NEXT_KPAIR( p ) ( p += 2, \ 200 ( (FT_UInt32)p[-2] << 16 ) | p[-1] ) 201 202 203 /************************************************************************/ 204 205 typedef struct PFR_PhyFontRec_ 206 { 207 FT_Memory memory; 208 FT_UInt32 offset; 209 210 FT_UInt font_ref_number; 211 FT_UInt outline_resolution; 212 FT_UInt metrics_resolution; 213 FT_BBox bbox; 214 FT_UInt flags; 215 FT_Int standard_advance; 216 217 FT_Int ascent; /* optional, bbox.yMax if not present */ 218 FT_Int descent; /* optional, bbox.yMin if not present */ 219 FT_Int leading; /* optional, 0 if not present */ 220 221 PFR_DimensionRec horizontal; 222 PFR_DimensionRec vertical; 223 224 FT_String* font_id; 225 FT_String* family_name; 226 FT_String* style_name; 227 228 FT_UInt num_strikes; 229 FT_UInt max_strikes; 230 PFR_StrikeRec* strikes; 231 232 FT_UInt num_blue_values; 233 FT_Int *blue_values; 234 FT_UInt blue_fuzz; 235 FT_UInt blue_scale; 236 237 FT_UInt num_chars; 238 FT_Offset chars_offset; 239 PFR_Char chars; 240 241 FT_UInt num_kern_pairs; 242 PFR_KernItem kern_items; 243 PFR_KernItem* kern_items_tail; 244 245 /* not part of the spec, but used during load */ 246 FT_ULong bct_offset; 247 FT_Byte* cursor; 248 249 } PFR_PhyFontRec, *PFR_PhyFont; 250 251 252 #define PFR_PHY_VERTICAL 0x01U 253 #define PFR_PHY_2BYTE_CHARCODE 0x02U 254 #define PFR_PHY_PROPORTIONAL 0x04U 255 #define PFR_PHY_ASCII_CODE 0x08U 256 #define PFR_PHY_2BYTE_GPS_SIZE 0x10U 257 #define PFR_PHY_3BYTE_GPS_OFFSET 0x20U 258 #define PFR_PHY_EXTRA_ITEMS 0x80U 259 260 261 #define PFR_KERN_2BYTE_CHAR 0x01U 262 #define PFR_KERN_2BYTE_ADJ 0x02U 263 264 265 /************************************************************************/ 266 267 #define PFR_GLYPH_YCOUNT 0x01U 268 #define PFR_GLYPH_XCOUNT 0x02U 269 #define PFR_GLYPH_1BYTE_XYCOUNT 0x04U 270 271 #define PFR_GLYPH_SINGLE_EXTRA_ITEMS 0x08U 272 #define PFR_GLYPH_COMPOUND_EXTRA_ITEMS 0x40U 273 274 #define PFR_GLYPH_IS_COMPOUND 0x80U 275 276 277 /* controlled coordinate */ 278 typedef struct PFR_CoordRec_ 279 { 280 FT_UInt org; 281 FT_UInt cur; 282 283 } PFR_CoordRec, *PFR_Coord; 284 285 286 typedef struct PFR_SubGlyphRec_ 287 { 288 FT_Fixed x_scale; 289 FT_Fixed y_scale; 290 FT_Int x_delta; 291 FT_Int y_delta; 292 FT_UInt32 gps_offset; 293 FT_UInt gps_size; 294 295 } PFR_SubGlyphRec, *PFR_SubGlyph; 296 297 298 #define PFR_SUBGLYPH_XSCALE 0x10U 299 #define PFR_SUBGLYPH_YSCALE 0x20U 300 #define PFR_SUBGLYPH_2BYTE_SIZE 0x40U 301 #define PFR_SUBGLYPH_3BYTE_OFFSET 0x80U 302 303 304 typedef struct PFR_GlyphRec_ 305 { 306 FT_Byte format; 307 308 #if 0 309 FT_UInt num_x_control; 310 FT_UInt num_y_control; 311 #endif 312 FT_UInt max_xy_control; 313 FT_Pos* x_control; 314 FT_Pos* y_control; 315 316 317 FT_UInt num_subs; 318 FT_UInt max_subs; 319 PFR_SubGlyphRec* subs; 320 321 FT_GlyphLoader loader; 322 FT_Bool path_begun; 323 324 } PFR_GlyphRec, *PFR_Glyph; 325 326 327 FT_END_HEADER 328 329 #endif /* PFRTYPES_H_ */ 330 331 332 /* END */ 333