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

📄 t1parse.c

📁 奇趣公司比较新的qt/emd版本
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************//*                                                                         *//*  t1parse.c                                                              *//*                                                                         *//*    Type 1 parser (body).                                                *//*                                                                         *//*  Copyright 1996-2001, 2002, 2003, 2004, 2005 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.                                        *//*                                                                         *//***************************************************************************/  /*************************************************************************/  /*                                                                       */  /* The Type 1 parser is in charge of the following:                      */  /*                                                                       */  /*  - provide an implementation of a growing sequence of objects called  */  /*    a `T1_Table' (used to build various tables needed by the loader).  */  /*                                                                       */  /*  - opening .pfb and .pfa files to extract their top-level and private */  /*    dictionaries.                                                      */  /*                                                                       */  /*  - read numbers, arrays & strings from any dictionary.                */  /*                                                                       */  /* See `t1load.c' to see how data is loaded from the font file.          */  /*                                                                       */  /*************************************************************************/#include <ft2build.h>#include FT_INTERNAL_DEBUG_H#include FT_INTERNAL_CALC_H#include FT_INTERNAL_STREAM_H#include FT_INTERNAL_POSTSCRIPT_AUX_H#include "t1parse.h"#include "t1errors.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_t1parse  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /*****                                                               *****/  /*****                   INPUT STREAM PARSER                         *****/  /*****                                                               *****/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  static FT_Error  read_pfb_tag( FT_Stream   stream,                FT_UShort  *atag,                FT_Long    *asize )  {    FT_Error   error;    FT_UShort  tag;    FT_Long    size;    *atag  = 0;    *asize = 0;    if ( !FT_READ_USHORT( tag ) )    {      if ( tag == 0x8001U || tag == 0x8002U )      {        if ( !FT_READ_LONG_LE( size ) )          *asize = size;      }      *atag = tag;    }    return error;  }  static FT_Error  check_type1_format( FT_Stream    stream,                      const char*  header_string,                      size_t       header_length )  {    FT_Error   error;    FT_UShort  tag;    FT_Long    size;    if ( FT_STREAM_SEEK( 0 ) )      goto Exit;    error = read_pfb_tag( stream, &tag, &size );    if ( error )      goto Exit;    if ( tag != 0x8001U && FT_STREAM_SEEK( 0 ) )      goto Exit;    if ( !FT_FRAME_ENTER( header_length ) )    {      error = 0;      if ( ft_memcmp( stream->cursor, header_string, header_length ) != 0 )        error = T1_Err_Unknown_File_Format;      FT_FRAME_EXIT();    }  Exit:    return error;  }  FT_LOCAL_DEF( FT_Error )  T1_New_Parser( T1_Parser      parser,                 FT_Stream      stream,                 FT_Memory      memory,                 PSAux_Service  psaux )  {    FT_Error   error;    FT_UShort  tag;    FT_Long    size;    psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );    parser->stream       = stream;    parser->base_len     = 0;    parser->base_dict    = 0;    parser->private_len  = 0;    parser->private_dict = 0;    parser->in_pfb       = 0;    parser->in_memory    = 0;    parser->single_block = 0;    /* check the header format */    error = check_type1_format( stream, "%!PS-AdobeFont", 14 );    if ( error )    {      if ( error != T1_Err_Unknown_File_Format )        goto Exit;      error = check_type1_format( stream, "%!FontType", 10 );      if ( error )      {        FT_TRACE2(( "[not a Type1 font]\n" ));        goto Exit;      }    }    /******************************************************************/    /*                                                                */    /* Here a short summary of what is going on:                      */    /*                                                                */    /*   When creating a new Type 1 parser, we try to locate and load */    /*   the base dictionary if this is possible (i.e. for PFB        */    /*   files).  Otherwise, we load the whole font into memory.      */    /*                                                                */    /*   When `loading' the base dictionary, we only setup pointers   */    /*   in the case of a memory-based stream.  Otherwise, we         */    /*   allocate and load the base dictionary in it.                 */    /*                                                                */    /*   parser->in_pfb is set if we are in a binary (".pfb") font.   */    /*   parser->in_memory is set if we have a memory stream.         */    /*                                                                */    /* try to compute the size of the base dictionary;   */    /* look for a Postscript binary file tag, i.e 0x8001 */    if ( FT_STREAM_SEEK( 0L ) )      goto Exit;    error = read_pfb_tag( stream, &tag, &size );    if ( error )      goto Exit;    if ( tag != 0x8001U )    {      /* assume that this is a PFA file for now; an error will */      /* be produced later when more things are checked        */      if ( FT_STREAM_SEEK( 0L ) )        goto Exit;      size = stream->size;    }    else      parser->in_pfb = 1;    /* now, try to load `size' bytes of the `base' dictionary we */    /* found previously                                          */    /* if it is a memory-based resource, set up pointers */    if ( !stream->read )    {      parser->base_dict = (FT_Byte*)stream->base + stream->pos;      parser->base_len  = size;      parser->in_memory = 1;      /* check that the `size' field is valid */      if ( FT_STREAM_SKIP( size ) )        goto Exit;    }    else    {      /* read segment in memory - this is clumsy, but so does the format */      if ( FT_ALLOC( parser->base_dict, size )       ||           FT_STREAM_READ( parser->base_dict, size ) )        goto Exit;      parser->base_len = size;    }    parser->root.base   = parser->base_dict;    parser->root.cursor = parser->base_dict;    parser->root.limit  = parser->root.cursor + parser->base_len;  Exit:    if ( error && !parser->in_memory )      FT_FREE( parser->base_dict );    return error;  }  FT_LOCAL_DEF( void )  T1_Finalize_Parser( T1_Parser  parser )

⌨️ 快捷键说明

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