📄 ttinterp.c
字号:
/* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ /* Only the glyph loader and debugger should call this function. */ /* */ FT_LOCAL_DEF FT_Error TT_Save_Context( TT_ExecContext exec, TT_Size size ) { FT_Int i; /* XXXX: Will probably disappear soon with all the code range */ /* management, which is now rather obsolete. */ /* */ size->num_function_defs = exec->numFDefs; size->num_instruction_defs = exec->numIDefs; size->max_func = exec->maxFunc; size->max_ins = exec->maxIns; for ( i = 0; i < TT_MAX_CODE_RANGES; i++ ) size->codeRangeTable[i] = exec->codeRangeTable[i]; return TT_Err_Ok; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Run_Context */ /* */ /* <Description> */ /* Executes one or more instructions in the execution context. */ /* */ /* <Input> */ /* debug :: A Boolean flag. If set, the function sets some internal */ /* variables and returns immediately, otherwise TT_RunIns() */ /* is called. */ /* */ /* This is commented out currently. */ /* */ /* <Input> */ /* exec :: A handle to the target execution context. */ /* */ /* <Return> */ /* TrueTyoe error code. 0 means success. */ /* */ /* <Note> */ /* Only the glyph loader and debugger should call this function. */ /* */ FT_LOCAL_DEF FT_Error TT_Run_Context( TT_ExecContext exec, FT_Bool debug ) { FT_Error error; if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) ) != TT_Err_Ok ) return error; exec->zp0 = exec->pts; exec->zp1 = exec->pts; exec->zp2 = exec->pts; exec->GS.gep0 = 1; exec->GS.gep1 = 1; exec->GS.gep2 = 1; exec->GS.projVector.x = 0x4000; exec->GS.projVector.y = 0x0000; exec->GS.freeVector = exec->GS.projVector; exec->GS.dualVector = exec->GS.projVector; exec->GS.round_state = 1; exec->GS.loop = 1; /* some glyphs leave something on the stack. so we clean it */ /* before a new execution. */ exec->top = 0; exec->callTop = 0;#if 1 FT_UNUSED( debug ); return exec->face->interpreter( exec );#else if ( !debug ) return TT_RunIns( exec ); else return TT_Err_Ok;#endif } const TT_GraphicsState tt_default_graphics_state = { 0, 0, 0, { 0x4000, 0 }, { 0x4000, 0 }, { 0x4000, 0 }, 1, 64, 1, TRUE, 68, 0, 0, 9, 3, 0, FALSE, 2, 1, 1, 1 }; /* documentation is in ttinterp.h */ FT_EXPORT_DEF( TT_ExecContext ) TT_New_Context( TT_Face face ) { TT_Driver driver; TT_ExecContext exec; FT_Memory memory; if ( !face ) return 0; driver = (TT_Driver)face->root.driver; memory = driver->root.root.memory; exec = driver->context; if ( !driver->context ) { FT_Error error; /* allocate object */ if ( ALLOC( exec, sizeof ( *exec ) ) ) goto Exit; /* initialize it */ error = Init_Context( exec, face, memory ); if ( error ) goto Fail; /* store it into the driver */ driver->context = exec; } Exit: return driver->context; Fail: FREE( exec ); return 0; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Done_Context */ /* */ /* <Description> */ /* Discards an execution context. */ /* */ /* <Input> */ /* exec :: A handle to the target execution context. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ /* Only the glyph loader and debugger should call this function. */ /* */ FT_LOCAL_DEF FT_Error TT_Done_Context( TT_ExecContext exec ) { /* Nothing at all for now */ FT_UNUSED( exec ); return TT_Err_Ok; }#ifdef FT_CONFIG_OPTION_OLD_CALCS static FT_F26Dot6 Norm( FT_F26Dot6 X, FT_F26Dot6 Y ) { TT_INT64 T1, T2; MUL_64( X, X, T1 ); MUL_64( Y, Y, T2 ); ADD_64( T1, T2, T1 ); return (FT_F26Dot6)SQRT_64( T1 ); }#endif /* FT_CONFIG_OPTION_OLD_CALCS */ /*************************************************************************/ /* */ /* Before an opcode is executed, the interpreter verifies that there are */ /* enough arguments on the stack, with the help of the Pop_Push_Count */ /* table. */ /* */ /* For each opcode, the first column gives the number of arguments that */ /* are popped from the stack; the second one gives the number of those */ /* that are pushed in result. */ /* */ /* Note that for opcodes with a varying number of parameters, either 0 */ /* or 1 arg is verified before execution, depending on the nature of the */ /* instruction: */ /* */ /* - if the number of arguments is given by the bytecode stream or the */ /* loop variable, 0 is chosen. */ /* */ /* - if the first argument is a count n that is followed by arguments */ /* a1 .. an, then 1 is chosen. */ /* */ /*************************************************************************/#undef PACK#define PACK( x, y ) ( ( x << 4 ) | y ) static const FT_Byte Pop_Push_Count[256] = { /* opcodes are gathered in groups of 16 */ /* please keep the spaces as they are */ /* SVTCA y */ PACK( 0, 0 ), /* SVTCA x */ PACK( 0, 0 ), /* SPvTCA y */ PACK( 0, 0 ), /* SPvTCA x */ PACK( 0, 0 ), /* SFvTCA y */ PACK( 0, 0 ), /* SFvTCA x */ PACK( 0, 0 ), /* SPvTL // */ PACK( 2, 0 ), /* SPvTL + */ PACK( 2, 0 ), /* SFvTL // */ PACK( 2, 0 ), /* SFvTL + */ PACK( 2, 0 ), /* SPvFS */ PACK( 2, 0 ), /* SFvFS */ PACK( 2, 0 ), /* GPV */ PACK( 0, 2 ), /* GFV */ PACK( 0, 2 ), /* SFvTPv */ PACK( 0, 0 ), /* ISECT */ PACK( 5, 0 ), /* SRP0 */ PACK( 1, 0 ), /* SRP1 */ PACK( 1, 0 ), /* SRP2 */ PACK( 1, 0 ), /* SZP0 */ PACK( 1, 0 ), /* SZP1 */ PACK( 1, 0 ), /* SZP2 */ PACK( 1, 0 ), /* SZPS */ PACK( 1, 0 ), /* SLOOP */ PACK( 1, 0 ), /* RTG */ PACK( 0, 0 ), /* RTHG */ PACK( 0, 0 ), /* SMD */ PACK( 1, 0 ), /* ELSE */ PACK( 0, 0 ), /* JMPR */ PACK( 1, 0 ), /* SCvTCi */ PACK( 1, 0 ), /* SSwCi */ PACK( 1, 0 ), /* SSW */ PACK( 1, 0 ), /* DUP */ PACK( 1, 2 ), /* POP */ PACK( 1, 0 ), /* CLEAR */ PACK( 0, 0 ), /* SWAP */ PACK( 2, 2 ), /* DEPTH */ PACK( 0, 1 ), /* CINDEX */ PACK( 1, 1 ), /* MINDEX */ PACK( 1, 0 ), /* AlignPTS */ PACK( 2, 0 ), /* INS_$28 */ PACK( 0, 0 ), /* UTP */ PACK( 1, 0 ), /* LOOPCALL */ PACK( 2, 0 ), /* CALL */ PACK( 1, 0 ), /* FDEF */ PACK( 1, 0 ), /* ENDF */ PACK( 0, 0 ), /* MDAP[0] */ PACK( 1, 0 ), /* MDAP[1] */ PACK( 1, 0 ), /* IUP[0] */ PACK( 0, 0 ), /* IUP[1] */ PACK( 0, 0 ), /* SHP[0] */ PACK( 0, 0 ), /* SHP[1] */ PACK( 0, 0 ), /* SHC[0] */ PACK( 1, 0 ), /* SHC[1] */ PACK( 1, 0 ), /* SHZ[0] */ PACK( 1, 0 ), /* SHZ[1] */ PACK( 1, 0 ), /* SHPIX */ PACK( 1, 0 ), /* IP */ PACK( 0, 0 ), /* MSIRP[0] */ PACK( 2, 0 ), /* MSIRP[1] */ PACK( 2, 0 ), /* AlignRP */ PACK( 0, 0 ), /* RTDG */ PACK( 0, 0 ), /* MIAP[0] */ PACK( 2, 0 ), /* MIAP[1] */ PACK( 2, 0 ), /* NPushB */ PACK( 0, 0 ), /* NPushW */ PACK( 0, 0 ), /* WS */ PACK( 2, 0 ), /* RS */ PACK( 1, 1 ), /* WCvtP */ PACK( 2, 0 ), /* RCvt */ PACK( 1, 1 ), /* GC[0] */ PACK( 1, 1 ), /* GC[1] */ PACK( 1, 1 ), /* SCFS */ PACK( 2, 0 ), /* MD[0] */ PACK( 2, 1 ), /* MD[1] */ PACK( 2, 1 ), /* MPPEM */ PACK( 0, 1 ), /* MPS */ PACK( 0, 1 ), /* FlipON */ PACK( 0, 0 ), /* FlipOFF */ PACK( 0, 0 ), /* DEBUG */ PACK( 1, 0 ), /* LT */ PACK( 2, 1 ), /* LTEQ */ PACK( 2, 1 ), /* GT */ PACK( 2, 1 ), /* GTEQ */ PACK( 2, 1 ), /* EQ */ PACK( 2, 1 ), /* NEQ */ PACK( 2, 1 ), /* ODD */ PACK( 1, 1 ), /* EVEN */ PACK( 1, 1 ),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -