< prev index next >

src/java.desktop/share/native/libfreetype/src/type1/t1parse.c

Print this page


   1 /***************************************************************************/
   2 /*                                                                         */
   3 /*  t1parse.c                                                              */
   4 /*                                                                         */
   5 /*    Type 1 parser (body).                                                */
   6 /*                                                                         */
   7 /*  Copyright 1996-2018 by                                                 */
   8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
   9 /*                                                                         */
  10 /*  This file is part of the FreeType project, and may only be used,       */
  11 /*  modified, and distributed under the terms of the FreeType project      */
  12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
  13 /*  this file you indicate that you have read the license and              */
  14 /*  understand and accept it fully.                                        */
  15 /*                                                                         */
  16 /***************************************************************************/
  17 
  18 
  19   /*************************************************************************/
  20   /*                                                                       */
  21   /* The Type 1 parser is in charge of the following:                      */
  22   /*                                                                       */
  23   /*  - provide an implementation of a growing sequence of objects called  */
  24   /*    a `T1_Table' (used to build various tables needed by the loader).  */
  25   /*                                                                       */
  26   /*  - opening .pfb and .pfa files to extract their top-level and private */
  27   /*    dictionaries.                                                      */
  28   /*                                                                       */
  29   /*  - read numbers, arrays & strings from any dictionary.                */
  30   /*                                                                       */
  31   /* See `t1load.c' to see how data is loaded from the font file.          */
  32   /*                                                                       */
  33   /*************************************************************************/
  34 
  35 
  36 #include <ft2build.h>
  37 #include FT_INTERNAL_DEBUG_H
  38 #include FT_INTERNAL_STREAM_H
  39 #include FT_INTERNAL_POSTSCRIPT_AUX_H
  40 
  41 #include "t1parse.h"
  42 
  43 #include "t1errors.h"
  44 
  45 
  46   /*************************************************************************/
  47   /*                                                                       */
  48   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
  49   /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
  50   /* messages during execution.                                            */
  51   /*                                                                       */
  52 #undef  FT_COMPONENT
  53 #define FT_COMPONENT  trace_t1parse
  54 
  55 
  56   /*************************************************************************/
  57   /*************************************************************************/
  58   /*************************************************************************/
  59   /*****                                                               *****/
  60   /*****                   INPUT STREAM PARSER                         *****/
  61   /*****                                                               *****/
  62   /*************************************************************************/
  63   /*************************************************************************/
  64   /*************************************************************************/
  65 
  66 
  67   /* see Adobe Technical Note 5040.Download_Fonts.pdf */
  68 
  69   static FT_Error
  70   read_pfb_tag( FT_Stream   stream,
  71                 FT_UShort  *atag,
  72                 FT_ULong   *asize )
  73   {


 152     parser->private_dict = NULL;
 153     parser->in_pfb       = 0;
 154     parser->in_memory    = 0;
 155     parser->single_block = 0;
 156 
 157     /* check the header format */
 158     error = check_type1_format( stream, "%!PS-AdobeFont", 14 );
 159     if ( error )
 160     {
 161       if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
 162         goto Exit;
 163 
 164       error = check_type1_format( stream, "%!FontType", 10 );
 165       if ( error )
 166       {
 167         FT_TRACE2(( "  not a Type 1 font\n" ));
 168         goto Exit;
 169       }
 170     }
 171 
 172     /******************************************************************/
 173     /*                                                                */
 174     /* Here a short summary of what is going on:                      */
 175     /*                                                                */
 176     /*   When creating a new Type 1 parser, we try to locate and load */
 177     /*   the base dictionary if this is possible (i.e., for PFB       */
 178     /*   files).  Otherwise, we load the whole font into memory.      */
 179     /*                                                                */
 180     /*   When `loading' the base dictionary, we only setup pointers   */
 181     /*   in the case of a memory-based stream.  Otherwise, we         */
 182     /*   allocate and load the base dictionary in it.                 */
 183     /*                                                                */
 184     /*   parser->in_pfb is set if we are in a binary (`.pfb') font.   */
 185     /*   parser->in_memory is set if we have a memory stream.         */
 186     /*                                                                */
 187 
 188     /* try to compute the size of the base dictionary;     */
 189     /* look for a Postscript binary file tag, i.e., 0x8001 */
 190     if ( FT_STREAM_SEEK( 0L ) )
 191       goto Exit;
 192 
 193     error = read_pfb_tag( stream, &tag, &size );
 194     if ( error )
 195       goto Exit;
 196 
 197     if ( tag != 0x8001U )
 198     {
 199       /* assume that this is a PFA file for now; an error will */
 200       /* be produced later when more things are checked        */
 201       if ( FT_STREAM_SEEK( 0L ) )
 202         goto Exit;
 203       size = stream->size;
 204     }
 205     else
 206       parser->in_pfb = 1;


   1 /****************************************************************************
   2  *
   3  * t1parse.c
   4  *
   5  *   Type 1 parser (body).
   6  *
   7  * Copyright (C) 1996-2019 by
   8  * David Turner, Robert Wilhelm, and Werner Lemberg.
   9  *
  10  * This file is part of the FreeType project, and may only be used,
  11  * modified, and distributed under the terms of the FreeType project
  12  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
  13  * this file you indicate that you have read the license and
  14  * understand and accept it fully.
  15  *
  16  */
  17 
  18 
  19   /**************************************************************************
  20    *
  21    * The Type 1 parser is in charge of the following:
  22    *
  23    * - provide an implementation of a growing sequence of objects called
  24    *   a `T1_Table' (used to build various tables needed by the loader).
  25    *
  26    * - opening .pfb and .pfa files to extract their top-level and private
  27    *   dictionaries.
  28    *
  29    * - read numbers, arrays & strings from any dictionary.
  30    *
  31    * See `t1load.c' to see how data is loaded from the font file.
  32    *
  33    */
  34 
  35 
  36 #include <ft2build.h>
  37 #include FT_INTERNAL_DEBUG_H
  38 #include FT_INTERNAL_STREAM_H
  39 #include FT_INTERNAL_POSTSCRIPT_AUX_H
  40 
  41 #include "t1parse.h"
  42 
  43 #include "t1errors.h"
  44 
  45 
  46   /**************************************************************************
  47    *
  48    * The macro FT_COMPONENT is used in trace mode.  It is an implicit
  49    * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
  50    * messages during execution.
  51    */
  52 #undef  FT_COMPONENT
  53 #define FT_COMPONENT  t1parse
  54 
  55 
  56   /*************************************************************************/
  57   /*************************************************************************/
  58   /*************************************************************************/
  59   /*****                                                               *****/
  60   /*****                   INPUT STREAM PARSER                         *****/
  61   /*****                                                               *****/
  62   /*************************************************************************/
  63   /*************************************************************************/
  64   /*************************************************************************/
  65 
  66 
  67   /* see Adobe Technical Note 5040.Download_Fonts.pdf */
  68 
  69   static FT_Error
  70   read_pfb_tag( FT_Stream   stream,
  71                 FT_UShort  *atag,
  72                 FT_ULong   *asize )
  73   {


 152     parser->private_dict = NULL;
 153     parser->in_pfb       = 0;
 154     parser->in_memory    = 0;
 155     parser->single_block = 0;
 156 
 157     /* check the header format */
 158     error = check_type1_format( stream, "%!PS-AdobeFont", 14 );
 159     if ( error )
 160     {
 161       if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
 162         goto Exit;
 163 
 164       error = check_type1_format( stream, "%!FontType", 10 );
 165       if ( error )
 166       {
 167         FT_TRACE2(( "  not a Type 1 font\n" ));
 168         goto Exit;
 169       }
 170     }
 171 
 172     /*******************************************************************
 173      *
 174      * Here a short summary of what is going on:
 175      *
 176      *   When creating a new Type 1 parser, we try to locate and load
 177      *   the base dictionary if this is possible (i.e., for PFB
 178      *   files).  Otherwise, we load the whole font into memory.
 179      *
 180      *   When `loading' the base dictionary, we only setup pointers
 181      *   in the case of a memory-based stream.  Otherwise, we
 182      *   allocate and load the base dictionary in it.
 183      *
 184      *   parser->in_pfb is set if we are in a binary (`.pfb') font.
 185      *   parser->in_memory is set if we have a memory stream.
 186      */
 187 
 188     /* try to compute the size of the base dictionary;     */
 189     /* look for a Postscript binary file tag, i.e., 0x8001 */
 190     if ( FT_STREAM_SEEK( 0L ) )
 191       goto Exit;
 192 
 193     error = read_pfb_tag( stream, &tag, &size );
 194     if ( error )
 195       goto Exit;
 196 
 197     if ( tag != 0x8001U )
 198     {
 199       /* assume that this is a PFA file for now; an error will */
 200       /* be produced later when more things are checked        */
 201       if ( FT_STREAM_SEEK( 0L ) )
 202         goto Exit;
 203       size = stream->size;
 204     }
 205     else
 206       parser->in_pfb = 1;


< prev index next >