]> git.saurik.com Git - wxWidgets.git/blob - src/freetype/truetype/ttinterp.h
This is how wxPlotWindow would look like with the
[wxWidgets.git] / src / freetype / truetype / ttinterp.h
1 /***************************************************************************/
2 /* */
3 /* ttinterp.h */
4 /* */
5 /* TrueType bytecode interpreter (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 TTINTERP_H
20 #define TTINTERP_H
21
22
23 #ifdef FT_FLAT_COMPILE
24
25 #include "ttobjs.h"
26
27 #else
28
29 #include <truetype/ttobjs.h>
30
31 #endif
32
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38
39 #ifndef TT_CONFIG_OPTION_STATIC_INTEPRETER /* indirect implementation */
40
41 #define EXEC_OP_ TT_ExecContext exc,
42 #define EXEC_OP TT_ExecContext exc
43 #define EXEC_ARG_ exc,
44 #define EXEC_ARG exc
45
46 #else /* static implementation */
47
48 #define EXEC_OP_ /* void */
49 #define EXEC_OP /* void */
50 #define EXEC_ARG_ /* void */
51 #define EXEC_ARG /* void */
52
53 #endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */
54
55
56 /*************************************************************************/
57 /* */
58 /* Rounding mode constants. */
59 /* */
60 #define TT_Round_Off 5
61 #define TT_Round_To_Half_Grid 0
62 #define TT_Round_To_Grid 1
63 #define TT_Round_To_Double_Grid 2
64 #define TT_Round_Up_To_Grid 4
65 #define TT_Round_Down_To_Grid 3
66 #define TT_Round_Super 6
67 #define TT_Round_Super_45 7
68
69
70 /*************************************************************************/
71 /* */
72 /* Function types used by the interpreter, depending on various modes */
73 /* (e.g. the rounding mode, whether to render a vertical or horizontal */
74 /* line etc). */
75 /* */
76 /*************************************************************************/
77
78 /* Rounding function */
79 typedef FT_F26Dot6 (*TT_Round_Func)( EXEC_OP_ FT_F26Dot6 distance,
80 FT_F26Dot6 compensation );
81
82 /* Point displacement along the freedom vector routine */
83 typedef void (*TT_Move_Func)( EXEC_OP_ TT_GlyphZone* zone,
84 FT_UInt point,
85 FT_F26Dot6 distance );
86
87 /* Distance projection along one of the projection vectors */
88 typedef FT_F26Dot6 (*TT_Project_Func)( EXEC_OP_ FT_Vector* v1,
89 FT_Vector* v2 );
90
91 /* reading a cvt value. Take care of non-square pixels if necessary */
92 typedef FT_F26Dot6 (*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong index );
93
94 /* setting or moving a cvt value. Take care of non-square pixels */
95 /* if necessary */
96 typedef void (*TT_Set_CVT_Func)( EXEC_OP_ FT_ULong index,
97 FT_F26Dot6 value );
98
99
100 /*************************************************************************/
101 /* */
102 /* This structure defines a call record, used to manage function calls. */
103 /* */
104 typedef struct TT_CallRec_
105 {
106 FT_Int Caller_Range;
107 FT_Long Caller_IP;
108 FT_Long Cur_Count;
109 FT_Long Cur_Restart;
110
111 } TT_CallRec, *TT_CallStack;
112
113
114 /*************************************************************************/
115 /* */
116 /* The main structure for the interpreter which collects all necessary */
117 /* variables and states. */
118 /* */
119 typedef struct TT_ExecContextRec_
120 {
121 TT_Face face;
122 TT_Size size;
123 FT_Memory memory;
124
125 /* instructions state */
126
127 FT_Error error; /* last execution error */
128
129 FT_Long top; /* top of exec. stack */
130
131 FT_UInt stackSize; /* size of exec. stack */
132 FT_Long* stack; /* current exec. stack */
133
134 FT_Long args;
135 FT_UInt new_top; /* new top after exec. */
136
137 TT_GlyphZone zp0, /* zone records */
138 zp1,
139 zp2,
140 pts,
141 twilight;
142
143 FT_Size_Metrics metrics;
144 TT_Size_Metrics tt_metrics; /* size metrics */
145
146 TT_GraphicsState GS; /* current graphics state */
147
148 FT_Int curRange; /* current code range number */
149 FT_Byte* code; /* current code range */
150 FT_Long IP; /* current instruction pointer */
151 FT_Long codeSize; /* size of current range */
152
153 FT_Byte opcode; /* current opcode */
154 FT_Int length; /* length of current opcode */
155
156 FT_Bool step_ins; /* true if the interpreter must */
157 /* increment IP after ins. exec */
158 FT_Long cvtSize;
159 FT_Long* cvt;
160
161 FT_UInt glyphSize; /* glyph instructions buffer size */
162 FT_Byte* glyphIns; /* glyph instructions buffer */
163
164 FT_UInt numFDefs; /* number of function defs */
165 FT_UInt maxFDefs; /* maximum number of function defs */
166 TT_DefArray FDefs; /* table of FDefs entries */
167
168 FT_UInt numIDefs; /* number of instruction defs */
169 FT_UInt maxIDefs; /* maximum number of ins defs */
170 TT_DefArray IDefs; /* table of IDefs entries */
171
172 FT_UInt maxFunc; /* maximum function index */
173 FT_UInt maxIns; /* maximum instruction index */
174
175 FT_Int callTop, /* top of call stack during execution */
176 callSize; /* size of call stack */
177 TT_CallStack callStack; /* call stack */
178
179 FT_UShort maxPoints; /* capacity of this context's `pts' */
180 FT_Short maxContours; /* record, expressed in points and */
181 /* contours. */
182
183 TT_CodeRangeTable codeRangeTable; /* table of valid code ranges */
184 /* useful for the debugger */
185
186 FT_UShort storeSize; /* size of current storage */
187 FT_Long* storage; /* storage area */
188
189 FT_F26Dot6 period; /* values used for the */
190 FT_F26Dot6 phase; /* `SuperRounding' */
191 FT_F26Dot6 threshold;
192
193 #if 0
194 /* this seems to be unused */
195 FT_Int cur_ppem; /* ppem along the current proj vector */
196 #endif
197
198 FT_Bool instruction_trap; /* If `True', the interpreter will */
199 /* exit after each instruction */
200
201 TT_GraphicsState default_GS; /* graphics state resulting from */
202 /* the prep program */
203 FT_Bool is_composite; /* true if the glyph is composite */
204 FT_Bool pedantic_hinting; /* true for pedantic interpretation */
205
206 /* latest interpreter additions */
207
208 FT_Long F_dot_P; /* dot product of freedom and projection */
209 /* vectors */
210 TT_Round_Func func_round; /* current rounding function */
211
212 TT_Project_Func func_project, /* current projection function */
213 func_dualproj, /* current dual proj. function */
214 func_freeProj; /* current freedom proj. func */
215
216 TT_Move_Func func_move; /* current point move function */
217
218 TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */
219 TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
220 TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
221
222 FT_ULong loadSize;
223 TT_SubGlyph_Stack loadStack; /* loading subglyph stack */
224
225 } TT_ExecContextRec;
226
227
228 extern const TT_GraphicsState tt_default_graphics_state;
229
230
231 LOCAL_DEF
232 FT_Error TT_Goto_CodeRange( TT_ExecContext exec,
233 FT_Int range,
234 FT_Long IP );
235
236 LOCAL_DEF
237 FT_Error TT_Set_CodeRange( TT_ExecContext exec,
238 FT_Int range,
239 void* base,
240 FT_Long length );
241
242 LOCAL_DEF
243 FT_Error TT_Clear_CodeRange( TT_ExecContext exec,
244 FT_Int range );
245
246 FT_EXPORT_DEF( TT_ExecContext ) TT_New_Context( TT_Face face );
247
248 LOCAL_DEF
249 FT_Error TT_Done_Context( TT_ExecContext exec );
250
251 LOCAL_DEF
252 FT_Error TT_Destroy_Context( TT_ExecContext exec,
253 FT_Memory memory );
254
255 LOCAL_DEF
256 FT_Error TT_Load_Context( TT_ExecContext exec,
257 TT_Face face,
258 TT_Size size );
259
260 LOCAL_DEF
261 FT_Error TT_Save_Context( TT_ExecContext exec,
262 TT_Size ins );
263
264 LOCAL_DEF
265 FT_Error TT_Run_Context( TT_ExecContext exec,
266 FT_Bool debug );
267
268 FT_EXPORT_DEF( FT_Error ) TT_RunIns( TT_ExecContext exec );
269
270
271 #ifdef __cplusplus
272 }
273 #endif
274
275 #endif /* TTINTERP_H */
276
277
278 /* END */