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

📄 cffdrivr.c

📁 下载来的一个看图软件的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /****                                                                 ****/  /****                                                                 ****/  /****             C H A R A C T E R   M A P P I N G S                 ****/  /****                                                                 ****/  /****                                                                 ****/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  static FT_Error  cff_get_glyph_name( CFF_Face    face,                      FT_UInt     glyph_index,                      FT_Pointer  buffer,                      FT_UInt     buffer_max )  {    CFF_Font         font   = (CFF_Font)face->extra.data;    FT_Memory        memory = FT_FACE_MEMORY( face );    FT_String*       gname;    FT_UShort        sid;    PSNames_Service  psnames;    FT_Error         error;    psnames = (PSNames_Service)FT_Get_Module_Interface(                face->root.driver->root.library, "psnames" );    if ( !psnames )    {      FT_ERROR(( "cff_get_glyph_name:" ));      FT_ERROR(( " cannot open CFF & CEF fonts\n" ));      FT_ERROR(( "                   " ));      FT_ERROR(( " without the `PSNames' module\n" ));      error = CFF_Err_Unknown_File_Format;      goto Exit;    }    /* first, locate the sid in the charset table */    sid = font->charset.sids[glyph_index];    /* now, lookup the name itself */    gname = cff_index_get_sid_string( &font->string_index, sid, psnames );    if ( gname && buffer_max > 0 )    {      FT_UInt  len = (FT_UInt)ft_strlen( gname );      if ( len >= buffer_max )        len = buffer_max - 1;      FT_MEM_COPY( buffer, gname, len );      ((FT_Byte*)buffer)[len] = 0;    }    FT_FREE( gname );    error = CFF_Err_Ok;    Exit:      return error;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    cff_get_name_index                                                 */  /*                                                                       */  /* <Description>                                                         */  /*    Uses the psnames module and the CFF font's charset to to return a  */  /*    a given glyph name's glyph index.                                  */  /*                                                                       */  /* <Input>                                                               */  /*    face       :: A handle to the source face object.                  */  /*                                                                       */  /*    glyph_name :: The glyph name.                                      */  /*                                                                       */  /* <Return>                                                              */  /*    Glyph index.  0 means `undefined character code'.                  */  /*                                                                       */  static FT_UInt  cff_get_name_index( CFF_Face    face,                      FT_String*  glyph_name )  {    CFF_Font         cff;    CFF_Charset      charset;    PSNames_Service  psnames;    FT_Memory        memory = FT_FACE_MEMORY( face );    FT_String*       name;    FT_UShort        sid;    FT_UInt          i;    FT_Int           result;    cff     = (CFF_FontRec *)face->extra.data;    charset = &cff->charset;    psnames = (PSNames_Service)FT_Get_Module_Interface(                face->root.driver->root.library, "psnames" );    for ( i = 0; i < cff->num_glyphs; i++ )    {      sid = charset->sids[i];      if ( sid > 390 )        name = cff_index_get_name( &cff->string_index, sid - 391 );      else        name = (FT_String *)psnames->adobe_std_strings( sid );      result = ft_strcmp( glyph_name, name );      if ( sid > 390 )        FT_FREE( name );      if ( !result )        return i;    }    return 0;  }  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /****                                                                 ****/  /****                                                                 ****/  /****                D R I V E R  I N T E R F A C E                   ****/  /****                                                                 ****/  /****                                                                 ****/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  static FT_Module_Interface  cff_get_interface( CFF_Driver   driver,                     const char*  module_interface )  {    FT_Module  sfnt;#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES    if ( ft_strcmp( (const char*)module_interface, "glyph_name" ) == 0 )      return (FT_Module_Interface)cff_get_glyph_name;    if ( ft_strcmp( (const char*)module_interface, "name_index" ) == 0 )      return (FT_Module_Interface)cff_get_name_index;#endif    /* we simply pass our request to the `sfnt' module */    sfnt = FT_Get_Module( driver->root.root.library, "sfnt" );    return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;  }  /* The FT_DriverInterface structure is defined in ftdriver.h. */  FT_CALLBACK_TABLE_DEF  const FT_Driver_ClassRec  cff_driver_class =  {    /* begin with the FT_Module_Class fields */    {      FT_MODULE_FONT_DRIVER       |      FT_MODULE_DRIVER_SCALABLE   |      FT_MODULE_DRIVER_HAS_HINTER,      sizeof( CFF_DriverRec ),      "cff",      0x10000L,      0x20000L,      0,   /* module-specific interface */      (FT_Module_Constructor)cff_driver_init,      (FT_Module_Destructor) cff_driver_done,      (FT_Module_Requester)  cff_get_interface,    },    /* now the specific driver fields */    sizeof( TT_FaceRec ),    sizeof( FT_SizeRec ),    sizeof( CFF_GlyphSlotRec ),    (FT_Face_InitFunc)       cff_face_init,    (FT_Face_DoneFunc)       cff_face_done,    (FT_Size_InitFunc)       cff_size_init,    (FT_Size_DoneFunc)       cff_size_done,    (FT_Slot_InitFunc)       cff_slot_init,    (FT_Slot_DoneFunc)       cff_slot_done,    (FT_Size_ResetPointsFunc)cff_size_reset,    (FT_Size_ResetPixelsFunc)cff_size_reset,    (FT_Slot_LoadFunc)       Load_Glyph,    (FT_Face_GetKerningFunc) Get_Kerning,    (FT_Face_AttachFunc)     0,    (FT_Face_GetAdvancesFunc)0,  };/* END */

⌨️ 快捷键说明

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