1 /***************************************************************************/
5 /* Type 1 parser (specification). */
7 /* Copyright 1996-2000 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
19 /*************************************************************************/
21 /* The Type1 parser component is in charge of simply parsing the font */
22 /* input stream and convert simple tokens and elements into integers, */
23 /* floats, matrices, strings, etc. */
25 /* It is used by the Type1 loader. */
27 /*************************************************************************/
33 #include <freetype/internal/ftstream.h>
36 #ifdef FT_FLAT_COMPILE
42 #include <type1/t1tokens.h>
52 /*************************************************************************/
58 /* An enumeration used to describe the Type 1 parser's state, i.e. */
59 /* which dictionary (or array) it is scanning and processing at the */
62 typedef enum T1_DictState_
65 dict_font
, /* parsing the font dictionary */
66 dict_fontinfo
, /* parsing the font info dictionary */
67 dict_none2
, /* beginning to parse the encrypted section */
68 dict_private
, /* parsing the private dictionary */
69 dict_encoding
, /* parsing the encoding array */
70 dict_subrs
, /* parsing the subrs array */
71 dict_othersubrs
, /* parsing the othersubrs array (?) */
72 dict_charstrings
, /* parsing the charstrings dictionary */
73 dict_unknown_array
, /* parsing/ignoring an unknown array */
74 dict_unknown_dict
, /* parsing/ignoring an unknown dictionary */
76 dict_max
/* do not remove from list */
81 /*************************************************************************/
87 /* A T1_Table is a simple object used to store an array of objects in */
88 /* a single memory block. */
91 /* block :: The address in memory of the growheap's block. This */
92 /* can change between two object adds, due to */
95 /* cursor :: The current top of the grow heap within its block. */
97 /* capacity :: The current size of the heap block. Increments by */
100 /* max_elems :: The maximum number of elements in table. */
102 /* num_elems :: The current number of elements in table. */
104 /* elements :: A table of element addresses within the block. */
106 /* lengths :: A table of element sizes within the block. */
108 /* memory :: The object used for memory operations */
109 /* (alloc/realloc). */
111 typedef struct T1_Table_
113 FT_Byte
* block
; /* current memory block */
114 FT_Int cursor
; /* current cursor in memory block */
115 FT_Int capacity
; /* current size of memory block */
119 FT_Byte
** elements
; /* addresses of table elements */
120 FT_Int
* lengths
; /* lengths of table elements */
127 /*************************************************************************/
133 /* A Type 1 parser. This object is in charge of parsing Type 1 ASCII */
134 /* streams and builds dictionaries for a T1_Face object. */
137 /* error :: The current error code. 0 means success. */
139 /* face :: The target T1_Face object being built. */
141 /* tokenizer :: The tokenizer (lexical analyser) used for */
142 /* processing the input stream. */
144 /* dump_tokens :: XXX */
146 /* stack :: The current token stack. Note that we don't */
147 /* use intermediate Postscript objects here! */
149 /* top :: The current top of token stack. */
151 /* limit :: The current upper bound of the token stack. */
152 /* Used for overflow checks. */
154 /* args :: The arguments of a given operator. Used and */
155 /* increased by the various CopyXXX() functions. */
157 /* state_index :: The index of the top of the dictionary state */
160 /* state_stack :: The dictionary states stack. */
162 /* table :: A T1_Table object used to record various kinds */
163 /* of dictionaries or arrays (like `/Encoding', */
164 /* `/Subrs', `/CharStrings'). */
166 /* cur_name :: XXX */
168 /* encoding_type :: XXX */
170 /* encoding_names :: XXX */
172 /* encoding_lengths :: XXX */
174 /* encoding_offsets :: XXX */
178 /* charstrings :: XXX */
180 typedef struct T1_Parser_
185 T1_Tokenizer tokenizer
;
188 T1_Token stack
[T1_MAX_STACK_DEPTH
];
194 T1_DictState state_stack
[T1_MAX_DICT_DEPTH
];
200 T1_EncodingType encoding_type
;
201 FT_Byte
* encoding_names
;
202 FT_Int
* encoding_lengths
;
203 FT_Byte
** encoding_offsets
;
206 FT_Byte
* charstrings
;
212 FT_Error
T1_New_Table( T1_Table
* table
,
217 FT_Error
T1_Add_Table( T1_Table
* table
,
223 void T1_Done_Table( T1_Table
* table
);
227 FT_String
* CopyString( T1_Parser
* parser
);
230 FT_Long
CopyInteger( T1_Parser
* parser
);
233 FT_Bool
CopyBoolean( T1_Parser
* parser
);
236 FT_Long
CopyFloat( T1_Parser
* parser
,
240 void CopyBBox( T1_Parser
* parser
,
244 void CopyMatrix( T1_Parser
* parser
,
248 void CopyArray( T1_Parser
* parser
,
249 FT_Byte
* num_elements
,
251 FT_Int max_elements
);
258 #endif /* T1PARSE_H */