ttinterp.h

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  ttinterp.h                                                             */
00004 /*                                                                         */
00005 /*    TrueType bytecode interpreter (specification).                       */
00006 /*                                                                         */
00007 /*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by             */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 
00019 #ifndef __TTINTERP_H__
00020 #define __TTINTERP_H__
00021 
00022 #include <ft2build.h>
00023 #include "ttobjs.h"
00024 
00025 
00026 FT_BEGIN_HEADER
00027 
00028 
00029 #ifndef TT_CONFIG_OPTION_STATIC_INTERPRETER /* indirect implementation */
00030 
00031 #define EXEC_OP_   TT_ExecContext  exc,
00032 #define EXEC_OP    TT_ExecContext  exc
00033 #define EXEC_ARG_  exc,
00034 #define EXEC_ARG   exc
00035 
00036 #else                                       /* static implementation */
00037 
00038 #define EXEC_OP_   /* void */
00039 #define EXEC_OP    /* void */
00040 #define EXEC_ARG_  /* void */
00041 #define EXEC_ARG   /* void */
00042 
00043 #endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */
00044 
00045 
00046   /*************************************************************************/
00047   /*                                                                       */
00048   /* Rounding mode constants.                                              */
00049   /*                                                                       */
00050 #define TT_Round_Off             5
00051 #define TT_Round_To_Half_Grid    0
00052 #define TT_Round_To_Grid         1
00053 #define TT_Round_To_Double_Grid  2
00054 #define TT_Round_Up_To_Grid      4
00055 #define TT_Round_Down_To_Grid    3
00056 #define TT_Round_Super           6
00057 #define TT_Round_Super_45        7
00058 
00059 
00060   /*************************************************************************/
00061   /*                                                                       */
00062   /* Function types used by the interpreter, depending on various modes    */
00063   /* (e.g. the rounding mode, whether to render a vertical or horizontal   */
00064   /* line etc).                                                            */
00065   /*                                                                       */
00066   /*************************************************************************/
00067 
00068   /* Rounding function */
00069   typedef FT_F26Dot6
00070   (*TT_Round_Func)( EXEC_OP_ FT_F26Dot6  distance,
00071                              FT_F26Dot6  compensation );
00072 
00073   /* Point displacement along the freedom vector routine */
00074   typedef void
00075   (*TT_Move_Func)( EXEC_OP_ TT_GlyphZone  zone,
00076                             FT_UShort     point,
00077                             FT_F26Dot6    distance );
00078 
00079   /* Distance projection along one of the projection vectors */
00080   typedef FT_F26Dot6
00081   (*TT_Project_Func)( EXEC_OP_ FT_Pos   dx,
00082                                FT_Pos   dy );
00083 
00084   /* reading a cvt value.  Take care of non-square pixels if necessary */
00085   typedef FT_F26Dot6
00086   (*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong  idx );
00087 
00088   /* setting or moving a cvt value.  Take care of non-square pixels  */
00089   /* if necessary                                                    */
00090   typedef void
00091   (*TT_Set_CVT_Func)( EXEC_OP_ FT_ULong    idx,
00092                                FT_F26Dot6  value );
00093 
00094 
00095   /*************************************************************************/
00096   /*                                                                       */
00097   /* This structure defines a call record, used to manage function calls.  */
00098   /*                                                                       */
00099   typedef struct  TT_CallRec_
00100   {
00101     FT_Int   Caller_Range;
00102     FT_Long  Caller_IP;
00103     FT_Long  Cur_Count;
00104     FT_Long  Cur_Restart;
00105 
00106   } TT_CallRec, *TT_CallStack;
00107 
00108 
00109   /*************************************************************************/
00110   /*                                                                       */
00111   /* The main structure for the interpreter which collects all necessary   */
00112   /* variables and states.                                                 */
00113   /*                                                                       */
00114   typedef struct  TT_ExecContextRec_
00115   {
00116     TT_Face            face;
00117     TT_Size            size;
00118     FT_Memory          memory;
00119 
00120     /* instructions state */
00121 
00122     FT_Error           error;      /* last execution error */
00123 
00124     FT_Long            top;        /* top of exec. stack   */
00125 
00126     FT_UInt            stackSize;  /* size of exec. stack  */
00127     FT_Long*           stack;      /* current exec. stack  */
00128 
00129     FT_Long            args;
00130     FT_UInt            new_top;    /* new top after exec.  */
00131 
00132     TT_GlyphZoneRec    zp0,        /* zone records */
00133                        zp1,
00134                        zp2,
00135                        pts,
00136                        twilight;
00137 
00138     FT_Size_Metrics    metrics;
00139     TT_Size_Metrics    tt_metrics; /* size metrics */
00140 
00141     TT_GraphicsState   GS;         /* current graphics state */
00142 
00143     FT_Int             curRange;  /* current code range number   */
00144     FT_Byte*           code;      /* current code range          */
00145     FT_Long            IP;        /* current instruction pointer */
00146     FT_Long            codeSize;  /* size of current range       */
00147 
00148     FT_Byte            opcode;    /* current opcode              */
00149     FT_Int             length;    /* length of current opcode    */
00150 
00151     FT_Bool            step_ins;  /* true if the interpreter must */
00152                                   /* increment IP after ins. exec */
00153     FT_Long            cvtSize;
00154     FT_Long*           cvt;
00155 
00156     FT_UInt            glyphSize; /* glyph instructions buffer size */
00157     FT_Byte*           glyphIns;  /* glyph instructions buffer */
00158 
00159     FT_UInt            numFDefs;  /* number of function defs         */
00160     FT_UInt            maxFDefs;  /* maximum number of function defs */
00161     TT_DefArray        FDefs;     /* table of FDefs entries          */
00162 
00163     FT_UInt            numIDefs;  /* number of instruction defs */
00164     FT_UInt            maxIDefs;  /* maximum number of ins defs */
00165     TT_DefArray        IDefs;     /* table of IDefs entries     */
00166 
00167     FT_UInt            maxFunc;   /* maximum function index     */
00168     FT_UInt            maxIns;    /* maximum instruction index  */
00169 
00170     FT_Int             callTop,    /* top of call stack during execution */
00171                        callSize;   /* size of call stack */
00172     TT_CallStack       callStack;  /* call stack */
00173 
00174     FT_UShort          maxPoints;    /* capacity of this context's `pts' */
00175     FT_Short           maxContours;  /* record, expressed in points and  */
00176                                      /* contours.                        */
00177 
00178     TT_CodeRangeTable  codeRangeTable;  /* table of valid code ranges */
00179                                         /* useful for the debugger   */
00180 
00181     FT_UShort          storeSize;  /* size of current storage */
00182     FT_Long*           storage;    /* storage area            */
00183 
00184     FT_F26Dot6         period;     /* values used for the */
00185     FT_F26Dot6         phase;      /* `SuperRounding'     */
00186     FT_F26Dot6         threshold;
00187 
00188 #if 0
00189     /* this seems to be unused */
00190     FT_Int             cur_ppem;   /* ppem along the current proj vector */
00191 #endif
00192 
00193     FT_Bool            instruction_trap; /* If `True', the interpreter will */
00194                                          /* exit after each instruction     */
00195 
00196     TT_GraphicsState   default_GS;       /* graphics state resulting from   */
00197                                          /* the prep program                */
00198     FT_Bool            is_composite;     /* true if the glyph is composite  */
00199     FT_Bool            pedantic_hinting; /* true if pedantic interpretation */
00200 
00201     /* latest interpreter additions */
00202 
00203     FT_Long            F_dot_P;    /* dot product of freedom and projection */
00204                                    /* vectors                               */
00205     TT_Round_Func      func_round; /* current rounding function             */
00206 
00207     TT_Project_Func    func_project,   /* current projection function */
00208                        func_dualproj,  /* current dual proj. function */
00209                        func_freeProj;  /* current freedom proj. func  */
00210 
00211     TT_Move_Func       func_move;      /* current point move function */
00212     TT_Move_Func       func_move_orig; /* move original position function */
00213 
00214     TT_Get_CVT_Func    func_read_cvt;  /* read a cvt entry              */
00215     TT_Set_CVT_Func    func_write_cvt; /* write a cvt entry (in pixels) */
00216     TT_Set_CVT_Func    func_move_cvt;  /* incr a cvt entry (in pixels)  */
00217 
00218     FT_Bool            grayscale;      /* are we hinting for grayscale? */
00219 
00220   } TT_ExecContextRec;
00221 
00222 
00223   extern const TT_GraphicsState  tt_default_graphics_state;
00224 
00225 
00226   FT_LOCAL( FT_Error )
00227   TT_Goto_CodeRange( TT_ExecContext  exec,
00228                      FT_Int          range,
00229                      FT_Long         IP );
00230 
00231   FT_LOCAL( FT_Error )
00232   TT_Set_CodeRange( TT_ExecContext  exec,
00233                     FT_Int          range,
00234                     void*           base,
00235                     FT_Long         length );
00236 
00237   FT_LOCAL( FT_Error )
00238   TT_Clear_CodeRange( TT_ExecContext  exec,
00239                       FT_Int          range );
00240 
00241 
00242   /*************************************************************************/
00243   /*                                                                       */
00244   /* <Function>                                                            */
00245   /*    TT_New_Context                                                     */
00246   /*                                                                       */
00247   /* <Description>                                                         */
00248   /*    Queries the face context for a given font.  Note that there is     */
00249   /*    now a _single_ execution context in the TrueType driver which is   */
00250   /*    shared among faces.                                                */
00251   /*                                                                       */
00252   /* <Input>                                                               */
00253   /*    face :: A handle to the source face object.                        */
00254   /*                                                                       */
00255   /* <Return>                                                              */
00256   /*    A handle to the execution context.  Initialized for `face'.        */
00257   /*                                                                       */
00258   /* <Note>                                                                */
00259   /*    Only the glyph loader and debugger should call this function.      */
00260   /*                                                                       */
00261   FT_EXPORT( TT_ExecContext )
00262   TT_New_Context( TT_Driver  driver );
00263 
00264   FT_LOCAL( FT_Error )
00265   TT_Done_Context( TT_ExecContext  exec );
00266 
00267   FT_LOCAL( FT_Error )
00268   TT_Load_Context( TT_ExecContext  exec,
00269                    TT_Face         face,
00270                    TT_Size         size );
00271 
00272   FT_LOCAL( FT_Error )
00273   TT_Save_Context( TT_ExecContext  exec,
00274                    TT_Size         ins );
00275 
00276   FT_LOCAL( FT_Error )
00277   TT_Run_Context( TT_ExecContext  exec,
00278                   FT_Bool         debug );
00279 
00280 
00281   /*************************************************************************/
00282   /*                                                                       */
00283   /* <Function>                                                            */
00284   /*    TT_RunIns                                                          */
00285   /*                                                                       */
00286   /* <Description>                                                         */
00287   /*    Executes one or more instruction in the execution context.  This   */
00288   /*    is the main function of the TrueType opcode interpreter.           */
00289   /*                                                                       */
00290   /* <Input>                                                               */
00291   /*    exec :: A handle to the target execution context.                  */
00292   /*                                                                       */
00293   /* <Return>                                                              */
00294   /*    FreeType error code.  0 means success.                             */
00295   /*                                                                       */
00296   /* <Note>                                                                */
00297   /*    Only the object manager and debugger should call this function.    */
00298   /*                                                                       */
00299   /*    This function is publicly exported because it is directly          */
00300   /*    invoked by the TrueType debugger.                                  */
00301   /*                                                                       */
00302   FT_EXPORT( FT_Error )
00303   TT_RunIns( TT_ExecContext  exec );
00304 
00305 
00306 FT_END_HEADER
00307 
00308 #endif /* __TTINTERP_H__ */
00309 
00310 
00311 /* END */

Generated on Tue Jul 5 14:13:54 2011 for ROOT_528-00b_version by  doxygen 1.5.1