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

📄 cffobjs.c

📁 source code: Covert TXT to PDF
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************//*                                                                         *//*  cffobjs.c                                                              *//*                                                                         *//*    OpenType objects manager (body).                                     *//*                                                                         *//*  Copyright 1996-2001 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.                                        *//*                                                                         *//***************************************************************************/#include <ft2build.h>#include FT_INTERNAL_DEBUG_H#include FT_INTERNAL_CALC_H#include FT_INTERNAL_STREAM_H#include FT_ERRORS_H#include FT_TRUETYPE_IDS_H#include FT_TRUETYPE_TAGS_H#include FT_INTERNAL_SFNT_H#include FT_INTERNAL_POSTSCRIPT_NAMES_H#include FT_INTERNAL_POSTSCRIPT_HINTS_H#include "cffobjs.h"#include "cffload.h"#include "cfferrs.h"#include <string.h>         /* for strlen() */  /*************************************************************************/  /*                                                                       */  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */  /* messages during execution.                                            */  /*                                                                       */#undef  FT_COMPONENT#define FT_COMPONENT  trace_cffobjs  /*************************************************************************/  /*                                                                       */  /*                            SIZE FUNCTIONS                             */  /*                                                                       */  /*  Note that we store the global hints in the size's "internal" root    */  /*  field.                                                               */  /*                                                                       */  /*************************************************************************/  static PSH_Globals_Funcs  CFF_Size_Get_Globals_Funcs( CFF_Size  size )  {    CFF_Face             face     = (CFF_Face)size->face;    CFF_Font*            font     = (CFF_Font *)face->extra.data;    PSHinter_Interface*  pshinter = (PSHinter_Interface *)font->pshinter;    FT_Module            module;    module = FT_Get_Module( size->face->driver->root.library,                            "pshinter" );    return ( module && pshinter && pshinter->get_globals_funcs )           ? pshinter->get_globals_funcs( module )           : 0;  }  FT_LOCAL_DEF void  CFF_Size_Done( CFF_Size  size )  {    if ( size->internal )    {      PSH_Globals_Funcs  funcs;      funcs = CFF_Size_Get_Globals_Funcs( size );      if ( funcs )        funcs->destroy( (PSH_Globals)size->internal );      size->internal = 0;    }  }  FT_LOCAL_DEF FT_Error  CFF_Size_Init( CFF_Size  size )  {    FT_Error           error = 0;    PSH_Globals_Funcs  funcs = CFF_Size_Get_Globals_Funcs( size );    if ( funcs )    {      PSH_Globals   globals;      CFF_Face      face    = (CFF_Face)size->face;      CFF_Font*     font    = (CFF_Font *)face->extra.data;      CFF_SubFont*  subfont = &font->top_font;      CFF_Private*  cpriv   = &subfont->private_dict;      T1_Private    priv;      /* IMPORTANT: The CFF and Type1 private dictionaries have    */      /*            slightly different structures; we need to      */      /*            synthetize a type1 dictionary on the fly here. */      {        FT_UInt  n, count;        MEM_Set( &priv, 0, sizeof ( priv ) );        count = priv.num_blue_values = cpriv->num_blue_values;        for ( n = 0; n < count; n++ )          priv.blue_values[n] = (FT_Short)cpriv->blue_values[n];        count = priv.num_other_blues = cpriv->num_other_blues;        for ( n = 0; n < count; n++ )          priv.other_blues[n] = (FT_Short)cpriv->other_blues[n];        count = priv.num_family_blues = cpriv->num_family_blues;        for ( n = 0; n < count; n++ )          priv.family_blues[n] = (FT_Short)cpriv->family_blues[n];        count = priv.num_family_other_blues = cpriv->num_family_other_blues;        for ( n = 0; n < count; n++ )          priv.family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];        priv.blue_scale = cpriv->blue_scale;        priv.blue_shift = cpriv->blue_shift;        priv.blue_fuzz  = cpriv->blue_fuzz;        priv.standard_width[0]  = (FT_UShort)cpriv->standard_width;        priv.standard_height[0] = (FT_UShort)cpriv->standard_height;        count = priv.num_snap_widths = cpriv->num_snap_widths;        for ( n = 0; n < count; n++ )          priv.snap_widths[n] = (FT_Short)cpriv->snap_widths[n];        count = priv.num_snap_heights = cpriv->num_snap_heights;        for ( n = 0; n < count; n++ )          priv.snap_heights[n] = (FT_Short)cpriv->snap_heights[n];        priv.force_bold     = cpriv->force_bold;        priv.language_group = cpriv->language_group;        priv.lenIV          = cpriv->lenIV;      }      error = funcs->create( size->face->memory, &priv, &globals );      if ( !error )        size->internal = (FT_Size_Internal)(void*)globals;    }    return error;  }  FT_LOCAL_DEF FT_Error  CFF_Size_Reset( CFF_Size  size )  {    PSH_Globals_Funcs  funcs = CFF_Size_Get_Globals_Funcs( size );    FT_Error           error = 0;    if ( funcs )      error = funcs->set_scale( (PSH_Globals)size->internal,                                 size->metrics.x_scale,                                 size->metrics.y_scale,                                 0, 0 );    return error;  }  /*************************************************************************/  /*                                                                       */  /*                            SLOT  FUNCTIONS                            */  /*                                                                       */  /*************************************************************************/  FT_LOCAL_DEF void  CFF_GlyphSlot_Done( CFF_GlyphSlot  slot )  {    slot->root.internal->glyph_hints = 0;  }  FT_LOCAL_DEF FT_Error  CFF_GlyphSlot_Init( CFF_GlyphSlot  slot )  {    CFF_Face             face     = (CFF_Face)slot->root.face;    CFF_Font*            font     = (CFF_Font *)face->extra.data;    PSHinter_Interface*  pshinter = (PSHinter_Interface *)font->pshinter;    if ( pshinter )    {      FT_Module  module;      module = FT_Get_Module( slot->root.face->driver->root.library,                              "pshinter" );      if ( module )      {        T2_Hints_Funcs  funcs;        funcs = pshinter->get_t2_funcs( module );        slot->root.internal->glyph_hints = (void*)funcs;      }    }    return 0;  }  /*************************************************************************/  /*                                                                       */  /*                           FACE  FUNCTIONS                             */  /*                                                                       */  /*************************************************************************/  static FT_String*  CFF_StrCopy( FT_Memory         memory,               const FT_String*  source )  {    FT_Error    error;    FT_String*  result = 0;    FT_Int      len = (FT_Int)strlen( source );    if ( !ALLOC( result, len + 1 ) )    {      MEM_Copy( result, source, len );      result[len] = 0;    }    return result;  }#if 0  /* this function is used to build a Unicode charmap from the glyph names */  /* in a file                                                             */  static FT_Error  CFF_Build_Unicode_Charmap( CFF_Face            face,                             FT_ULong            base_offset,                             PSNames_Interface*  psnames )  {    CFF_Font*       font = (CFF_Font*)face->extra.data;    FT_Memory       memory = FT_FACE_MEMORY(face);    FT_UInt         n, num_glyphs = face->root.num_glyphs;    const char**    glyph_names;    FT_Error        error;    CFF_Font_Dict*  dict = &font->top_font.font_dict;    FT_ULong        charset_offset;    FT_Byte         format;    FT_Stream       stream = face->root.stream;    charset_offset = dict->charset_offset;    if ( !charset_offset )    {      FT_ERROR(( "CFF_Build_Unicode_Charmap: charset table is missing\n" ));      error = CFF_Err_Invalid_File_Format;      goto Exit;    }    /* allocate the charmap */    if ( ALLOC( face->charmap, ...    /* seek to charset table and allocate glyph names table */    if ( FILE_Seek( base_offset + charset_offset )           ||         ALLOC_ARRAY( glyph_names, num_glyphs, const char* ) )      goto Exit;    /* now, read each glyph name and store it in the glyph name table */    if ( READ_Byte( format ) )      goto Fail;    switch ( format )    {    case 0:  /* format 0 - one SID per glyph */      {        const char**  gname = glyph_names;        const char**  limit = gname + num_glyphs;        if ( ACCESS_Frame( num_glyphs * 2 ) )          goto Fail;        for ( ; gname < limit; gname++ )          gname[0] = CFF_Get_String( &font->string_index,                                     GET_UShort(),                                     psnames );        FORGET_Frame();        break;      }    case 1:  /* format 1 - sequential ranges                    */    case 2:  /* format 2 - sequential ranges with 16-bit counts */      {        const char**  gname = glyph_names;        const char**  limit = gname + num_glyphs;        FT_UInt       len = 3;        if ( format == 2 )          len++;        while ( gname < limit )        {          FT_UInt  first;          FT_UInt  count;          if ( ACCESS_Frame( len ) )            goto Fail;          first = GET_UShort();          if ( format == 3 )            count = GET_UShort();          else            count = GET_Byte();          FORGET_Frame();          for ( ; count > 0; count-- )          {            gname[0] = CFF_Get_String( &font->string_index,                                       first,                                       psnames );            gname++;            first++;          }        }        break;      }    default:   /* unknown charset format! */      FT_ERROR(( "CFF_Build_Unicode_Charmap: unknown charset format!\n" ));      error = CFF_Err_Invalid_File_Format;      goto Fail;    }    /* all right, the glyph names were loaded; we now need to create */    /* the corresponding unicode charmap                             */  Fail:    for ( n = 0; n < num_glyphs; n++ )      FREE( glyph_names[n] );    FREE( glyph_names );  Exit:    return error;  }#endif /* 0 */  static FT_Encoding  find_encoding( int  platform_id,                 int  encoding_id )  {    typedef struct  TEncoding    {      int          platform_id;      int          encoding_id;      FT_Encoding  encoding;    } TEncoding;    static    const TEncoding  tt_encodings[] =    {      { TT_PLATFORM_ISO,           -1,                  ft_encoding_unicode },      { TT_PLATFORM_APPLE_UNICODE, -1,                  ft_encoding_unicode },      { TT_PLATFORM_MACINTOSH,     TT_MAC_ID_ROMAN,     ft_encoding_apple_roman },      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_UNICODE_CS, ft_encoding_unicode },      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_SJIS,       ft_encoding_sjis },      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_GB2312,     ft_encoding_gb2312 },      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_BIG_5,      ft_encoding_big5 },      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_WANSUNG,    ft_encoding_wansung },      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_JOHAB,      ft_encoding_johab }

⌨️ 快捷键说明

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