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

📄 ftobjs.c

📁 a very goog book
💻 C
📖 第 1 页 / 共 5 页
字号:
  FT_BASE_DEF( FT_Error )  FT_Render_Glyph_Internal( FT_Library    library,                            FT_GlyphSlot  slot,                            FT_UInt       render_mode )  {    FT_Error     error = FT_Err_Ok;    FT_Renderer  renderer;    /* if it is already a bitmap, no need to do anything */    switch ( slot->format )    {    case ft_glyph_format_bitmap:   /* already a bitmap, don't do anything */      break;    default:      {        FT_ListNode  node   = 0;        FT_Bool      update = 0;        /* small shortcut for the very common case */        if ( slot->format == ft_glyph_format_outline )        {          renderer = library->cur_renderer;          node     = library->renderers.head;        }        else          renderer = FT_Lookup_Renderer( library, slot->format, &node );        error = FT_Err_Unimplemented_Feature;        while ( renderer )        {          error = renderer->render( renderer, slot, render_mode, NULL );          if ( !error ||               FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph )            break;          /* FT_Err_Cannot_Render_Glyph is returned if the render mode   */          /* is unsupported by the current renderer for this glyph image */          /* format.                                                     */          /* now, look for another renderer that supports the same */          /* format.                                               */          renderer = FT_Lookup_Renderer( library, slot->format, &node );          update   = 1;        }        /* if we changed the current renderer for the glyph image format */        /* we need to select it as the next current one                  */        if ( !error && update && renderer )          FT_Set_Renderer( library, renderer, 0, 0 );      }    }    return error;  }  /* documentation is in freetype.h */  FT_EXPORT_DEF( FT_Error )  FT_Render_Glyph( FT_GlyphSlot  slot,                   FT_UInt       render_mode )  {    FT_Library  library;    if ( !slot )      return FT_Err_Invalid_Argument;    library = FT_FACE_LIBRARY( slot->face );    return FT_Render_Glyph_Internal( library, slot, render_mode );  }  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /****                                                                 ****/  /****                                                                 ****/  /****                         M O D U L E S                           ****/  /****                                                                 ****/  /****                                                                 ****/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    Destroy_Module                                                     */  /*                                                                       */  /* <Description>                                                         */  /*    Destroys a given module object.  For drivers, this also destroys   */  /*    all child faces.                                                   */  /*                                                                       */  /* <InOut>                                                               */  /*     module :: A handle to the target driver object.                   */  /*                                                                       */  /* <Note>                                                                */  /*     The driver _must_ be LOCKED!                                      */  /*                                                                       */  static void  Destroy_Module( FT_Module  module )  {    FT_Memory         memory  = module->memory;    FT_Module_Class*  clazz   = module->clazz;    FT_Library        library = module->library;    /* finalize client-data - before anything else */    if ( module->generic.finalizer )      module->generic.finalizer( module );    if ( library && library->auto_hinter == module )      library->auto_hinter = 0;    /* if the module is a renderer */    if ( FT_MODULE_IS_RENDERER( module ) )      ft_remove_renderer( module );    /* if the module is a font driver, add some steps */    if ( FT_MODULE_IS_DRIVER( module ) )      Destroy_Driver( FT_DRIVER( module ) );    /* finalize the module object */    if ( clazz->module_done )      clazz->module_done( module );    /* discard it */    FT_FREE( module );  }  /* documentation is in ftmodule.h */  FT_EXPORT_DEF( FT_Error )  FT_Add_Module( FT_Library              library,                 const FT_Module_Class*  clazz )  {    FT_Error   error;    FT_Memory  memory;    FT_Module  module;    FT_UInt    nn;#define FREETYPE_VER_FIXED  ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \                                FREETYPE_MINOR                  )    if ( !library )      return FT_Err_Invalid_Library_Handle;    if ( !clazz )      return FT_Err_Invalid_Argument;    /* check freetype version */    if ( clazz->module_requires > FREETYPE_VER_FIXED )      return FT_Err_Invalid_Version;    /* look for a module with the same name in the library's table */    for ( nn = 0; nn < library->num_modules; nn++ )    {      module = library->modules[nn];      if ( ft_strcmp( module->clazz->module_name, clazz->module_name ) == 0 )      {        /* this installed module has the same name, compare their versions */        if ( clazz->module_version <= module->clazz->module_version )          return FT_Err_Lower_Module_Version;        /* remove the module from our list, then exit the loop to replace */        /* it by our new version..                                        */        FT_Remove_Module( library, module );        break;      }    }    memory = library->memory;    error  = FT_Err_Ok;    if ( library->num_modules >= FT_MAX_MODULES )    {      error = FT_Err_Too_Many_Drivers;      goto Exit;    }    /* allocate module object */    if ( FT_ALLOC( module,clazz->module_size ) )      goto Exit;    /* base initialization */    module->library = library;    module->memory  = memory;    module->clazz   = (FT_Module_Class*)clazz;    /* check whether the module is a renderer - this must be performed */    /* before the normal module initialization                         */    if ( FT_MODULE_IS_RENDERER( module ) )    {      /* add to the renderers list */      error = ft_add_renderer( module );      if ( error )        goto Fail;    }    /* is the module a auto-hinter? */    if ( FT_MODULE_IS_HINTER( module ) )      library->auto_hinter = module;    /* if the module is a font driver */    if ( FT_MODULE_IS_DRIVER( module ) )    {      /* allocate glyph loader if needed */      FT_Driver  driver = FT_DRIVER( module );      driver->clazz = (FT_Driver_Class)module->clazz;      if ( FT_DRIVER_USES_OUTLINES( driver ) )      {        error = FT_GlyphLoader_New( memory, &driver->glyph_loader );        if ( error )          goto Fail;      }    }    if ( clazz->module_init )    {      error = clazz->module_init( module );      if ( error )        goto Fail;    }    /* add module to the library's table */    library->modules[library->num_modules++] = module;  Exit:    return error;  Fail:    if ( FT_MODULE_IS_DRIVER( module ) )    {      FT_Driver  driver = FT_DRIVER( module );      if ( FT_DRIVER_USES_OUTLINES( driver ) )        FT_GlyphLoader_Done( driver->glyph_loader );    }    if ( FT_MODULE_IS_RENDERER( module ) )    {      FT_Renderer  renderer = FT_RENDERER( module );      if ( renderer->raster )        renderer->clazz->raster_class->raster_done( renderer->raster );    }    FT_FREE( module );    goto Exit;  }  /* documentation is in ftmodule.h */  FT_EXPORT_DEF( FT_Module )  FT_Get_Module( FT_Library   library,                 const char*  module_name )  {    FT_Module   result = 0;    FT_Module*  cur;    FT_Module*  limit;    if ( !library || !module_name )      return result;    cur   = library->modules;    limit = cur + library->num_modules;    for ( ; cur < limit; cur++ )      if ( ft_strcmp( cur[0]->clazz->module_name, module_name ) == 0 )      {        result = cur[0];        break;      }    return result;  }  /* documentation is in ftobjs.h */  FT_BASE_DEF( const void* )  FT_Get_Module_Interface( FT_Library   library,                           const char*  mod_name )  {    FT_Module  module;    /* test for valid `library' delayed to FT_Get_Module() */    module = FT_Get_Module( library, mod_name );    return module ? module->clazz->module_interface : 0;  }  /* documentation is in ftmodule.h */  FT_EXPORT_DEF( FT_Error )  FT_Remove_Module( FT_Library  library,                    FT_Module   module )  {    /* try to find the module from the table, then remove it from there */    if ( !library )      return FT_Err_Invalid_Library_Handle;    if ( module )    {      FT_Module*  cur   = library->modules;      FT_Module*  limit = cur + library->num_modules;      for ( ; cur < limit; cur++ )      {        if ( cur[0] == module )        {          /* remove it from the table */          library->num_modules--;          limit--;          while ( cur < limit )          {            cur[0] = cur[1];            cur++;          }          limit[0] = 0;          /* destroy the module */          Destroy_Module( module );          return FT_Err_Ok;        }      }    }    return FT_Err_Invalid_Driver_Handle;  }  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /****                                                                 ****/  /****                                                                 ****/  /****                         L I B R A R Y                           ****/  /****                                                                 ****/  /****                                                                 ****/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /* documentation is in ftmodule.h */  FT_EXPORT_DEF( FT_Error )  FT_New_Library( FT_Memory    memory,                  FT_Library  *alibrary )  {    FT_Library  library = 0;    FT_Error    error;    if ( !memory )      return FT_Err_Invalid_Argument;#ifdef FT_DEBUG_LEVEL_ERROR    /* init debugging support */    ft_debug_init();#endif    /* first of all, allocate the library object */    if ( FT_NEW( library ) )      return error;    library->memory = memory;    /* allocate the render pool */    library->raster_pool_size = FT_RENDER_POOL_SIZE;    if ( FT_ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )      goto Fail;    /* That's ok now */    *alibrary = library;    return FT_Err_Ok;  Fail:    FT_FREE( library );    return error;  }  /* documentation is in freetype.h */  FT_EXPORT_DEF( void )  FT_Library_Version( FT_Library   library,                      FT_Int      *amajor,                      FT_Int      *aminor,                      FT_Int      *apatch )  {    FT_Int  major = 0;    FT_Int  minor = 0;    FT_Int  patch = 0;    if ( library )    {      major = library->version_major;      minor = library->version_minor;      patch = library->version_patch;    }    if ( *amajor )      *amajor = major;    if ( *aminor )      *aminor = minor;    if ( *apatch )      *apatch = patch;  }  /* documentation is in ftmodule.h */  FT_EXPORT_DEF( FT_Error )  FT_Done_Library( FT_Library  library )  {    FT_Memory  memory;    if ( !library )      return FT_Err_Invalid_Library_Handle;    memory = library->memory;    /* Discard client-data */    if ( library->generic.finalizer )      library->generic.finalizer( library );    /* Close all modules in the library */#if 1    while ( library->num_modules > 0 )      FT_Remove_Module( library, library->modules[0] );#else    {      FT_UInt  n;      for ( n = 0; n < library->num_modules; n++ )      {        FT_Module  module = library->modules[n];        if ( module )        {          Destroy_Module( module );          library->modules[n] = 0;        }      }    }#endif    /* Destroy raster objects */    FT_FREE( library->raster_pool );    library->raster_pool_size = 0;    FT_FREE( library );    return FT_Err_Ok;  }  /* documentation is in ftmodule.h */  FT_EXPORT_DEF( void )  FT_Set_Debug_Hook( FT_Library         library,                     FT_UInt            hook_index,                     FT_DebugHook_Func  debug_hook )  {    if ( library && debug_hook &&         hook_index <           ( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) )      library->debug_hooks[hook_index] = debug_hook;  }/* END */

⌨️ 快捷键说明

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