?? ttinterp.c
字號(hào):
/* */ FT_LOCAL_DEF( FT_Error ) TT_Clear_CodeRange( TT_ExecContext exec, FT_Int range ) { FT_ASSERT( range >= 1 && range <= 3 ); exec->codeRangeTable[range - 1].base = NULL; exec->codeRangeTable[range - 1].size = 0; return TT_Err_Ok; } /*************************************************************************/ /* */ /* EXECUTION CONTEXT ROUTINES */ /* */ /*************************************************************************/ /*************************************************************************/ /* */ /* <Function> */ /* TT_Destroy_Context */ /* */ /* <Description> */ /* Destroys a given context. */ /* */ /* <Input> */ /* exec :: A handle to the target execution context. */ /* */ /* memory :: A handle to the parent memory object. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ /* Only the glyph loader and debugger should call this function. */ /* */ FT_LOCAL_DEF( FT_Error ) TT_Destroy_Context( TT_ExecContext exec, FT_Memory memory ) { /* free composite load stack */ FT_FREE( exec->loadStack ); exec->loadSize = 0; /* points zone */ exec->maxPoints = 0; exec->maxContours = 0; /* free stack */ FT_FREE( exec->stack ); exec->stackSize = 0; /* free call stack */ FT_FREE( exec->callStack ); exec->callSize = 0; exec->callTop = 0; /* free glyph code range */ FT_FREE( exec->glyphIns ); exec->glyphSize = 0; exec->size = NULL; exec->face = NULL; FT_FREE( exec ); return TT_Err_Ok; } /*************************************************************************/ /* */ /* <Function> */ /* Init_Context */ /* */ /* <Description> */ /* Initializes a context object. */ /* */ /* <Input> */ /* memory :: A handle to the parent memory object. */ /* */ /* face :: A handle to the source TrueType face object. */ /* */ /* <InOut> */ /* exec :: A handle to the target execution context. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ static FT_Error Init_Context( TT_ExecContext exec, TT_Face face, FT_Memory memory ) { FT_Error error; FT_TRACE1(( "Init_Context: new object at 0x%08p, parent = 0x%08p\n", exec, face )); exec->memory = memory; exec->callSize = 32; if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) ) goto Fail_Memory; /* all values in the context are set to 0 already, but this is */ /* here as a remainder */ exec->maxPoints = 0; exec->maxContours = 0; exec->stackSize = 0; exec->loadSize = 0; exec->glyphSize = 0; exec->stack = NULL; exec->loadStack = NULL; exec->glyphIns = NULL; exec->face = face; exec->size = NULL; return TT_Err_Ok; Fail_Memory: FT_ERROR(( "Init_Context: not enough memory for 0x%08lx\n", (FT_Long)exec )); TT_Destroy_Context( exec, memory ); return error; } /*************************************************************************/ /* */ /* <Function> */ /* Update_Max */ /* */ /* <Description> */ /* Checks the size of a buffer and reallocates it if necessary. */ /* */ /* <Input> */ /* memory :: A handle to the parent memory object. */ /* */ /* multiplier :: The size in bytes of each element in the buffer. */ /* */ /* new_max :: The new capacity (size) of the buffer. */ /* */ /* <InOut> */ /* size :: The address of the buffer's current size expressed */ /* in elements. */ /* */ /* buff :: The address of the buffer base pointer. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ static FT_Error Update_Max( FT_Memory memory, FT_ULong* size, FT_Long multiplier, void** buff, FT_ULong new_max ) { FT_Error error; if ( *size < new_max ) { FT_FREE( *buff ); if ( FT_ALLOC( *buff, new_max * multiplier ) ) return error; *size = new_max; } return TT_Err_Ok; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_Context */ /* */ /* <Description> */ /* Prepare an execution context for glyph hinting. */ /* */ /* <Input> */ /* face :: A handle to the source face object. */ /* */ /* size :: A handle to the source size object. */ /* */ /* <InOut> */ /* 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_Load_Context( TT_ExecContext exec, TT_Face face, TT_Size size ) { FT_Int i; FT_ULong tmp; TT_MaxProfile* maxp; FT_Error error; exec->face = face; maxp = &face->max_profile; exec->size = size; if ( size ) { exec->numFDefs = size->num_function_defs; exec->maxFDefs = size->max_function_defs; exec->numIDefs = size->num_instruction_defs; exec->maxIDefs = size->max_instruction_defs; exec->FDefs = size->function_defs; exec->IDefs = size->instruction_defs; exec->tt_metrics = size->ttmetrics; exec->metrics = size->root.metrics; exec->maxFunc = size->max_func; exec->maxIns = size->max_ins; for ( i = 0; i < TT_MAX_CODE_RANGES; i++ ) exec->codeRangeTable[i] = size->codeRangeTable[i]; /* set graphics state */ exec->GS = size->GS; exec->cvtSize = size->cvt_size; exec->cvt = size->cvt; exec->storeSize = size->storage_size; exec->storage = size->storage; exec->twilight = size->twilight; } error = Update_Max( exec->memory, &exec->loadSize, sizeof ( TT_SubGlyphRec ), (void**)&exec->loadStack, exec->face->max_components + 1 ); if ( error ) return error; /* XXX: We reserve a little more elements on the stack to deal safely */ /* with broken fonts like arialbs, courbs, timesbs, etc. */ tmp = exec->stackSize; error = Update_Max( exec->memory, &tmp, sizeof ( FT_F26Dot6 ), (void**)&exec->stack, maxp->maxStackElements + 32 ); exec->stackSize = (FT_UInt)tmp; if ( error ) return error; tmp = exec->glyphSize; error = Update_Max( exec->memory, &tmp, sizeof ( FT_Byte ), (void**)&exec->glyphIns, maxp->maxSizeOfInstructions ); exec->glyphSize = (FT_UShort)tmp; if ( error ) return error; exec->pts.n_points = 0; exec->pts.n_contours = 0; exec->instruction_trap = FALSE; return TT_Err_Ok; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Save_Context */ /* */ /* <Description> */ /* Saves the code ranges in a `size' object. */ /* */ /* <Input> */ /* exec :: A handle to the source execution context. */ /* */ /* <InOut> */ /* size :: A handle to the target size object. */ /* */ /* <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. */
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -