]> git.saurik.com Git - wxWidgets.git/blob - src/freetype/type1/t1gload.h
yet another file I added on the wxUniv branch and forgot to merge
[wxWidgets.git] / src / freetype / type1 / t1gload.h
1 /***************************************************************************/
2 /* */
3 /* t1gload.h */
4 /* */
5 /* Type 1 Glyph Loader (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 T1GLOAD_H
20 #define T1GLOAD_H
21
22
23 #ifdef FT_FLAT_COMPILE
24
25 #include "t1objs.h"
26
27 #else
28
29 #include <type1/t1objs.h>
30
31 #endif
32
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38
39 typedef struct T1_Builder_ T1_Builder;
40
41 typedef FT_Error (*T1_Builder_EndChar)( T1_Builder* loader );
42
43 typedef FT_Error (*T1_Builder_Sbw)( T1_Builder* loader,
44 FT_Pos sbx,
45 FT_Pos sby,
46 FT_Pos wx,
47 FT_Pos wy );
48
49 typedef FT_Error (*T1_Builder_ClosePath)( T1_Builder* loader );
50
51 typedef FT_Error (*T1_Builder_RLineTo)( T1_Builder* loader,
52 FT_Pos dx,
53 FT_Pos dy );
54
55 typedef FT_Error (*T1_Builder_RMoveTo)( T1_Builder* loader,
56 FT_Pos dx,
57 FT_Pos dy );
58
59 typedef FT_Error (*T1_Builder_RCurveTo)( T1_Builder* loader,
60 FT_Pos dx1,
61 FT_Pos dy1,
62 FT_Pos dx2,
63 FT_Pos dy2,
64 FT_Pos dx3,
65 FT_Pos dy3 );
66
67
68 /*************************************************************************/
69 /* */
70 /* <Structure> */
71 /* T1_Builder_Funcs */
72 /* */
73 /* <Description> */
74 /* A structure to store the address of various functions used by a */
75 /* glyph builder to implement the outline's `path construction'. */
76 /* */
77 typedef struct T1_Builder_Funcs_
78 {
79 T1_Builder_EndChar end_char;
80 T1_Builder_Sbw set_bearing_point;
81 T1_Builder_ClosePath close_path;
82 T1_Builder_RLineTo rline_to;
83 T1_Builder_RMoveTo rmove_to;
84 T1_Builder_RCurveTo rcurve_to;
85
86 } T1_Builder_Funcs;
87
88
89 /*************************************************************************/
90 /* */
91 /* <Structure> */
92 /* T1_Builder */
93 /* */
94 /* <Description> */
95 /* A structure used during glyph loading to store its outline. */
96 /* */
97 /* <Fields> */
98 /* memory :: The current memory object. */
99 /* */
100 /* face :: The current face object. */
101 /* */
102 /* size :: The current size object. */
103 /* */
104 /* glyph :: The current glyph slot. */
105 /* */
106 /* loader :: The current glyph loader. */
107 /* */
108 /* current :: The current glyph outline. */
109 /* */
110 /* base :: The base glyph outline. */
111 /* */
112 /* last :: The last point position. */
113 /* */
114 /* scale_x :: The horizontal scale (FUnits to sub-pixels). */
115 /* */
116 /* scale_y :: The vertical scale (FUnits to sub-pixels). */
117 /* */
118 /* pos_x :: The horizontal translation (for composite glyphs). */
119 /* */
120 /* pos_y :: The vertical translation (for composite glyphs). */
121 /* */
122 /* left_bearing :: The left side bearing point. */
123 /* */
124 /* advance :: The horizontal advance vector. */
125 /* */
126 /* no_recurse :: */
127 /* */
128 /* bbox :: The glyph's bounding box. */
129 /* */
130 /* path_begun :: A flag which indicates that a new path has begun. */
131 /* */
132 /* load_points :: A flag which indicates, if not set, that no points */
133 /* are loaded. */
134 /* */
135 /* pass :: The pass number for multi-pass hinters. */
136 /* */
137 /* hint_point :: The index of the next point to hint. */
138 /* */
139 /* funcs :: A table of builder functions used to perform the */
140 /* outline's path construction. */
141 /* */
142 struct T1_Builder_
143 {
144 FT_Memory memory;
145 T1_Face face;
146 T1_Size size;
147 T1_GlyphSlot glyph;
148 FT_GlyphLoader* loader;
149
150 FT_Outline* current; /* the current glyph outline */
151 FT_Outline* base; /* the composite glyph outline */
152
153 FT_Vector last;
154
155 FT_Fixed scale_x;
156 FT_Fixed scale_y;
157
158 FT_Pos pos_x;
159 FT_Pos pos_y;
160
161 FT_Vector left_bearing;
162 FT_Vector advance;
163 FT_Bool no_recurse;
164
165 FT_BBox bbox; /* bounding box */
166 FT_Bool path_begun;
167 FT_Bool load_points;
168
169 FT_Int pass;
170 FT_Int hint_point;
171
172 /* path construction function interface */
173 T1_Builder_Funcs funcs;
174 };
175
176
177 typedef FT_Error (*T1_Hinter_ChangeHints)( T1_Builder* builder );
178
179 typedef FT_Error (*T1_Hinter_DotSection)( T1_Builder* builder );
180
181 typedef FT_Error (*T1_Hinter_Stem)( T1_Builder* builder,
182 FT_Pos pos,
183 FT_Pos width,
184 FT_Bool vertical );
185
186 typedef FT_Error (*T1_Hinter_Stem3)( T1_Builder* builder,
187 FT_Pos pos0,
188 FT_Pos width0,
189 FT_Pos pos1,
190 FT_Pos width1,
191 FT_Pos pos2,
192 FT_Pos width2,
193 FT_Bool vertical );
194
195
196 /*************************************************************************/
197 /* */
198 /* <Structure> */
199 /* T1_Hinter_Funcs */
200 /* */
201 /* <Description> */
202 /* A structure to store the address of various functions used by a */
203 /* Type 1 hinter to perform outline hinting. */
204 /* */
205 typedef struct T1_Hinter_Func_
206 {
207 T1_Hinter_ChangeHints change_hints;
208 T1_Hinter_DotSection dot_section;
209 T1_Hinter_Stem stem;
210 T1_Hinter_Stem3 stem3;
211
212 } T1_Hinter_Funcs;
213
214
215 typedef enum T1_Operator_
216 {
217 op_none = 0,
218 op_endchar,
219 op_hsbw,
220 op_seac,
221 op_sbw,
222 op_closepath,
223 op_hlineto,
224 op_hmoveto,
225 op_hvcurveto,
226 op_rlineto,
227 op_rmoveto,
228 op_rrcurveto,
229 op_vhcurveto,
230 op_vlineto,
231 op_vmoveto,
232 op_dotsection,
233 op_hstem,
234 op_hstem3,
235 op_vstem,
236 op_vstem3,
237 op_div,
238 op_callothersubr,
239 op_callsubr,
240 op_pop,
241 op_return,
242 op_setcurrentpoint,
243
244 op_max /* never remove this one */
245
246 } T1_Operator;
247
248
249 /* execution context charstring zone */
250 typedef struct T1_Decoder_Zone_
251 {
252 FT_Byte* base;
253 FT_Byte* limit;
254 FT_Byte* cursor;
255
256 } T1_Decoder_Zone;
257
258
259 typedef struct T1_Decoder_
260 {
261 T1_Builder builder;
262 T1_Hinter_Funcs hinter;
263
264 FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
265 FT_Int* top;
266
267 T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
268 T1_Decoder_Zone* zone;
269
270 FT_Int flex_state;
271 FT_Int num_flex_vectors;
272 FT_Vector flex_vectors[7];
273
274 } T1_Decoder;
275
276
277 LOCAL_DEF
278 void T1_Init_Builder( T1_Builder* builder,
279 T1_Face face,
280 T1_Size size,
281 T1_GlyphSlot glyph,
282 const T1_Builder_Funcs* funcs );
283
284 LOCAL_DEF
285 void T1_Done_Builder( T1_Builder* builder );
286
287 LOCAL_DEF
288 void T1_Init_Decoder( T1_Decoder* decoder,
289 const T1_Hinter_Funcs* funcs );
290
291 LOCAL_DEF
292 FT_Error T1_Compute_Max_Advance( T1_Face face,
293 FT_Int* max_advance );
294
295 LOCAL_DEF
296 FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
297 FT_Byte* charstring_base,
298 FT_Int charstring_len,
299 FT_Int num_subrs,
300 FT_Byte** subrs_base,
301 FT_Int* subrs_len );
302
303 LOCAL_DEF
304 FT_Error T1_Add_Points( T1_Builder* builder,
305 FT_Int num_points );
306
307 LOCAL_DEF
308 FT_Error T1_Add_Contours( T1_Builder* builder,
309 FT_Int num_contours );
310
311 LOCAL_DEF
312 FT_Error T1_Load_Glyph( T1_GlyphSlot glyph,
313 T1_Size size,
314 FT_Int glyph_index,
315 FT_Int load_flags );
316
317
318 #ifdef __cplusplus
319 }
320 #endif
321
322
323 #endif /* T1GLOAD_H */
324
325
326 /* END */