⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttinterp.c

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 C
📖 第 1 页 / 共 5 页
字号:
  /* <Function>                                                            */  /*    TT_Clear_CodeRange                                                 */  /*                                                                       */  /* <Description>                                                         */  /*    Clears a code range.                                               */  /*                                                                       */  /* <Input>                                                               */  /*    range :: The code range index.                                     */  /*                                                                       */  /* <InOut>                                                               */  /*    exec  :: The target execution context.                             */  /*                                                                       */  /* <Return>                                                              */  /*   TrueType error code.  0 means success.                              */  /*                                                                       */  /* <Note>                                                                */  /*    Does not set the Error variable.                                   */  /*                                                                       */  EXPORT_FUNC  TT_Error  TT_Clear_CodeRange( TT_ExecContext  exec,                                TT_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.                */  /*    system :: A handle to the parent system object.                    */  /*                                                                       */  /* <Return>                                                              */  /*    TrueType error code.  0 means success.                             */  /*                                                                       */  /* <Note>                                                                */  /*    Only the glyph loader and debugger should call this function.      */  /*                                                                       */  LOCAL_FUNC  TT_Error  TT_Destroy_Context( TT_ExecContext  exec,                                FT_Memory       memory )  {    /* free composite load stack */    FREE( exec->loadStack );    exec->loadSize = 0;    /* points zone */    exec->maxPoints   = 0;    exec->maxContours = 0;    /* free stack */    FREE( exec->stack );    exec->stackSize = 0;    /* free call stack */    FREE( exec->callStack );    exec->callSize = 0;    exec->callTop  = 0;    /* free glyph code range */    FREE( exec->glyphIns );    exec->glyphSize = 0;    exec->size = NULL;    exec->face = NULL;    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>                                                              */  /*    TrueType error code.  0 means success.                             */  /*                                                                       */  static  TT_Error  Init_Context( TT_ExecContext  exec,                          TT_Face         face,                          FT_Memory       memory )  {    TT_Error  error;    FT_TRACE1(( "TT.Create_Create: new object at 0x%08lx, parent = 0x%08lx\n",              (long)exec, (long)face ));    /* XXX: We don't reserve arrays anymore, this is done automatically */    /*      during a call to Context_Load().                            */    exec->memory   = memory;    exec->callSize = 32;    if ( ALLOC_ARRAY( exec->callStack, exec->callSize, TT_CallRec ) )      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(( "TT.Context_Create: not enough memory for 0x%08lx\n",             (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>                                                               */  /*    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>                                                              */  /*    TrueType error code.  0 means success.                             */  /*                                                                       */  static  TT_Error  Update_Max( FT_Memory  memory,                        TT_ULong*  size,                        TT_Long    multiplier,                        void**     buff,                        TT_ULong   new_max )  {    TT_Error  error;    if ( *size < new_max )    {      FREE( *buff );      if ( 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>                                                              */  /*    TrueType error code.  0 means success.                             */  /*                                                                       */  /* <Note>                                                                */  /*    Only the glyph loader and debugger should call this function.      */  /*                                                                       */  EXPORT_FUNC  TT_Error  TT_Load_Context( TT_ExecContext  exec,                             TT_Face         face,                             TT_Size         size )  {    TT_Int          i;    TT_ULong        tmp;    TT_MaxProfile*  maxp;    TT_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 ( TT_F26Dot6 ),                        (void**)&exec->stack,                        maxp->maxStackElements + 32 );    exec->stackSize = (TT_UInt)tmp;    if ( error )      return error;    tmp = exec->glyphSize;    error = Update_Max( exec->memory,                        &tmp,                        sizeof ( TT_Byte ),                        (void**)&exec->glyphIns,                        maxp->maxSizeOfInstructions );    exec->glyphSize = (TT_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.                  */  /*                                                                       */  /* <Output>                                                              */  /*    ins  :: A handle to the target size object.                        */  /*                                                                       */  /* <Return>                                                              */  /*    TrueType error code.  0 means success.                             */  /*                                                                       */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -