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