1 /****************************************************************************
   2  *
   3  * t1parse.h
   4  *
   5  *   Type 1 parser (specification).
   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 #ifndef T1PARSE_H_
  20 #define T1PARSE_H_
  21 
  22 
  23 #include <ft2build.h>
  24 #include FT_INTERNAL_TYPE1_TYPES_H
  25 #include FT_INTERNAL_STREAM_H
  26 
  27 
  28 FT_BEGIN_HEADER
  29 
  30 
  31   /**************************************************************************
  32    *
  33    * @Struct:
  34    *   T1_ParserRec
  35    *
  36    * @Description:
  37    *   A PS_ParserRec is an object used to parse a Type 1 fonts very
  38    *   quickly.
  39    *
  40    * @Fields:
  41    *   root ::
  42    *     The root parser.
  43    *
  44    *   stream ::
  45    *     The current input stream.
  46    *
  47    *   base_dict ::
  48    *     A pointer to the top-level dictionary.
  49    *
  50    *   base_len ::
  51    *     The length in bytes of the top dictionary.
  52    *
  53    *   private_dict ::
  54    *     A pointer to the private dictionary.
  55    *
  56    *   private_len ::
  57    *     The length in bytes of the private dictionary.
  58    *
  59    *   in_pfb ::
  60    *     A boolean.  Indicates that we are handling a PFB
  61    *     file.
  62    *
  63    *   in_memory ::
  64    *     A boolean.  Indicates a memory-based stream.
  65    *
  66    *   single_block ::
  67    *     A boolean.  Indicates that the private dictionary
  68    *     is stored in lieu of the base dictionary.
  69    */
  70   typedef struct  T1_ParserRec_
  71   {
  72     PS_ParserRec  root;
  73     FT_Stream     stream;
  74 
  75     FT_Byte*      base_dict;
  76     FT_ULong      base_len;
  77 
  78     FT_Byte*      private_dict;
  79     FT_ULong      private_len;
  80 
  81     FT_Bool       in_pfb;
  82     FT_Bool       in_memory;
  83     FT_Bool       single_block;
  84 
  85   } T1_ParserRec, *T1_Parser;
  86 
  87 
  88 #define T1_Add_Table( p, i, o, l )  (p)->funcs.add( (p), i, o, l )
  89 #define T1_Release_Table( p )          \
  90           do                           \
  91           {                            \
  92             if ( (p)->funcs.release )  \
  93               (p)->funcs.release( p ); \
  94           } while ( 0 )
  95 
  96 
  97 #define T1_Skip_Spaces( p )    (p)->root.funcs.skip_spaces( &(p)->root )
  98 #define T1_Skip_PS_Token( p )  (p)->root.funcs.skip_PS_token( &(p)->root )
  99 
 100 #define T1_ToInt( p )       (p)->root.funcs.to_int( &(p)->root )
 101 #define T1_ToFixed( p, t )  (p)->root.funcs.to_fixed( &(p)->root, t )
 102 
 103 #define T1_ToCoordArray( p, m, c )                           \
 104           (p)->root.funcs.to_coord_array( &(p)->root, m, c )
 105 #define T1_ToFixedArray( p, m, f, t )                           \
 106           (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
 107 #define T1_ToToken( p, t )                          \
 108           (p)->root.funcs.to_token( &(p)->root, t )
 109 #define T1_ToTokenArray( p, t, m, c )                           \
 110           (p)->root.funcs.to_token_array( &(p)->root, t, m, c )
 111 
 112 #define T1_Load_Field( p, f, o, m, pf )                         \
 113           (p)->root.funcs.load_field( &(p)->root, f, o, m, pf )
 114 
 115 #define T1_Load_Field_Table( p, f, o, m, pf )                         \
 116           (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )
 117 
 118 
 119   FT_LOCAL( FT_Error )
 120   T1_New_Parser( T1_Parser      parser,
 121                  FT_Stream      stream,
 122                  FT_Memory      memory,
 123                  PSAux_Service  psaux );
 124 
 125   FT_LOCAL( FT_Error )
 126   T1_Get_Private_Dict( T1_Parser      parser,
 127                        PSAux_Service  psaux );
 128 
 129   FT_LOCAL( void )
 130   T1_Finalize_Parser( T1_Parser  parser );
 131 
 132 
 133 FT_END_HEADER
 134 
 135 #endif /* T1PARSE_H_ */
 136 
 137 
 138 /* END */