1 | /***************************************************************************/ |
---|
2 | /* */ |
---|
3 | /* psaux.h */ |
---|
4 | /* */ |
---|
5 | /* Auxiliary functions and data structures related to PostScript fonts */ |
---|
6 | /* (specification). */ |
---|
7 | /* */ |
---|
8 | /* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2008, 2009 by */ |
---|
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 __PSAUX_H__ |
---|
21 | #define __PSAUX_H__ |
---|
22 | |
---|
23 | |
---|
24 | #include <ft2build.h> |
---|
25 | #include FT_INTERNAL_OBJECTS_H |
---|
26 | #include FT_INTERNAL_TYPE1_TYPES_H |
---|
27 | #include FT_SERVICE_POSTSCRIPT_CMAPS_H |
---|
28 | |
---|
29 | |
---|
30 | FT_BEGIN_HEADER |
---|
31 | |
---|
32 | |
---|
33 | /*************************************************************************/ |
---|
34 | /*************************************************************************/ |
---|
35 | /***** *****/ |
---|
36 | /***** T1_TABLE *****/ |
---|
37 | /***** *****/ |
---|
38 | /*************************************************************************/ |
---|
39 | /*************************************************************************/ |
---|
40 | |
---|
41 | |
---|
42 | typedef struct PS_TableRec_* PS_Table; |
---|
43 | typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs; |
---|
44 | |
---|
45 | |
---|
46 | /*************************************************************************/ |
---|
47 | /* */ |
---|
48 | /* <Struct> */ |
---|
49 | /* PS_Table_FuncsRec */ |
---|
50 | /* */ |
---|
51 | /* <Description> */ |
---|
52 | /* A set of function pointers to manage PS_Table objects. */ |
---|
53 | /* */ |
---|
54 | /* <Fields> */ |
---|
55 | /* table_init :: Used to initialize a table. */ |
---|
56 | /* */ |
---|
57 | /* table_done :: Finalizes resp. destroy a given table. */ |
---|
58 | /* */ |
---|
59 | /* table_add :: Adds a new object to a table. */ |
---|
60 | /* */ |
---|
61 | /* table_release :: Releases table data, then finalizes it. */ |
---|
62 | /* */ |
---|
63 | typedef struct PS_Table_FuncsRec_ |
---|
64 | { |
---|
65 | FT_Error |
---|
66 | (*init)( PS_Table table, |
---|
67 | FT_Int count, |
---|
68 | FT_Memory memory ); |
---|
69 | |
---|
70 | void |
---|
71 | (*done)( PS_Table table ); |
---|
72 | |
---|
73 | FT_Error |
---|
74 | (*add)( PS_Table table, |
---|
75 | FT_Int idx, |
---|
76 | void* object, |
---|
77 | FT_PtrDist length ); |
---|
78 | |
---|
79 | void |
---|
80 | (*release)( PS_Table table ); |
---|
81 | |
---|
82 | } PS_Table_FuncsRec; |
---|
83 | |
---|
84 | |
---|
85 | /*************************************************************************/ |
---|
86 | /* */ |
---|
87 | /* <Struct> */ |
---|
88 | /* PS_TableRec */ |
---|
89 | /* */ |
---|
90 | /* <Description> */ |
---|
91 | /* A PS_Table is a simple object used to store an array of objects in */ |
---|
92 | /* a single memory block. */ |
---|
93 | /* */ |
---|
94 | /* <Fields> */ |
---|
95 | /* block :: The address in memory of the growheap's block. This */ |
---|
96 | /* can change between two object adds, due to */ |
---|
97 | /* reallocation. */ |
---|
98 | /* */ |
---|
99 | /* cursor :: The current top of the grow heap within its block. */ |
---|
100 | /* */ |
---|
101 | /* capacity :: The current size of the heap block. Increments by */ |
---|
102 | /* 1kByte chunks. */ |
---|
103 | /* */ |
---|
104 | /* max_elems :: The maximum number of elements in table. */ |
---|
105 | /* */ |
---|
106 | /* num_elems :: The current number of elements in table. */ |
---|
107 | /* */ |
---|
108 | /* elements :: A table of element addresses within the block. */ |
---|
109 | /* */ |
---|
110 | /* lengths :: A table of element sizes within the block. */ |
---|
111 | /* */ |
---|
112 | /* memory :: The object used for memory operations */ |
---|
113 | /* (alloc/realloc). */ |
---|
114 | /* */ |
---|
115 | /* funcs :: A table of method pointers for this object. */ |
---|
116 | /* */ |
---|
117 | typedef struct PS_TableRec_ |
---|
118 | { |
---|
119 | FT_Byte* block; /* current memory block */ |
---|
120 | FT_Offset cursor; /* current cursor in memory block */ |
---|
121 | FT_Offset capacity; /* current size of memory block */ |
---|
122 | FT_Long init; |
---|
123 | |
---|
124 | FT_Int max_elems; |
---|
125 | FT_Int num_elems; |
---|
126 | FT_Byte** elements; /* addresses of table elements */ |
---|
127 | FT_PtrDist* lengths; /* lengths of table elements */ |
---|
128 | |
---|
129 | FT_Memory memory; |
---|
130 | PS_Table_FuncsRec funcs; |
---|
131 | |
---|
132 | } PS_TableRec; |
---|
133 | |
---|
134 | |
---|
135 | /*************************************************************************/ |
---|
136 | /*************************************************************************/ |
---|
137 | /***** *****/ |
---|
138 | /***** T1 FIELDS & TOKENS *****/ |
---|
139 | /***** *****/ |
---|
140 | /*************************************************************************/ |
---|
141 | /*************************************************************************/ |
---|
142 | |
---|
143 | typedef struct PS_ParserRec_* PS_Parser; |
---|
144 | |
---|
145 | typedef struct T1_TokenRec_* T1_Token; |
---|
146 | |
---|
147 | typedef struct T1_FieldRec_* T1_Field; |
---|
148 | |
---|
149 | |
---|
150 | /* simple enumeration type used to identify token types */ |
---|
151 | typedef enum T1_TokenType_ |
---|
152 | { |
---|
153 | T1_TOKEN_TYPE_NONE = 0, |
---|
154 | T1_TOKEN_TYPE_ANY, |
---|
155 | T1_TOKEN_TYPE_STRING, |
---|
156 | T1_TOKEN_TYPE_ARRAY, |
---|
157 | T1_TOKEN_TYPE_KEY, /* aka `name' */ |
---|
158 | |
---|
159 | /* do not remove */ |
---|
160 | T1_TOKEN_TYPE_MAX |
---|
161 | |
---|
162 | } T1_TokenType; |
---|
163 | |
---|
164 | |
---|
165 | /* a simple structure used to identify tokens */ |
---|
166 | typedef struct T1_TokenRec_ |
---|
167 | { |
---|
168 | FT_Byte* start; /* first character of token in input stream */ |
---|
169 | FT_Byte* limit; /* first character after the token */ |
---|
170 | T1_TokenType type; /* type of token */ |
---|
171 | |
---|
172 | } T1_TokenRec; |
---|
173 | |
---|
174 | |
---|
175 | /* enumeration type used to identify object fields */ |
---|
176 | typedef enum T1_FieldType_ |
---|
177 | { |
---|
178 | T1_FIELD_TYPE_NONE = 0, |
---|
179 | T1_FIELD_TYPE_BOOL, |
---|
180 | T1_FIELD_TYPE_INTEGER, |
---|
181 | T1_FIELD_TYPE_FIXED, |
---|
182 | T1_FIELD_TYPE_FIXED_1000, |
---|
183 | T1_FIELD_TYPE_STRING, |
---|
184 | T1_FIELD_TYPE_KEY, |
---|
185 | T1_FIELD_TYPE_BBOX, |
---|
186 | T1_FIELD_TYPE_INTEGER_ARRAY, |
---|
187 | T1_FIELD_TYPE_FIXED_ARRAY, |
---|
188 | T1_FIELD_TYPE_CALLBACK, |
---|
189 | |
---|
190 | /* do not remove */ |
---|
191 | T1_FIELD_TYPE_MAX |
---|
192 | |
---|
193 | } T1_FieldType; |
---|
194 | |
---|
195 | |
---|
196 | typedef enum T1_FieldLocation_ |
---|
197 | { |
---|
198 | T1_FIELD_LOCATION_CID_INFO, |
---|
199 | T1_FIELD_LOCATION_FONT_DICT, |
---|
200 | T1_FIELD_LOCATION_FONT_INFO, |
---|
201 | T1_FIELD_LOCATION_PRIVATE, |
---|
202 | T1_FIELD_LOCATION_BBOX, |
---|
203 | T1_FIELD_LOCATION_LOADER, |
---|
204 | T1_FIELD_LOCATION_FACE, |
---|
205 | T1_FIELD_LOCATION_BLEND, |
---|
206 | |
---|
207 | /* do not remove */ |
---|
208 | T1_FIELD_LOCATION_MAX |
---|
209 | |
---|
210 | } T1_FieldLocation; |
---|
211 | |
---|
212 | |
---|
213 | typedef void |
---|
214 | (*T1_Field_ParseFunc)( FT_Face face, |
---|
215 | FT_Pointer parser ); |
---|
216 | |
---|
217 | |
---|
218 | /* structure type used to model object fields */ |
---|
219 | typedef struct T1_FieldRec_ |
---|
220 | { |
---|
221 | const char* ident; /* field identifier */ |
---|
222 | T1_FieldLocation location; |
---|
223 | T1_FieldType type; /* type of field */ |
---|
224 | T1_Field_ParseFunc reader; |
---|
225 | FT_UInt offset; /* offset of field in object */ |
---|
226 | FT_Byte size; /* size of field in bytes */ |
---|
227 | FT_UInt array_max; /* maximal number of elements for */ |
---|
228 | /* array */ |
---|
229 | FT_UInt count_offset; /* offset of element count for */ |
---|
230 | /* arrays; must not be zero if in */ |
---|
231 | /* use -- in other words, a */ |
---|
232 | /* `num_FOO' element must not */ |
---|
233 | /* start the used structure if we */ |
---|
234 | /* parse a `FOO' array */ |
---|
235 | FT_UInt dict; /* where we expect it */ |
---|
236 | } T1_FieldRec; |
---|
237 | |
---|
238 | #define T1_FIELD_DICT_FONTDICT ( 1 << 0 ) /* also FontInfo and FDArray */ |
---|
239 | #define T1_FIELD_DICT_PRIVATE ( 1 << 1 ) |
---|
240 | |
---|
241 | |
---|
242 | |
---|
243 | #define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \ |
---|
244 | { \ |
---|
245 | _ident, T1CODE, _type, \ |
---|
246 | 0, \ |
---|
247 | FT_FIELD_OFFSET( _fname ), \ |
---|
248 | FT_FIELD_SIZE( _fname ), \ |
---|
249 | 0, 0, \ |
---|
250 | _dict \ |
---|
251 | }, |
---|
252 | |
---|
253 | #define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \ |
---|
254 | { \ |
---|
255 | _ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \ |
---|
256 | (T1_Field_ParseFunc)_reader, \ |
---|
257 | 0, 0, \ |
---|
258 | 0, 0, \ |
---|
259 | _dict \ |
---|
260 | }, |
---|
261 | |
---|
262 | #define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \ |
---|
263 | { \ |
---|
264 | _ident, T1CODE, _type, \ |
---|
265 | 0, \ |
---|
266 | FT_FIELD_OFFSET( _fname ), \ |
---|
267 | FT_FIELD_SIZE_DELTA( _fname ), \ |
---|
268 | _max, \ |
---|
269 | FT_FIELD_OFFSET( num_ ## _fname ), \ |
---|
270 | _dict \ |
---|
271 | }, |
---|
272 | |
---|
273 | #define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \ |
---|
274 | { \ |
---|
275 | _ident, T1CODE, _type, \ |
---|
276 | 0, \ |
---|
277 | FT_FIELD_OFFSET( _fname ), \ |
---|
278 | FT_FIELD_SIZE_DELTA( _fname ), \ |
---|
279 | _max, 0, \ |
---|
280 | _dict \ |
---|
281 | }, |
---|
282 | |
---|
283 | |
---|
284 | #define T1_FIELD_BOOL( _ident, _fname, _dict ) \ |
---|
285 | T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict ) |
---|
286 | |
---|
287 | #define T1_FIELD_NUM( _ident, _fname, _dict ) \ |
---|
288 | T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict ) |
---|
289 | |
---|
290 | #define T1_FIELD_FIXED( _ident, _fname, _dict ) \ |
---|
291 | T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict ) |
---|
292 | |
---|
293 | #define T1_FIELD_FIXED_1000( _ident, _fname, _dict ) \ |
---|
294 | T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \ |
---|
295 | _dict ) |
---|
296 | |
---|
297 | #define T1_FIELD_STRING( _ident, _fname, _dict ) \ |
---|
298 | T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict ) |
---|
299 | |
---|
300 | #define T1_FIELD_KEY( _ident, _fname, _dict ) \ |
---|
301 | T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict ) |
---|
302 | |
---|
303 | #define T1_FIELD_BBOX( _ident, _fname, _dict ) \ |
---|
304 | T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict ) |
---|
305 | |
---|
306 | |
---|
307 | #define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict ) \ |
---|
308 | T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \ |
---|
309 | _fname, _fmax, _dict ) |
---|
310 | |
---|
311 | #define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict ) \ |
---|
312 | T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \ |
---|
313 | _fname, _fmax, _dict ) |
---|
314 | |
---|
315 | #define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict ) \ |
---|
316 | T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \ |
---|
317 | _fname, _fmax, _dict ) |
---|
318 | |
---|
319 | #define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict ) \ |
---|
320 | T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \ |
---|
321 | _fname, _fmax, _dict ) |
---|
322 | |
---|
323 | #define T1_FIELD_CALLBACK( _ident, _name, _dict ) \ |
---|
324 | T1_NEW_CALLBACK_FIELD( _ident, _name, _dict ) |
---|
325 | |
---|
326 | |
---|
327 | /*************************************************************************/ |
---|
328 | /*************************************************************************/ |
---|
329 | /***** *****/ |
---|
330 | /***** T1 PARSER *****/ |
---|
331 | /***** *****/ |
---|
332 | /*************************************************************************/ |
---|
333 | /*************************************************************************/ |
---|
334 | |
---|
335 | typedef const struct PS_Parser_FuncsRec_* PS_Parser_Funcs; |
---|
336 | |
---|
337 | typedef struct PS_Parser_FuncsRec_ |
---|
338 | { |
---|
339 | void |
---|
340 | (*init)( PS_Parser parser, |
---|
341 | FT_Byte* base, |
---|
342 | FT_Byte* limit, |
---|
343 | FT_Memory memory ); |
---|
344 | |
---|
345 | void |
---|
346 | (*done)( PS_Parser parser ); |
---|
347 | |
---|
348 | void |
---|
349 | (*skip_spaces)( PS_Parser parser ); |
---|
350 | void |
---|
351 | (*skip_PS_token)( PS_Parser parser ); |
---|
352 | |
---|
353 | FT_Long |
---|
354 | (*to_int)( PS_Parser parser ); |
---|
355 | FT_Fixed |
---|
356 | (*to_fixed)( PS_Parser parser, |
---|
357 | FT_Int power_ten ); |
---|
358 | |
---|
359 | FT_Error |
---|
360 | (*to_bytes)( PS_Parser parser, |
---|
361 | FT_Byte* bytes, |
---|
362 | FT_Long max_bytes, |
---|
363 | FT_Long* pnum_bytes, |
---|
364 | FT_Bool delimiters ); |
---|
365 | |
---|
366 | FT_Int |
---|
367 | (*to_coord_array)( PS_Parser parser, |
---|
368 | FT_Int max_coords, |
---|
369 | FT_Short* coords ); |
---|
370 | FT_Int |
---|
371 | (*to_fixed_array)( PS_Parser parser, |
---|
372 | FT_Int max_values, |
---|
373 | FT_Fixed* values, |
---|
374 | FT_Int power_ten ); |
---|
375 | |
---|
376 | void |
---|
377 | (*to_token)( PS_Parser parser, |
---|
378 | T1_Token token ); |
---|
379 | void |
---|
380 | (*to_token_array)( PS_Parser parser, |
---|
381 | T1_Token tokens, |
---|
382 | FT_UInt max_tokens, |
---|
383 | FT_Int* pnum_tokens ); |
---|
384 | |
---|
385 | FT_Error |
---|
386 | (*load_field)( PS_Parser parser, |
---|
387 | const T1_Field field, |
---|
388 | void** objects, |
---|
389 | FT_UInt max_objects, |
---|
390 | FT_ULong* pflags ); |
---|
391 | |
---|
392 | FT_Error |
---|
393 | (*load_field_table)( PS_Parser parser, |
---|
394 | const T1_Field field, |
---|
395 | void** objects, |
---|
396 | FT_UInt max_objects, |
---|
397 | FT_ULong* pflags ); |
---|
398 | |
---|
399 | } PS_Parser_FuncsRec; |
---|
400 | |
---|
401 | |
---|
402 | /*************************************************************************/ |
---|
403 | /* */ |
---|
404 | /* <Struct> */ |
---|
405 | /* PS_ParserRec */ |
---|
406 | /* */ |
---|
407 | /* <Description> */ |
---|
408 | /* A PS_Parser is an object used to parse a Type 1 font very quickly. */ |
---|
409 | /* */ |
---|
410 | /* <Fields> */ |
---|
411 | /* cursor :: The current position in the text. */ |
---|
412 | /* */ |
---|
413 | /* base :: Start of the processed text. */ |
---|
414 | /* */ |
---|
415 | /* limit :: End of the processed text. */ |
---|
416 | /* */ |
---|
417 | /* error :: The last error returned. */ |
---|
418 | /* */ |
---|
419 | /* memory :: The object used for memory operations (alloc/realloc). */ |
---|
420 | /* */ |
---|
421 | /* funcs :: A table of functions for the parser. */ |
---|
422 | /* */ |
---|
423 | typedef struct PS_ParserRec_ |
---|
424 | { |
---|
425 | FT_Byte* cursor; |
---|
426 | FT_Byte* base; |
---|
427 | FT_Byte* limit; |
---|
428 | FT_Error error; |
---|
429 | FT_Memory memory; |
---|
430 | |
---|
431 | PS_Parser_FuncsRec funcs; |
---|
432 | |
---|
433 | } PS_ParserRec; |
---|
434 | |
---|
435 | |
---|
436 | /*************************************************************************/ |
---|
437 | /*************************************************************************/ |
---|
438 | /***** *****/ |
---|
439 | /***** T1 BUILDER *****/ |
---|
440 | /***** *****/ |
---|
441 | /*************************************************************************/ |
---|
442 | /*************************************************************************/ |
---|
443 | |
---|
444 | |
---|
445 | typedef struct T1_BuilderRec_* T1_Builder; |
---|
446 | |
---|
447 | |
---|
448 | typedef FT_Error |
---|
449 | (*T1_Builder_Check_Points_Func)( T1_Builder builder, |
---|
450 | FT_Int count ); |
---|
451 | |
---|
452 | typedef void |
---|
453 | (*T1_Builder_Add_Point_Func)( T1_Builder builder, |
---|
454 | FT_Pos x, |
---|
455 | FT_Pos y, |
---|
456 | FT_Byte flag ); |
---|
457 | |
---|
458 | typedef FT_Error |
---|
459 | (*T1_Builder_Add_Point1_Func)( T1_Builder builder, |
---|
460 | FT_Pos x, |
---|
461 | FT_Pos y ); |
---|
462 | |
---|
463 | typedef FT_Error |
---|
464 | (*T1_Builder_Add_Contour_Func)( T1_Builder builder ); |
---|
465 | |
---|
466 | typedef FT_Error |
---|
467 | (*T1_Builder_Start_Point_Func)( T1_Builder builder, |
---|
468 | FT_Pos x, |
---|
469 | FT_Pos y ); |
---|
470 | |
---|
471 | typedef void |
---|
472 | (*T1_Builder_Close_Contour_Func)( T1_Builder builder ); |
---|
473 | |
---|
474 | |
---|
475 | typedef const struct T1_Builder_FuncsRec_* T1_Builder_Funcs; |
---|
476 | |
---|
477 | typedef struct T1_Builder_FuncsRec_ |
---|
478 | { |
---|
479 | void |
---|
480 | (*init)( T1_Builder builder, |
---|
481 | FT_Face face, |
---|
482 | FT_Size size, |
---|
483 | FT_GlyphSlot slot, |
---|
484 | FT_Bool hinting ); |
---|
485 | |
---|
486 | void |
---|
487 | (*done)( T1_Builder builder ); |
---|
488 | |
---|
489 | T1_Builder_Check_Points_Func check_points; |
---|
490 | T1_Builder_Add_Point_Func add_point; |
---|
491 | T1_Builder_Add_Point1_Func add_point1; |
---|
492 | T1_Builder_Add_Contour_Func add_contour; |
---|
493 | T1_Builder_Start_Point_Func start_point; |
---|
494 | T1_Builder_Close_Contour_Func close_contour; |
---|
495 | |
---|
496 | } T1_Builder_FuncsRec; |
---|
497 | |
---|
498 | |
---|
499 | /* an enumeration type to handle charstring parsing states */ |
---|
500 | typedef enum T1_ParseState_ |
---|
501 | { |
---|
502 | T1_Parse_Start, |
---|
503 | T1_Parse_Have_Width, |
---|
504 | T1_Parse_Have_Moveto, |
---|
505 | T1_Parse_Have_Path |
---|
506 | |
---|
507 | } T1_ParseState; |
---|
508 | |
---|
509 | |
---|
510 | /*************************************************************************/ |
---|
511 | /* */ |
---|
512 | /* <Structure> */ |
---|
513 | /* T1_BuilderRec */ |
---|
514 | /* */ |
---|
515 | /* <Description> */ |
---|
516 | /* A structure used during glyph loading to store its outline. */ |
---|
517 | /* */ |
---|
518 | /* <Fields> */ |
---|
519 | /* memory :: The current memory object. */ |
---|
520 | /* */ |
---|
521 | /* face :: The current face object. */ |
---|
522 | /* */ |
---|
523 | /* glyph :: The current glyph slot. */ |
---|
524 | /* */ |
---|
525 | /* loader :: XXX */ |
---|
526 | /* */ |
---|
527 | /* base :: The base glyph outline. */ |
---|
528 | /* */ |
---|
529 | /* current :: The current glyph outline. */ |
---|
530 | /* */ |
---|
531 | /* max_points :: maximum points in builder outline */ |
---|
532 | /* */ |
---|
533 | /* max_contours :: Maximal number of contours in builder outline. */ |
---|
534 | /* */ |
---|
535 | /* last :: The last point position. */ |
---|
536 | /* */ |
---|
537 | /* pos_x :: The horizontal translation (if composite glyph). */ |
---|
538 | /* */ |
---|
539 | /* pos_y :: The vertical translation (if composite glyph). */ |
---|
540 | /* */ |
---|
541 | /* left_bearing :: The left side bearing point. */ |
---|
542 | /* */ |
---|
543 | /* advance :: The horizontal advance vector. */ |
---|
544 | /* */ |
---|
545 | /* bbox :: Unused. */ |
---|
546 | /* */ |
---|
547 | /* parse_state :: An enumeration which controls the charstring */ |
---|
548 | /* parsing state. */ |
---|
549 | /* */ |
---|
550 | /* load_points :: If this flag is not set, no points are loaded. */ |
---|
551 | /* */ |
---|
552 | /* no_recurse :: Set but not used. */ |
---|
553 | /* */ |
---|
554 | /* metrics_only :: A boolean indicating that we only want to compute */ |
---|
555 | /* the metrics of a given glyph, not load all of its */ |
---|
556 | /* points. */ |
---|
557 | /* */ |
---|
558 | /* funcs :: An array of function pointers for the builder. */ |
---|
559 | /* */ |
---|
560 | typedef struct T1_BuilderRec_ |
---|
561 | { |
---|
562 | FT_Memory memory; |
---|
563 | FT_Face face; |
---|
564 | FT_GlyphSlot glyph; |
---|
565 | FT_GlyphLoader loader; |
---|
566 | FT_Outline* base; |
---|
567 | FT_Outline* current; |
---|
568 | |
---|
569 | FT_Vector last; |
---|
570 | |
---|
571 | FT_Pos pos_x; |
---|
572 | FT_Pos pos_y; |
---|
573 | |
---|
574 | FT_Vector left_bearing; |
---|
575 | FT_Vector advance; |
---|
576 | |
---|
577 | FT_BBox bbox; /* bounding box */ |
---|
578 | T1_ParseState parse_state; |
---|
579 | FT_Bool load_points; |
---|
580 | FT_Bool no_recurse; |
---|
581 | FT_Bool shift; |
---|
582 | |
---|
583 | FT_Bool metrics_only; |
---|
584 | |
---|
585 | void* hints_funcs; /* hinter-specific */ |
---|
586 | void* hints_globals; /* hinter-specific */ |
---|
587 | |
---|
588 | T1_Builder_FuncsRec funcs; |
---|
589 | |
---|
590 | } T1_BuilderRec; |
---|
591 | |
---|
592 | |
---|
593 | /*************************************************************************/ |
---|
594 | /*************************************************************************/ |
---|
595 | /***** *****/ |
---|
596 | /***** T1 DECODER *****/ |
---|
597 | /***** *****/ |
---|
598 | /*************************************************************************/ |
---|
599 | /*************************************************************************/ |
---|
600 | |
---|
601 | #if 0 |
---|
602 | |
---|
603 | /*************************************************************************/ |
---|
604 | /* */ |
---|
605 | /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ |
---|
606 | /* calls during glyph loading. */ |
---|
607 | /* */ |
---|
608 | #define T1_MAX_SUBRS_CALLS 8 |
---|
609 | |
---|
610 | |
---|
611 | /*************************************************************************/ |
---|
612 | /* */ |
---|
613 | /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ |
---|
614 | /* minimum of 16 is required. */ |
---|
615 | /* */ |
---|
616 | #define T1_MAX_CHARSTRINGS_OPERANDS 32 |
---|
617 | |
---|
618 | #endif /* 0 */ |
---|
619 | |
---|
620 | |
---|
621 | typedef struct T1_Decoder_ZoneRec_ |
---|
622 | { |
---|
623 | FT_Byte* cursor; |
---|
624 | FT_Byte* base; |
---|
625 | FT_Byte* limit; |
---|
626 | |
---|
627 | } T1_Decoder_ZoneRec, *T1_Decoder_Zone; |
---|
628 | |
---|
629 | |
---|
630 | typedef struct T1_DecoderRec_* T1_Decoder; |
---|
631 | typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs; |
---|
632 | |
---|
633 | |
---|
634 | typedef FT_Error |
---|
635 | (*T1_Decoder_Callback)( T1_Decoder decoder, |
---|
636 | FT_UInt glyph_index ); |
---|
637 | |
---|
638 | |
---|
639 | typedef struct T1_Decoder_FuncsRec_ |
---|
640 | { |
---|
641 | FT_Error |
---|
642 | (*init)( T1_Decoder decoder, |
---|
643 | FT_Face face, |
---|
644 | FT_Size size, |
---|
645 | FT_GlyphSlot slot, |
---|
646 | FT_Byte** glyph_names, |
---|
647 | PS_Blend blend, |
---|
648 | FT_Bool hinting, |
---|
649 | FT_Render_Mode hint_mode, |
---|
650 | T1_Decoder_Callback callback ); |
---|
651 | |
---|
652 | void |
---|
653 | (*done)( T1_Decoder decoder ); |
---|
654 | |
---|
655 | FT_Error |
---|
656 | (*parse_charstrings)( T1_Decoder decoder, |
---|
657 | FT_Byte* base, |
---|
658 | FT_UInt len ); |
---|
659 | |
---|
660 | } T1_Decoder_FuncsRec; |
---|
661 | |
---|
662 | |
---|
663 | typedef struct T1_DecoderRec_ |
---|
664 | { |
---|
665 | T1_BuilderRec builder; |
---|
666 | |
---|
667 | FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS]; |
---|
668 | FT_Long* top; |
---|
669 | |
---|
670 | T1_Decoder_ZoneRec zones[T1_MAX_SUBRS_CALLS + 1]; |
---|
671 | T1_Decoder_Zone zone; |
---|
672 | |
---|
673 | FT_Service_PsCMaps psnames; /* for seac */ |
---|
674 | FT_UInt num_glyphs; |
---|
675 | FT_Byte** glyph_names; |
---|
676 | |
---|
677 | FT_Int lenIV; /* internal for sub routine calls */ |
---|
678 | FT_UInt num_subrs; |
---|
679 | FT_Byte** subrs; |
---|
680 | FT_PtrDist* subrs_len; /* array of subrs length (optional) */ |
---|
681 | |
---|
682 | FT_Matrix font_matrix; |
---|
683 | FT_Vector font_offset; |
---|
684 | |
---|
685 | FT_Int flex_state; |
---|
686 | FT_Int num_flex_vectors; |
---|
687 | FT_Vector flex_vectors[7]; |
---|
688 | |
---|
689 | PS_Blend blend; /* for multiple master support */ |
---|
690 | |
---|
691 | FT_Render_Mode hint_mode; |
---|
692 | |
---|
693 | T1_Decoder_Callback parse_callback; |
---|
694 | T1_Decoder_FuncsRec funcs; |
---|
695 | |
---|
696 | FT_Int* buildchar; |
---|
697 | FT_UInt len_buildchar; |
---|
698 | |
---|
699 | } T1_DecoderRec; |
---|
700 | |
---|
701 | |
---|
702 | /*************************************************************************/ |
---|
703 | /*************************************************************************/ |
---|
704 | /***** *****/ |
---|
705 | /***** AFM PARSER *****/ |
---|
706 | /***** *****/ |
---|
707 | /*************************************************************************/ |
---|
708 | /*************************************************************************/ |
---|
709 | |
---|
710 | typedef struct AFM_ParserRec_* AFM_Parser; |
---|
711 | |
---|
712 | typedef struct AFM_Parser_FuncsRec_ |
---|
713 | { |
---|
714 | FT_Error |
---|
715 | (*init)( AFM_Parser parser, |
---|
716 | FT_Memory memory, |
---|
717 | FT_Byte* base, |
---|
718 | FT_Byte* limit ); |
---|
719 | |
---|
720 | void |
---|
721 | (*done)( AFM_Parser parser ); |
---|
722 | |
---|
723 | FT_Error |
---|
724 | (*parse)( AFM_Parser parser ); |
---|
725 | |
---|
726 | } AFM_Parser_FuncsRec; |
---|
727 | |
---|
728 | |
---|
729 | typedef struct AFM_StreamRec_* AFM_Stream; |
---|
730 | |
---|
731 | |
---|
732 | /*************************************************************************/ |
---|
733 | /* */ |
---|
734 | /* <Struct> */ |
---|
735 | /* AFM_ParserRec */ |
---|
736 | /* */ |
---|
737 | /* <Description> */ |
---|
738 | /* An AFM_Parser is a parser for the AFM files. */ |
---|
739 | /* */ |
---|
740 | /* <Fields> */ |
---|
741 | /* memory :: The object used for memory operations (alloc and */ |
---|
742 | /* realloc). */ |
---|
743 | /* */ |
---|
744 | /* stream :: This is an opaque object. */ |
---|
745 | /* */ |
---|
746 | /* FontInfo :: The result will be stored here. */ |
---|
747 | /* */ |
---|
748 | /* get_index :: A user provided function to get a glyph index by its */ |
---|
749 | /* name. */ |
---|
750 | /* */ |
---|
751 | typedef struct AFM_ParserRec_ |
---|
752 | { |
---|
753 | FT_Memory memory; |
---|
754 | AFM_Stream stream; |
---|
755 | |
---|
756 | AFM_FontInfo FontInfo; |
---|
757 | |
---|
758 | FT_Int |
---|
759 | (*get_index)( const char* name, |
---|
760 | FT_UInt len, |
---|
761 | void* user_data ); |
---|
762 | |
---|
763 | void* user_data; |
---|
764 | |
---|
765 | } AFM_ParserRec; |
---|
766 | |
---|
767 | |
---|
768 | /*************************************************************************/ |
---|
769 | /*************************************************************************/ |
---|
770 | /***** *****/ |
---|
771 | /***** TYPE1 CHARMAPS *****/ |
---|
772 | /***** *****/ |
---|
773 | /*************************************************************************/ |
---|
774 | /*************************************************************************/ |
---|
775 | |
---|
776 | typedef const struct T1_CMap_ClassesRec_* T1_CMap_Classes; |
---|
777 | |
---|
778 | typedef struct T1_CMap_ClassesRec_ |
---|
779 | { |
---|
780 | FT_CMap_Class standard; |
---|
781 | FT_CMap_Class expert; |
---|
782 | FT_CMap_Class custom; |
---|
783 | FT_CMap_Class unicode; |
---|
784 | |
---|
785 | } T1_CMap_ClassesRec; |
---|
786 | |
---|
787 | |
---|
788 | /*************************************************************************/ |
---|
789 | /*************************************************************************/ |
---|
790 | /***** *****/ |
---|
791 | /***** PSAux Module Interface *****/ |
---|
792 | /***** *****/ |
---|
793 | /*************************************************************************/ |
---|
794 | /*************************************************************************/ |
---|
795 | |
---|
796 | typedef struct PSAux_ServiceRec_ |
---|
797 | { |
---|
798 | /* don't use `PS_Table_Funcs' and friends to avoid compiler warnings */ |
---|
799 | const PS_Table_FuncsRec* ps_table_funcs; |
---|
800 | const PS_Parser_FuncsRec* ps_parser_funcs; |
---|
801 | const T1_Builder_FuncsRec* t1_builder_funcs; |
---|
802 | const T1_Decoder_FuncsRec* t1_decoder_funcs; |
---|
803 | |
---|
804 | void |
---|
805 | (*t1_decrypt)( FT_Byte* buffer, |
---|
806 | FT_Offset length, |
---|
807 | FT_UShort seed ); |
---|
808 | |
---|
809 | T1_CMap_Classes t1_cmap_classes; |
---|
810 | |
---|
811 | /* fields after this comment line were added after version 2.1.10 */ |
---|
812 | const AFM_Parser_FuncsRec* afm_parser_funcs; |
---|
813 | |
---|
814 | } PSAux_ServiceRec, *PSAux_Service; |
---|
815 | |
---|
816 | /* backwards-compatible type definition */ |
---|
817 | typedef PSAux_ServiceRec PSAux_Interface; |
---|
818 | |
---|
819 | |
---|
820 | /*************************************************************************/ |
---|
821 | /*************************************************************************/ |
---|
822 | /***** *****/ |
---|
823 | /***** Some convenience functions *****/ |
---|
824 | /***** *****/ |
---|
825 | /*************************************************************************/ |
---|
826 | /*************************************************************************/ |
---|
827 | |
---|
828 | #define IS_PS_NEWLINE( ch ) \ |
---|
829 | ( (ch) == '\r' || \ |
---|
830 | (ch) == '\n' ) |
---|
831 | |
---|
832 | #define IS_PS_SPACE( ch ) \ |
---|
833 | ( (ch) == ' ' || \ |
---|
834 | IS_PS_NEWLINE( ch ) || \ |
---|
835 | (ch) == '\t' || \ |
---|
836 | (ch) == '\f' || \ |
---|
837 | (ch) == '\0' ) |
---|
838 | |
---|
839 | #define IS_PS_SPECIAL( ch ) \ |
---|
840 | ( (ch) == '/' || \ |
---|
841 | (ch) == '(' || (ch) == ')' || \ |
---|
842 | (ch) == '<' || (ch) == '>' || \ |
---|
843 | (ch) == '[' || (ch) == ']' || \ |
---|
844 | (ch) == '{' || (ch) == '}' || \ |
---|
845 | (ch) == '%' ) |
---|
846 | |
---|
847 | #define IS_PS_DELIM( ch ) \ |
---|
848 | ( IS_PS_SPACE( ch ) || \ |
---|
849 | IS_PS_SPECIAL( ch ) ) |
---|
850 | |
---|
851 | #define IS_PS_DIGIT( ch ) \ |
---|
852 | ( (ch) >= '0' && (ch) <= '9' ) |
---|
853 | |
---|
854 | #define IS_PS_XDIGIT( ch ) \ |
---|
855 | ( IS_PS_DIGIT( ch ) || \ |
---|
856 | ( (ch) >= 'A' && (ch) <= 'F' ) || \ |
---|
857 | ( (ch) >= 'a' && (ch) <= 'f' ) ) |
---|
858 | |
---|
859 | #define IS_PS_BASE85( ch ) \ |
---|
860 | ( (ch) >= '!' && (ch) <= 'u' ) |
---|
861 | |
---|
862 | #define IS_PS_TOKEN( cur, limit, token ) \ |
---|
863 | ( (char)(cur)[0] == (token)[0] && \ |
---|
864 | ( (cur) + sizeof ( (token) ) == (limit) || \ |
---|
865 | ( (cur) + sizeof( (token) ) < (limit) && \ |
---|
866 | IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) ) && \ |
---|
867 | ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 ) |
---|
868 | |
---|
869 | |
---|
870 | FT_END_HEADER |
---|
871 | |
---|
872 | #endif /* __PSAUX_H__ */ |
---|
873 | |
---|
874 | |
---|
875 | /* END */ |
---|