1 /***************************************************************************/
2 /*                                                                         */
3 /*  pfrtypes.h                                                             */
4 /*                                                                         */
5 /*    FreeType PFR data structures (specification only).                   */
6 /*                                                                         */
7 /*  Copyright 2002, 2003, 2005, 2007 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   typedef enum  PFR_HeaderFlags_
73   {
74     PFR_FLAG_BLACK_PIXEL   = 1,
75     PFR_FLAG_INVERT_BITMAP = 2
76 
77   } PFR_HeaderFlags;
78 
79 
80   /************************************************************************/
81 
82   typedef struct  PFR_LogFontRec_
83   {
84     FT_UInt32  size;
85     FT_UInt32  offset;
86 
87     FT_Int32   matrix[4];
88     FT_UInt    stroke_flags;
89     FT_Int     stroke_thickness;
90     FT_Int     bold_thickness;
91     FT_Int32   miter_limit;
92 
93     FT_UInt32  phys_size;
94     FT_UInt32  phys_offset;
95 
96   } PFR_LogFontRec, *PFR_LogFont;
97 
98 
99   typedef enum  PFR_LogFlags_
100   {
101     PFR_LOG_EXTRA_ITEMS  = 0x40,
102     PFR_LOG_2BYTE_BOLD   = 0x20,
103     PFR_LOG_BOLD         = 0x10,
104     PFR_LOG_2BYTE_STROKE = 8,
105     PFR_LOG_STROKE       = 4,
106     PFR_LINE_JOIN_MASK   = 3
107 
108   } PFR_LogFlags;
109 
110 
111   typedef enum  PFR_LineJoinFlags_
112   {
113     PFR_LINE_JOIN_MITER = 0,
114     PFR_LINE_JOIN_ROUND = 1,
115     PFR_LINE_JOIN_BEVEL = 2
116 
117   } PFR_LineJoinFlags;
118 
119 
120   /************************************************************************/
121 
122   typedef enum  PFR_BitmapFlags_
123   {
124     PFR_BITMAP_3BYTE_OFFSET   = 4,
125     PFR_BITMAP_2BYTE_SIZE     = 2,
126     PFR_BITMAP_2BYTE_CHARCODE = 1
127 
128   } PFR_BitmapFlags;
129 
130 
131   typedef struct  PFR_BitmapCharRec_
132   {
133     FT_UInt    char_code;
134     FT_UInt    gps_size;
135     FT_UInt32  gps_offset;
136 
137   } PFR_BitmapCharRec, *PFR_BitmapChar;
138 
139 
140   typedef enum  PFR_StrikeFlags_
141   {
142     PFR_STRIKE_2BYTE_COUNT  = 0x10,
143     PFR_STRIKE_3BYTE_OFFSET = 0x08,
144     PFR_STRIKE_3BYTE_SIZE   = 0x04,
145     PFR_STRIKE_2BYTE_YPPM   = 0x02,
146     PFR_STRIKE_2BYTE_XPPM   = 0x01
147 
148   } PFR_StrikeFlags;
149 
150 
151   typedef struct  PFR_StrikeRec_
152   {
153     FT_UInt         x_ppm;
154     FT_UInt         y_ppm;
155     FT_UInt         flags;
156 
157     FT_UInt32       gps_size;
158     FT_UInt32       gps_offset;
159 
160     FT_UInt32       bct_size;
161     FT_UInt32       bct_offset;
162 
163     /* optional */
164     FT_UInt         num_bitmaps;
165     PFR_BitmapChar  bitmaps;
166 
167   } PFR_StrikeRec, *PFR_Strike;
168 
169 
170   /************************************************************************/
171 
172   typedef struct  PFR_CharRec_
173   {
174     FT_UInt    char_code;
175     FT_Int     advance;
176     FT_UInt    gps_size;
177     FT_UInt32  gps_offset;
178 
179   } PFR_CharRec, *PFR_Char;
180 
181 
182   /************************************************************************/
183 
184   typedef struct  PFR_DimensionRec_
185   {
186     FT_UInt  standard;
187     FT_UInt  num_stem_snaps;
188     FT_Int*  stem_snaps;
189 
190   } PFR_DimensionRec, *PFR_Dimension;
191 
192   /************************************************************************/
193 
194   typedef struct PFR_KernItemRec_*  PFR_KernItem;
195 
196   typedef struct  PFR_KernItemRec_
197   {
198     PFR_KernItem  next;
199     FT_Byte       pair_count;
200     FT_Byte       flags;
201     FT_Short      base_adj;
202     FT_UInt       pair_size;
203     FT_Offset     offset;
204     FT_UInt32     pair1;
205     FT_UInt32     pair2;
206 
207   } PFR_KernItemRec;
208 
209 
210 #define PFR_KERN_INDEX( g1, g2 )                          \
211           ( ( (FT_UInt32)(g1) << 16 ) | (FT_UInt16)(g2) )
212 
213 #define PFR_KERN_PAIR_INDEX( pair )                        \
214           PFR_KERN_INDEX( (pair)->glyph1, (pair)->glyph2 )
215 
216 #define PFR_NEXT_KPAIR( p )  ( p += 2,                              \
217                                ( (FT_UInt32)p[-2] << 16 ) | p[-1] )
218 
219 
220   /************************************************************************/
221 
222   typedef struct  PFR_PhyFontRec_
223   {
224     FT_Memory          memory;
225     FT_UInt32          offset;
226 
227     FT_UInt            font_ref_number;
228     FT_UInt            outline_resolution;
229     FT_UInt            metrics_resolution;
230     FT_BBox            bbox;
231     FT_UInt            flags;
232     FT_UInt            standard_advance;
233 
234     FT_Int             ascent;   /* optional, bbox.yMax if not present */
235     FT_Int             descent;  /* optional, bbox.yMin if not present */
236     FT_Int             leading;  /* optional, 0 if not present         */
237 
238     PFR_DimensionRec   horizontal;
239     PFR_DimensionRec   vertical;
240 
241     FT_String*         font_id;
242     FT_String*         family_name;
243     FT_String*         style_name;
244 
245     FT_UInt            num_strikes;
246     FT_UInt            max_strikes;
247     PFR_StrikeRec*     strikes;
248 
249     FT_UInt            num_blue_values;
250     FT_Int            *blue_values;
251     FT_UInt            blue_fuzz;
252     FT_UInt            blue_scale;
253 
254     FT_UInt            num_chars;
255     FT_Offset          chars_offset;
256     PFR_Char           chars;
257 
258     FT_UInt            num_kern_pairs;
259     PFR_KernItem       kern_items;
260     PFR_KernItem*      kern_items_tail;
261 
262     /* not part of the spec, but used during load */
263     FT_Long            bct_offset;
264     FT_Byte*           cursor;
265 
266   } PFR_PhyFontRec, *PFR_PhyFont;
267 
268 
269   typedef enum  PFR_PhyFlags_
270   {
271     PFR_PHY_EXTRA_ITEMS      = 0x80,
272     PFR_PHY_3BYTE_GPS_OFFSET = 0x20,
273     PFR_PHY_2BYTE_GPS_SIZE   = 0x10,
274     PFR_PHY_ASCII_CODE       = 0x08,
275     PFR_PHY_PROPORTIONAL     = 0x04,
276     PFR_PHY_2BYTE_CHARCODE   = 0x02,
277     PFR_PHY_VERTICAL         = 0x01
278 
279   } PFR_PhyFlags;
280 
281 
282   typedef enum PFR_KernFlags_
283   {
284     PFR_KERN_2BYTE_CHAR  = 0x01,
285     PFR_KERN_2BYTE_ADJ   = 0x02
286 
287   } PFR_KernFlags;
288 
289 
290   /************************************************************************/
291 
292   typedef enum  PFR_GlyphFlags_
293   {
294     PFR_GLYPH_IS_COMPOUND   = 0x80,
295     PFR_GLYPH_EXTRA_ITEMS   = 0x08,
296     PFR_GLYPH_1BYTE_XYCOUNT = 0x04,
297     PFR_GLYPH_XCOUNT        = 0x02,
298     PFR_GLYPH_YCOUNT        = 0x01
299 
300   } PFR_GlyphFlags;
301 
302 
303   /* controlled coordinate */
304   typedef struct  PFR_CoordRec_
305   {
306     FT_UInt  org;
307     FT_UInt  cur;
308 
309   } PFR_CoordRec, *PFR_Coord;
310 
311 
312   typedef struct  PFR_SubGlyphRec_
313   {
314     FT_Fixed   x_scale;
315     FT_Fixed   y_scale;
316     FT_Int     x_delta;
317     FT_Int     y_delta;
318     FT_UInt32  gps_offset;
319     FT_UInt    gps_size;
320 
321   } PFR_SubGlyphRec, *PFR_SubGlyph;
322 
323 
324   typedef enum  PFR_SubgGlyphFlags_
325   {
326     PFR_SUBGLYPH_3BYTE_OFFSET = 0x80,
327     PFR_SUBGLYPH_2BYTE_SIZE   = 0x40,
328     PFR_SUBGLYPH_YSCALE       = 0x20,
329     PFR_SUBGLYPH_XSCALE       = 0x10
330 
331   } PFR_SubGlyphFlags;
332 
333 
334   typedef struct  PFR_GlyphRec_
335   {
336     FT_Byte           format;
337 
338 #if 0
339     FT_UInt           num_x_control;
340     FT_UInt           num_y_control;
341 #endif
342     FT_UInt           max_xy_control;
343     FT_Pos*           x_control;
344     FT_Pos*           y_control;
345 
346 
347     FT_UInt           num_subs;
348     FT_UInt           max_subs;
349     PFR_SubGlyphRec*  subs;
350 
351     FT_GlyphLoader    loader;
352     FT_Bool           path_begun;
353 
354   } PFR_GlyphRec, *PFR_Glyph;
355 
356 
357 FT_END_HEADER
358 
359 #endif /* __PFRTYPES_H__ */
360 
361 
362 /* END */
363