]> git.saurik.com Git - wxWidgets.git/blame - src/freetype/type1z/z1parse.h
added wxMGL+DOS+Watcom makefiles
[wxWidgets.git] / src / freetype / type1z / z1parse.h
CommitLineData
cabec872
RR
1/***************************************************************************/
2/* */
3/* z1parse.h */
4/* */
5/* Experimental Type 1 parser (specification). */
6/* */
7/* Copyright 1996-2000 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 Z1PARSE_H
20#define Z1PARSE_H
21
22#include <freetype/internal/t1types.h>
23
24#ifdef __cplusplus
25 extern "C" {
26#endif
27
28
29 /* simple enumeration type used to identify token types */
30 typedef enum Z1_Token_Type_
31 {
32 t1_token_none = 0,
33 t1_token_any,
34 t1_token_string,
35 t1_token_array,
36
37 /* do not remove */
38 t1_token_max
39
40 } Z1_Token_Type;
41
42
43 /* a simple structure used to identify tokens */
44 typedef struct Z1_Token_Rec_
45 {
46 FT_Byte* start; /* first character of token in input stream */
47 FT_Byte* limit; /* first character after the token */
48 Z1_Token_Type type; /* type of token.. */
49
50 } Z1_Token_Rec;
51
52
53 /* enumeration type used to identify object fields */
54 typedef enum Z1_Field_Type_
55 {
56 t1_field_none = 0,
57 t1_field_bool,
58 t1_field_integer,
59 t1_field_fixed,
60 t1_field_string,
61 t1_field_integer_array,
62 t1_field_fixed_array,
63
64 /* do not remove */
65 t1_field_max
66
67 } Z1_Field_Type;
68
69
70 /* structure type used to model object fields */
71 typedef struct Z1_Field_Rec_
72 {
73 Z1_Field_Type type; /* type of field */
74 FT_UInt offset; /* offset of field in object */
75 FT_UInt size; /* size of field in bytes */
76 FT_UInt array_max; /* maximum number of elements for array */
77 FT_UInt count_offset; /* offset of element count for arrays */
78 FT_Int flag_bit; /* bit number for field flag */
79
80 } Z1_Field_Rec;
81
82
83#define Z1_FIELD_REF( s, f ) ( ((s*)0)->f )
84
85#define Z1_FIELD_BOOL( _ftype, _fname ) \
86 { \
87 t1_field_bool, \
88 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
89 sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
90 0, 0, 0 \
91 }
92
93#define Z1_FIELD_NUM( _ftype, _fname ) \
94 { \
95 t1_field_integer, \
96 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
97 sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
98 0, 0, 0 \
99 }
100
101#define Z1_FIELD_FIXED( _ftype, _fname, _power ) \
102 { \
103 t1_field_fixed, \
104 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
105 sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
106 0, 0, 0 \
107 }
108
109#define Z1_FIELD_STRING( _ftype, _fname ) \
110 { \
111 t1_field_string, \
112 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
113 sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
114 0, 0, 0 \
115 }
116
117#define Z1_FIELD_NUM_ARRAY( _ftype, _fname, _fcount, _fmax ) \
118 { \
119 t1_field_integer, \
120 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
121 sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
122 _fmax, \
123 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fcount ), \
124 0 \
125 }
126
127#define Z1_FIELD_FIXED_ARRAY( _ftype, _fname, _fcount, _fmax ) \
128 { \
129 t1_field_fixed, \
130 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
131 sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
132 _fmax, \
133 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fcount ), \
134 0 \
135 }
136
137#define Z1_FIELD_NUM_ARRAY2( _ftype, _fname, _fmax ) \
138 { \
139 t1_field_integer, \
140 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
141 sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
142 _fmax, \
143 0, 0 \
144 }
145
146#define Z1_FIELD_FIXED_ARRAY2( _ftype, _fname, _fmax ) \
147 { \
148 t1_field_fixed, \
149 (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
150 sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
151 _fmax, \
152 0, 0 \
153 }
154
155
156 /*************************************************************************/
157 /* */
158 /* <Struct> */
159 /* Z1_Table */
160 /* */
161 /* <Description> */
162 /* A Z1_Table is a simple object used to store an array of objects in */
163 /* a single memory block. */
164 /* */
165 /* <Fields> */
166 /* block :: The address in memory of the growheap's block. This */
167 /* can change between two object adds, due to the use of */
168 /* reallocation. */
169 /* */
170 /* cursor :: The current top of the grow heap within its block. */
171 /* */
172 /* capacity :: The current size of the heap block. Increments in */
173 /* 1kByte blocks. */
174 /* */
175 /* init :: A boolean. Set when the table has been initialized */
176 /* (the table user should set this field). */
177 /* */
178 /* max_elems :: The maximum number of elements in the table. */
179 /* */
180 /* num_elems :: The current number of elements in the table. */
181 /* */
182 /* elements :: A table of element addresses within the block. */
183 /* */
184 /* lengths :: A table of element sizes within the block. */
185 /* */
186 /* memory :: The memory object used for memory operations */
187 /* (allocation/reallocation). */
188 /* */
189 typedef struct Z1_Table_
190 {
191 FT_Byte* block; /* current memory block */
192 FT_Int cursor; /* current cursor in memory block */
193 FT_Int capacity; /* current size of memory block */
194 FT_Long init;
195
196 FT_Int max_elems;
197 FT_Int num_elems;
198 FT_Byte** elements; /* addresses of table elements */
199 FT_Int* lengths; /* lengths of table elements */
200
201 FT_Memory memory;
202
203 } Z1_Table;
204
205
206 /*************************************************************************/
207 /* */
208 /* <Struct> */
209 /* Z1_Parser */
210 /* */
211 /* <Description> */
212 /* A Z1_Parser is an object used to parse a Type 1 fonts very */
213 /* quickly. */
214 /* */
215 /* <Fields> */
216 /* stream :: The current input stream. */
217 /* */
218 /* memory :: The current memory object. */
219 /* */
220 /* base_dict :: A pointer to the top-level dictionary. */
221 /* */
222 /* base_len :: The length in bytes of the top dictionary. */
223 /* */
224 /* private_dict :: A pointer to the private dictionary. */
225 /* */
226 /* private_len :: The length in bytes of the private dictionary. */
227 /* */
228 /* in_pfb :: A boolean. Indicates that we are handling a PFB */
229 /* file. */
230 /* */
231 /* in_memory :: A boolean. Indicates a memory-based stream. */
232 /* */
233 /* single_block :: A boolean. Indicates that the private dictionary */
234 /* is stored in lieu of the base dictionary. */
235 /* */
236 /* cursor :: The current parser cursor. */
237 /* */
238 /* limit :: The current parser limit (first byte after the */
239 /* current dictionary). */
240 /* */
241 /* error :: The current parsing error. */
242 /* */
243 typedef struct Z1_Parser_
244 {
245 FT_Stream stream;
246 FT_Memory memory;
247
248 FT_Byte* base_dict;
249 FT_Int base_len;
250
251 FT_Byte* private_dict;
252 FT_Int private_len;
253
254 FT_Byte in_pfb;
255 FT_Byte in_memory;
256 FT_Byte single_block;
257
258 FT_Byte* cursor;
259 FT_Byte* limit;
260 FT_Error error;
261
262 } Z1_Parser;
263
264
265 LOCAL_DEF
266 FT_Error Z1_New_Table( Z1_Table* table,
267 FT_Int count,
268 FT_Memory memory );
269
270
271 LOCAL_DEF
272 FT_Error Z1_Add_Table( Z1_Table* table,
273 FT_Int index,
274 void* object,
275 FT_Int length );
276
277#if 0
278 LOCAL_DEF
279 void Z1_Done_Table( Z1_Table* table );
280#endif
281
282 LOCAL_DEF
283 void Z1_Release_Table( Z1_Table* table );
284
285 LOCAL_DEF
286 FT_Long Z1_ToInt( Z1_Parser* parser );
287
288 LOCAL_DEF
289 FT_Long Z1_ToFixed( Z1_Parser* parser,
290 FT_Int power_ten );
291
292 LOCAL_DEF
293 FT_Int Z1_ToCoordArray( Z1_Parser* parser,
294 FT_Int max_coords,
295 FT_Short* coords );
296
297 LOCAL_DEF
298 FT_Int Z1_ToFixedArray( Z1_Parser* parser,
299 FT_Int max_values,
300 FT_Fixed* values,
301 FT_Int power_ten );
302
303#if 0
304 LOCAL_DEF
305 FT_String* Z1_ToString( Z1_Parser* parser );
306
307 LOCAL_DEF
308 FT_Bool Z1_ToBool( Z1_Parser* parser );
309#endif
310
311
312 LOCAL_DEF
313 void Z1_Skip_Spaces( Z1_Parser* parser );
314
315 LOCAL_DEF
316 void Z1_ToToken( Z1_Parser* parser,
317 Z1_Token_Rec* token );
318
319 LOCAL_FUNC
320 void Z1_ToTokenArray( Z1_Parser* parser,
321 Z1_Token_Rec* tokens,
322 FT_UInt max_tokens,
323 FT_Int* pnum_tokens );
324
325 LOCAL_DEF
326 FT_Error Z1_Load_Field( Z1_Parser* parser,
327 const Z1_Field_Rec* field,
328 void** objects,
329 FT_UInt max_objects,
330 FT_ULong* pflags );
331
332 LOCAL_DEF
333 FT_Error Z1_Load_Field_Table( Z1_Parser* parser,
334 const Z1_Field_Rec* field,
335 void** objects,
336 FT_UInt max_objects,
337 FT_ULong* pflags );
338
339
340 LOCAL_DEF
341 FT_Error Z1_New_Parser( Z1_Parser* parser,
342 FT_Stream stream,
343 FT_Memory memory );
344
345 LOCAL_DEF
346 FT_Error Z1_Get_Private_Dict( Z1_Parser* parser );
347
348 LOCAL_DEF
349 void Z1_Decrypt( FT_Byte* buffer,
350 FT_Int length,
351 FT_UShort seed );
352
353 LOCAL_DEF
354 void Z1_Done_Parser( Z1_Parser* parser );
355
356#ifdef __cplusplus
357 }
358#endif
359
360#endif /* Z1PARSE_H */
361
362
363/* END */