xref: /inferno-os/libfreetype/pfrtypes.h (revision 7ef44d652ae9e5e1f5b3465d73684e4a54de73c0)
1 /***************************************************************************/
2 /*                                                                         */
3 /*  pfrtypes.h                                                             */
4 /*                                                                         */
5 /*    FreeType PFR data structures (specification only).                   */
6 /*                                                                         */
7 /*  Copyright 2002 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_UInt       pair_count;
200     FT_UInt       pair_size;
201     FT_Int        base_adj;
202     FT_UInt       flags;
203     FT_UInt32     offset;
204     FT_UInt32     pair1;
205     FT_UInt32     pair2;
206 
207   } PFR_KernItemRec;
208 
209 #define PFR_KERN_INDEX( g1, g2 ) \
210   ( ( (FT_UInt32)(g1) << 16 ) | (FT_UInt16)(g2) )
211 
212   typedef struct  PFR_KernPairRec_
213   {
214     FT_UInt    glyph1;
215     FT_UInt    glyph2;
216     FT_Vector  kerning;
217 
218   } PFR_KernPairRec, *PFR_KernPair;
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     PFR_DimensionRec   horizontal;
235     PFR_DimensionRec   vertical;
236 
237     FT_String*         font_id;
238 
239     FT_UInt            num_strikes;
240     FT_UInt            max_strikes;
241     PFR_StrikeRec*     strikes;
242 
243     FT_UInt            num_blue_values;
244     FT_Int            *blue_values;
245     FT_UInt            blue_fuzz;
246     FT_UInt            blue_scale;
247 
248     FT_UInt            num_chars;
249     FT_UInt32          chars_offset;
250     PFR_Char           chars;
251 
252     FT_UInt            num_kern_pairs;
253     PFR_KernItem       kern_items;
254     PFR_KernItem*      kern_items_tail;
255 
256     /* not part of the spec, but used during load */
257     FT_UInt32          bct_offset;
258     FT_Byte*           cursor;
259 
260   } PFR_PhyFontRec, *PFR_PhyFont;
261 
262 
263   typedef enum  PFR_PhyFlags_
264   {
265     PFR_PHY_EXTRA_ITEMS      = 0x80,
266     PFR_PHY_3BYTE_GPS_OFFSET = 0x20,
267     PFR_PHY_2BYTE_GPS_SIZE   = 0x10,
268     PFR_PHY_ASCII_CODE       = 0x08,
269     PFR_PHY_PROPORTIONAL     = 0x04,
270     PFR_PHY_2BYTE_CHARCODE   = 0x02,
271     PFR_PHY_VERTICAL         = 0x01
272 
273   } PFR_PhyFlags;
274 
275 
276   typedef enum PFR_KernFlags_
277   {
278     PFR_KERN_2BYTE_ADJ   = 0x01,
279     PFR_KERN_2BYTE_CHAR  = 0x02
280 
281   } PFR_KernFlags;
282 
283 
284   /************************************************************************/
285 
286   typedef enum  PFR_GlyphFlags_
287   {
288     PFR_GLYPH_IS_COMPOUND   = 0x80,
289     PFR_GLYPH_EXTRA_ITEMS   = 0x08,
290     PFR_GLYPH_1BYTE_XYCOUNT = 0x04,
291     PFR_GLYPH_XCOUNT        = 0x02,
292     PFR_GLYPH_YCOUNT        = 0x01
293 
294   } PFR_GlyphFlags;
295 
296 
297   /* controlled coordinate */
298   typedef struct  PFR_CoordRec_
299   {
300     FT_UInt  org;
301     FT_UInt  cur;
302 
303   } PFR_CoordRec, *PFR_Coord;
304 
305 
306   typedef struct  PFR_SubGlyphRec_
307   {
308     FT_Fixed   x_scale;
309     FT_Fixed   y_scale;
310     FT_Int     x_delta;
311     FT_Int     y_delta;
312     FT_UInt32  gps_offset;
313     FT_UInt    gps_size;
314 
315   } PFR_SubGlyphRec, *PFR_SubGlyph;
316 
317 
318   typedef enum  PFR_SubgGlyphFlags_
319   {
320     PFR_SUBGLYPH_3BYTE_OFFSET = 0x80,
321     PFR_SUBGLYPH_2BYTE_SIZE   = 0x40,
322     PFR_SUBGLYPH_YSCALE       = 0x20,
323     PFR_SUBGLYPH_XSCALE       = 0x10
324 
325   } PFR_SubGlyphFlags;
326 
327 
328   typedef struct  PFR_GlyphRec_
329   {
330     FT_Byte           format;
331 
332     FT_UInt           num_x_control;
333     FT_UInt           num_y_control;
334     FT_UInt           max_xy_control;
335     FT_Pos*           x_control;
336     FT_Pos*           y_control;
337 
338 
339     FT_UInt           num_subs;
340     FT_UInt           max_subs;
341     PFR_SubGlyphRec*  subs;
342 
343     FT_GlyphLoader    loader;
344     FT_Bool           path_begun;
345 
346   } PFR_GlyphRec, *PFR_Glyph;
347 
348 
349 FT_END_HEADER
350 
351 #endif /* __PFRTYPES_H__ */
352 
353 
354 /* END */
355