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

📄 ttapi.c

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************************* * *  ttapi.c     * *    High-level interface implementation * *  Copyright 1996-1998 by *  David Turner, Robert Wilhelm, and Werner Lemberg. * *  This file is part of the FreeType project, and may only be used, *  modified, and distributed under the terms of the FreeType project *  license, LICENSE.TXT.  By continuing to use, modify, or distribute  *  this file you indicate that you have read the license and *  understand and accept it fully. * *  Notes: * *    This file is used to implement most of the functions that are *    defined in the file "freetype.h". However, two functions are *    implemented elsewhere :                                 * ******************************************************************/#include <freetype.h>#include <ftdebug.h>#include <ftstream.h>#include <ftcalc.h>#include <ftlist.h>#include <ftraster.h>#include <ttdriver.h>#include <ttobjs.h>#include <ttcmap.h>#define _TRUETYPE_#include <truetype.h>  /* backwards compatible interface *//* required by the tracing mode */#undef  FT_COMPONENT#define FT_COMPONENT  trace_ttapi#define RENDER_POOL_SIZE  64000  static  const FT_DriverInterface*  tt_interface = &tt_driver_interface;    static  const TT_DriverInterface*  tt_extension = &tt_format_interface;  /***********************************************************************/  /*                                                                     */  /* <Function> TT_Init_FreeType                                         */  /*                                                                     */  /* <Description>                                                       */  /*    Creates a new TrueType driver/engine object.                     */  /*                                                                     */  /* <Output>                                                            */  /*    engine   ::  handle to the new engine object                     */  /*                                                                     */  /* <Return>                                                            */  /*    TrueType error code. 0 means success                             */  /*                                                                     */  /* <MT-Note>                                                           */  /*    No.                                                              */  /*                                                                     */  /* <Note>                                                              */  /*    This function is provided for stand-alone compiles of the        */  /*    TrueType driver.                                                 */  /*                                                                     */  EXPORT_FUNC  TT_Error  TT_Init_FreeType( TT_Engine*  engine )  {    FT_Library library;    FT_System  system;    TT_Error   error;    *engine = 0;    error = FT_New_System( &system );    if (error) return error;        error = FT_New_Library( system, &library );    if (!error)      /* Now create a new TrueType driver object */      error = FT_Add_Driver( library,                             (FT_DriverInterface*)&tt_driver_interface );    if (error)      FT_Done_Library(library);    else      *engine = (TT_Engine)library;    return error;  }  /***********************************************************************/  /*                                                                     */  /* <Function> TT_Done_FreeType                                         */  /*                                                                     */  /* <Description>                                                       */  /*    Destroys a given TrueType engine object created with             */  /*    TT_Init_FreeType. All associated objects, (i.e. faces, outlines  */  /*    and charmaps) will be destroyed..                                */  /*                                                                     */  /* <Input>                                                             */  /*    engine   :: handle to the engine object                          */  /*                                                                     */  /* <Return>                                                            */  /*    TrueType error code. 0 means success                             */  /*                                                                     */  /* <MT-Note>                                                           */  /*    No.                                                              */  /*                                                                     */  /* <Note>                                                              */  /*    This function is provided for stand-alone compiles of the        */  /*    TrueType driver. The FreeType library uses the TT_Done_Engine    */  /*    API.                                                             */  /*                                                                     */  EXPORT_FUNC  TT_Error  TT_Done_FreeType( TT_Engine  engine )  {    FT_Library  library = (FT_Library)engine;    FT_Done_FreeType( library );    return FT_Err_Ok;  }  /***********************************************************************/  /*                                                                     */  /* <Function> TT_Set_Raster_Gray_Palette                               */  /*                                                                     */  /* <Description>                                                       */  /*    Sets the raster's gray 5-levels palette. Entry 0 correspond to   */  /*    the background, Entry 4 to the foreground. Intermediate entries  */  /*    correspond to gray levels..                                      */  /*                                                                     */  /* <Input>                                                             */  /*    engine   :: handle to the engine object                          */  /*    palette  :: an array of 5 bytes used to render 8-bit pixmaps     */  /*                                                                     */  /* <Return>                                                            */  /*    TrueType error code. 0 means success                             */  /*                                                                     */  /* <MT-Note>                                                           */  /*    No.                                                              */  /*                                                                     */  /* <Note>                                                              */  /*    This function is provided for stand-alone compiles of the        */  /*    TrueType driver. The FreeType library accesses directly the      */  /*    raster object to set the palette.                                */  /*                                                                     */  /*    This function ONLY supports 5 levels of grays.                   */  /*                                                                     */  EXPORT_FUNC  TT_Error  TT_Set_Raster_Gray_Palette( TT_Engine       engine,                                        const TT_Byte*  palette )  {      FT_Library  library;        if (!engine)      return TT_Err_Invalid_Engine;        library = (FT_Library)engine;    return FT_Set_Raster_Palette( library, 5, (unsigned char*)palette );  }  /***********************************************************************/  /*                                                                     */  /* <Function> TT_Open_Face                                             */  /*                                                                     */  /* <Description>                                                       */  /*    Creates a new face object from a given resource. The file can    */  /*    be either a TrueType file (ttf) or a TrueType collection (ttc).  */  /*    In the latter case, only the first face is opened. The number    */  /*    of faces in a collection can be obtained in the face's           */  /*    properties field "num_Faces". Other faces can be opened with     */  /*    TT_Open_Collection (see below).                                  */  /*                                                                     */  /* <Input>                                                             */  /*    engine    :: the parent engine object where to create the face   */  /*                 object.                                             */  /*                                                                     */  /*    pathname  :: pathname for the font file.                         */  /*                                                                     */  /* <Output>                                                            */  /*    face      :: a handle to the fresh face object.                  */  /*                                                                     */  /* <Return>                                                            */  /*    TrueType error code. 0 means success..                           */  /*                                                                     */  /* <MT-Note>                                                           */  /*    Yes.                                                             */  /*                                                                     */  /* <Note>                                                              */  /*    This API is provided fro backwards compatibility. Please use     */  /*    the functions TT_New_Face/TT_Done_Face now to create and         */  /*    discard face objects..                                           */  /*                                                                     */        static        TT_Error  open_face( FT_Library      library,                             const TT_Text*  pathname,                             TT_Int          face_index,                             TT_Face        *aface )        {          TT_Error    error;          FT_Resource resource;                *aface = 0;                error = FT_New_Resource( library, pathname, &resource );          if (error) return error;#if 0                error = FT_Add_Resource( library, resource );          if (error) goto Fail_Install;#endif          error = FT_New_Face( resource, face_index, (FT_Face*)aface );          /* Destroy glyph slot to comply with the 1.x API */          if (!error)            FT_Done_GlyphSlot( (*aface)->root.slot );                if (error)            FT_Done_Resource(resource);                return error;        }  EXPORT_DEF  TT_Error  TT_Open_Face( TT_Engine      engine,                          const TT_Text* pathname,                          TT_Face*       aface )  {    if (!engine)      return TT_Err_Invalid_Driver_Handle;    return  open_face( (FT_Library)engine, pathname, 0, aface );  }    /***********************************************************************/  /*                                                                     */  /* <Function> TT_Open_Collection                                       */  /*                                                                     */  /* <Description>                                                       */  /*    Loads a given face within a collection.                          */  /*                                                                     */  /* <Input>                                                             */  /*    engine    :: TrueType engine object where to load the face       */  /*    pathname  :: the collection's pathname                           */  /*    fontIndex :: index of face within the collection. first is 0     */  /*                                                                     */  /* <Output>                                                            */  /*    face      :: handle to the new face object. Always set to NULL   */  /*                 in case of error                                    */  /* <Return>                                                            */  /*    TrueType error code. 0 means success                             */  /*                                                                     */  /* <MT-Note>                                                           */  /*    Yes.                                                             */  /*                                                                     */  /* <Note>                                                              */  /*    This API is provided for backwards compatibility. Please use     */  /*    the functions TT_New_Collection/TT_Done_Face now to create and   */  /*    discard face/collection objects.                                 */  /*                                                                     */  EXPORT_DEF  TT_Error  TT_Open_Collection( TT_Engine       engine,                                const TT_Text*  pathname,

⌨️ 快捷键说明

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