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

📄 cidload.c

📁 奇趣公司比较新的qt/emd版本
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************//*                                                                         *//*  cidload.c                                                              *//*                                                                         *//*    CID-keyed Type1 font loader (body).                                  *//*                                                                         *//*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 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_CONFIG_CONFIG_H#include FT_MULTIPLE_MASTERS_H#include FT_INTERNAL_TYPE1_TYPES_H#include "cidload.h"#include "ciderrs.h"  /*************************************************************************/  /*                                                                       */  /* 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_cidload  /* read a single offset */  FT_LOCAL_DEF( FT_Long )  cid_get_offset( FT_Byte*  *start,                  FT_Byte    offsize )  {    FT_Long   result;    FT_Byte*  p = *start;    for ( result = 0; offsize > 0; offsize-- )    {      result <<= 8;      result  |= *p++;    }    *start = p;    return result;  }  /*************************************************************************/  /*************************************************************************/  /*****                                                               *****/  /*****                    TYPE 1 SYMBOL PARSING                      *****/  /*****                                                               *****/  /*************************************************************************/  /*************************************************************************/  static FT_Error  cid_load_keyword( CID_Face        face,                    CID_Loader*     loader,                    const T1_Field  keyword )  {    FT_Error      error;    CID_Parser*   parser = &loader->parser;    FT_Byte*      object;    void*         dummy_object;    CID_FaceInfo  cid = &face->cid;    /* if the keyword has a dedicated callback, call it */    if ( keyword->type == T1_FIELD_TYPE_CALLBACK )    {      keyword->reader( (FT_Face)face, parser );      error = parser->root.error;      goto Exit;    }    /* we must now compute the address of our target object */    switch ( keyword->location )    {    case T1_FIELD_LOCATION_CID_INFO:      object = (FT_Byte*)cid;      break;    case T1_FIELD_LOCATION_FONT_INFO:      object = (FT_Byte*)&cid->font_info;      break;    case T1_FIELD_LOCATION_BBOX:      object = (FT_Byte*)&cid->font_bbox;      break;    default:      {        CID_FaceDict  dict;        if ( parser->num_dict < 0 )        {          FT_ERROR(( "cid_load_keyword: invalid use of `%s'!\n",                     keyword->ident ));          error = CID_Err_Syntax_Error;          goto Exit;        }        dict = cid->font_dicts + parser->num_dict;        switch ( keyword->location )        {        case T1_FIELD_LOCATION_PRIVATE:          object = (FT_Byte*)&dict->private_dict;          break;        default:          object = (FT_Byte*)dict;        }      }    }    dummy_object = object;    /* now, load the keyword data in the object's field(s) */    if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY ||         keyword->type == T1_FIELD_TYPE_FIXED_ARRAY   )      error = cid_parser_load_field_table( &loader->parser, keyword,                                           &dummy_object );    else      error = cid_parser_load_field( &loader->parser,                                     keyword, &dummy_object );  Exit:    return error;  }  FT_CALLBACK_DEF( FT_Error )  parse_font_matrix( CID_Face     face,                     CID_Parser*  parser )  {    FT_Matrix*    matrix;    FT_Vector*    offset;    CID_FaceDict  dict;    FT_Face       root = (FT_Face)&face->root;    FT_Fixed      temp[6];    FT_Fixed      temp_scale;    if ( parser->num_dict >= 0 )    {      dict   = face->cid.font_dicts + parser->num_dict;      matrix = &dict->font_matrix;      offset = &dict->font_offset;      (void)cid_parser_to_fixed_array( parser, 6, temp, 3 );      temp_scale = FT_ABS( temp[3] );      /* Set units per EM based on FontMatrix values.  We set the value to */      /* `1000/temp_scale', because temp_scale was already multiplied by   */      /* 1000 (in `t1_tofixed', from psobjs.c).                            */      root->units_per_EM = (FT_UShort)( FT_DivFix( 0x10000L,                                        FT_DivFix( temp_scale, 1000 ) ) );      /* we need to scale the values by 1.0/temp[3] */      if ( temp_scale != 0x10000L )      {        temp[0] = FT_DivFix( temp[0], temp_scale );        temp[1] = FT_DivFix( temp[1], temp_scale );        temp[2] = FT_DivFix( temp[2], temp_scale );        temp[4] = FT_DivFix( temp[4], temp_scale );        temp[5] = FT_DivFix( temp[5], temp_scale );        temp[3] = 0x10000L;      }      matrix->xx = temp[0];      matrix->yx = temp[1];      matrix->xy = temp[2];      matrix->yy = temp[3];      /* note that the font offsets are expressed in integer font units */      offset->x  = temp[4] >> 16;      offset->y  = temp[5] >> 16;    }    return CID_Err_Ok;      /* this is a callback function; */                            /* we must return an error code */  }  FT_CALLBACK_DEF( FT_Error )  parse_fd_array( CID_Face     face,                  CID_Parser*  parser )  {    CID_FaceInfo  cid    = &face->cid;    FT_Memory     memory = face->root.memory;    FT_Error      error  = CID_Err_Ok;    FT_Long       num_dicts;    num_dicts = cid_parser_to_int( parser );    if ( !cid->font_dicts )    {      FT_Int  n;      if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) )        goto Exit;      cid->num_dicts = (FT_UInt)num_dicts;      /* don't forget to set a few defaults */      for ( n = 0; n < cid->num_dicts; n++ )      {        CID_FaceDict  dict = cid->font_dicts + n;        /* default value for lenIV */        dict->private_dict.lenIV = 4;      }    }  Exit:    return error;  }  static  const T1_FieldRec  cid_field_records[] =  {#include "cidtoken.h"    T1_FIELD_CALLBACK( "FDArray",    parse_fd_array, 0 )    T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix, 0 )    { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 }  };  static FT_Error  cid_parse_dict( CID_Face     face,                  CID_Loader*  loader,                  FT_Byte*     base,                  FT_Long      size )  {    CID_Parser*  parser = &loader->parser;    parser->root.cursor = base;    parser->root.limit  = base + size;    parser->root.error  = CID_Err_Ok;    {      FT_Byte*  cur   = base;      FT_Byte*  limit = cur + size;      for (;;)      {        FT_Byte*  newlimit;        parser->root.cursor = cur;        cid_parser_skip_spaces( parser );        if ( parser->root.cursor >= limit )          newlimit = limit - 1 - 17;        else          newlimit = parser->root.cursor - 17;        /* look for `%ADOBeginFontDict' */        for ( ; cur < newlimit; cur++ )        {          if ( *cur == '%'                                            &&               ft_strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )          {            /* if /FDArray was found, then cid->num_dicts is > 0, and */            /* we can start increasing parser->num_dict               */            if ( face->cid.num_dicts > 0 )              parser->num_dict++;          }        }        cur = parser->root.cursor;        /* no error can occur in cid_parser_skip_spaces */        if ( cur >= limit )          break;        cid_parser_skip_PS_token( parser );        if ( parser->root.cursor >= limit || parser->root.error )          break;        /* look for immediates */        if ( *cur == '/' && cur + 2 < limit )        {          FT_PtrDist  len;          cur++;          len = parser->root.cursor - cur;          if ( len > 0 && len < 22 )          {            /* now compare the immediate name to the keyword table */            T1_Field  keyword = (T1_Field)cid_field_records;            for (;;)            {              FT_Byte*  name;              name = (FT_Byte*)keyword->ident;

⌨️ 快捷键说明

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