Home | History | Annotate | Download | only in internal
      1 /****************************************************************************
      2  *
      3  * psaux.h
      4  *
      5  *   Auxiliary functions and data structures related to PostScript fonts
      6  *   (specification).
      7  *
      8  * Copyright 1996-2018 by
      9  * David Turner, Robert Wilhelm, and Werner Lemberg.
     10  *
     11  * This file is part of the FreeType project, and may only be used,
     12  * modified, and distributed under the terms of the FreeType project
     13  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
     14  * this file you indicate that you have read the license and
     15  * understand and accept it fully.
     16  *
     17  */
     18 
     19 
     20 #ifndef PSAUX_H_
     21 #define PSAUX_H_
     22 
     23 
     24 #include <ft2build.h>
     25 #include FT_INTERNAL_OBJECTS_H
     26 #include FT_INTERNAL_TYPE1_TYPES_H
     27 #include FT_INTERNAL_HASH_H
     28 #include FT_INTERNAL_TRUETYPE_TYPES_H
     29 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
     30 #include FT_INTERNAL_CFF_TYPES_H
     31 #include FT_INTERNAL_CFF_OBJECTS_TYPES_H
     32 
     33 
     34 
     35 FT_BEGIN_HEADER
     36 
     37 
     38   /************************************************************************
     39    *
     40    * PostScript modules driver class.
     41    */
     42   typedef struct  PS_DriverRec_
     43   {
     44     FT_DriverRec  root;
     45 
     46     FT_UInt   hinting_engine;
     47     FT_Bool   no_stem_darkening;
     48     FT_Int    darken_params[8];
     49     FT_Int32  random_seed;
     50 
     51   } PS_DriverRec, *PS_Driver;
     52 
     53 
     54   /*************************************************************************/
     55   /*************************************************************************/
     56   /*****                                                               *****/
     57   /*****                             T1_TABLE                          *****/
     58   /*****                                                               *****/
     59   /*************************************************************************/
     60   /*************************************************************************/
     61 
     62 
     63   typedef struct PS_TableRec_*              PS_Table;
     64   typedef const struct PS_Table_FuncsRec_*  PS_Table_Funcs;
     65 
     66 
     67   /**************************************************************************
     68    *
     69    * @struct:
     70    *   PS_Table_FuncsRec
     71    *
     72    * @description:
     73    *   A set of function pointers to manage PS_Table objects.
     74    *
     75    * @fields:
     76    *   table_init ::
     77    *     Used to initialize a table.
     78    *
     79    *   table_done ::
     80    *     Finalizes resp. destroy a given table.
     81    *
     82    *   table_add ::
     83    *     Adds a new object to a table.
     84    *
     85    *   table_release ::
     86    *     Releases table data, then finalizes it.
     87    */
     88   typedef struct  PS_Table_FuncsRec_
     89   {
     90     FT_Error
     91     (*init)( PS_Table   table,
     92              FT_Int     count,
     93              FT_Memory  memory );
     94 
     95     void
     96     (*done)( PS_Table  table );
     97 
     98     FT_Error
     99     (*add)( PS_Table  table,
    100             FT_Int    idx,
    101             void*     object,
    102             FT_UInt   length );
    103 
    104     void
    105     (*release)( PS_Table  table );
    106 
    107   } PS_Table_FuncsRec;
    108 
    109 
    110   /**************************************************************************
    111    *
    112    * @struct:
    113    *   PS_TableRec
    114    *
    115    * @description:
    116    *   A PS_Table is a simple object used to store an array of objects in
    117    *   a single memory block.
    118    *
    119    * @fields:
    120    *   block ::
    121    *     The address in memory of the growheap's block.  This
    122    *     can change between two object adds, due to
    123    *     reallocation.
    124    *
    125    *   cursor ::
    126    *     The current top of the grow heap within its block.
    127    *
    128    *   capacity ::
    129    *     The current size of the heap block.  Increments by
    130    *     1kByte chunks.
    131    *
    132    *   init ::
    133    *     Set to 0xDEADBEEF if `elements' and `lengths' have
    134    *     been allocated.
    135    *
    136    *   max_elems ::
    137    *     The maximum number of elements in table.
    138    *
    139    *   num_elems ::
    140    *     The current number of elements in table.
    141    *
    142    *   elements ::
    143    *     A table of element addresses within the block.
    144    *
    145    *   lengths ::
    146    *     A table of element sizes within the block.
    147    *
    148    *   memory ::
    149    *     The object used for memory operations
    150    *     (alloc/realloc).
    151    *
    152    *   funcs ::
    153    *     A table of method pointers for this object.
    154    */
    155   typedef struct  PS_TableRec_
    156   {
    157     FT_Byte*           block;          /* current memory block           */
    158     FT_Offset          cursor;         /* current cursor in memory block */
    159     FT_Offset          capacity;       /* current size of memory block   */
    160     FT_ULong           init;
    161 
    162     FT_Int             max_elems;
    163     FT_Int             num_elems;
    164     FT_Byte**          elements;       /* addresses of table elements */
    165     FT_UInt*           lengths;        /* lengths of table elements   */
    166 
    167     FT_Memory          memory;
    168     PS_Table_FuncsRec  funcs;
    169 
    170   } PS_TableRec;
    171 
    172 
    173   /*************************************************************************/
    174   /*************************************************************************/
    175   /*****                                                               *****/
    176   /*****                       T1 FIELDS & TOKENS                      *****/
    177   /*****                                                               *****/
    178   /*************************************************************************/
    179   /*************************************************************************/
    180 
    181   typedef struct PS_ParserRec_*  PS_Parser;
    182 
    183   typedef struct T1_TokenRec_*   T1_Token;
    184 
    185   typedef struct T1_FieldRec_*   T1_Field;
    186 
    187 
    188   /* simple enumeration type used to identify token types */
    189   typedef enum  T1_TokenType_
    190   {
    191     T1_TOKEN_TYPE_NONE = 0,
    192     T1_TOKEN_TYPE_ANY,
    193     T1_TOKEN_TYPE_STRING,
    194     T1_TOKEN_TYPE_ARRAY,
    195     T1_TOKEN_TYPE_KEY, /* aka `name' */
    196 
    197     /* do not remove */
    198     T1_TOKEN_TYPE_MAX
    199 
    200   } T1_TokenType;
    201 
    202 
    203   /* a simple structure used to identify tokens */
    204   typedef struct  T1_TokenRec_
    205   {
    206     FT_Byte*      start;   /* first character of token in input stream */
    207     FT_Byte*      limit;   /* first character after the token          */
    208     T1_TokenType  type;    /* type of token                            */
    209 
    210   } T1_TokenRec;
    211 
    212 
    213   /* enumeration type used to identify object fields */
    214   typedef enum  T1_FieldType_
    215   {
    216     T1_FIELD_TYPE_NONE = 0,
    217     T1_FIELD_TYPE_BOOL,
    218     T1_FIELD_TYPE_INTEGER,
    219     T1_FIELD_TYPE_FIXED,
    220     T1_FIELD_TYPE_FIXED_1000,
    221     T1_FIELD_TYPE_STRING,
    222     T1_FIELD_TYPE_KEY,
    223     T1_FIELD_TYPE_BBOX,
    224     T1_FIELD_TYPE_MM_BBOX,
    225     T1_FIELD_TYPE_INTEGER_ARRAY,
    226     T1_FIELD_TYPE_FIXED_ARRAY,
    227     T1_FIELD_TYPE_CALLBACK,
    228 
    229     /* do not remove */
    230     T1_FIELD_TYPE_MAX
    231 
    232   } T1_FieldType;
    233 
    234 
    235   typedef enum  T1_FieldLocation_
    236   {
    237     T1_FIELD_LOCATION_CID_INFO,
    238     T1_FIELD_LOCATION_FONT_DICT,
    239     T1_FIELD_LOCATION_FONT_EXTRA,
    240     T1_FIELD_LOCATION_FONT_INFO,
    241     T1_FIELD_LOCATION_PRIVATE,
    242     T1_FIELD_LOCATION_BBOX,
    243     T1_FIELD_LOCATION_LOADER,
    244     T1_FIELD_LOCATION_FACE,
    245     T1_FIELD_LOCATION_BLEND,
    246 
    247     /* do not remove */
    248     T1_FIELD_LOCATION_MAX
    249 
    250   } T1_FieldLocation;
    251 
    252 
    253   typedef void
    254   (*T1_Field_ParseFunc)( FT_Face     face,
    255                          FT_Pointer  parser );
    256 
    257 
    258   /* structure type used to model object fields */
    259   typedef struct  T1_FieldRec_
    260   {
    261     const char*         ident;        /* field identifier               */
    262     T1_FieldLocation    location;
    263     T1_FieldType        type;         /* type of field                  */
    264     T1_Field_ParseFunc  reader;
    265     FT_UInt             offset;       /* offset of field in object      */
    266     FT_Byte             size;         /* size of field in bytes         */
    267     FT_UInt             array_max;    /* maximum number of elements for */
    268                                       /* array                          */
    269     FT_UInt             count_offset; /* offset of element count for    */
    270                                       /* arrays; must not be zero if in */
    271                                       /* use -- in other words, a       */
    272                                       /* `num_FOO' element must not     */
    273                                       /* start the used structure if we */
    274                                       /* parse a `FOO' array            */
    275     FT_UInt             dict;         /* where we expect it             */
    276   } T1_FieldRec;
    277 
    278 #define T1_FIELD_DICT_FONTDICT ( 1 << 0 ) /* also FontInfo and FDArray */
    279 #define T1_FIELD_DICT_PRIVATE  ( 1 << 1 )
    280 
    281 
    282 
    283 #define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \
    284           {                                                 \
    285             _ident, T1CODE, _type,                          \
    286             0,                                              \
    287             FT_FIELD_OFFSET( _fname ),                      \
    288             FT_FIELD_SIZE( _fname ),                        \
    289             0, 0,                                           \
    290             _dict                                           \
    291           },
    292 
    293 #define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \
    294           {                                             \
    295             _ident, T1CODE, T1_FIELD_TYPE_CALLBACK,     \
    296             (T1_Field_ParseFunc)_reader,                \
    297             0, 0,                                       \
    298             0, 0,                                       \
    299             _dict                                       \
    300           },
    301 
    302 #define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \
    303           {                                                      \
    304             _ident, T1CODE, _type,                               \
    305             0,                                                   \
    306             FT_FIELD_OFFSET( _fname ),                           \
    307             FT_FIELD_SIZE_DELTA( _fname ),                       \
    308             _max,                                                \
    309             FT_FIELD_OFFSET( num_ ## _fname ),                   \
    310             _dict                                                \
    311           },
    312 
    313 #define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \
    314           {                                                       \
    315             _ident, T1CODE, _type,                                \
    316             0,                                                    \
    317             FT_FIELD_OFFSET( _fname ),                            \
    318             FT_FIELD_SIZE_DELTA( _fname ),                        \
    319             _max, 0,                                              \
    320             _dict                                                 \
    321           },
    322 
    323 
    324 #define T1_FIELD_BOOL( _ident, _fname, _dict )                             \
    325           T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict )
    326 
    327 #define T1_FIELD_NUM( _ident, _fname, _dict )                                 \
    328           T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict )
    329 
    330 #define T1_FIELD_FIXED( _ident, _fname, _dict )                             \
    331           T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict )
    332 
    333 #define T1_FIELD_FIXED_1000( _ident, _fname, _dict )                     \
    334           T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \
    335                                _dict )
    336 
    337 #define T1_FIELD_STRING( _ident, _fname, _dict )                             \
    338           T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict )
    339 
    340 #define T1_FIELD_KEY( _ident, _fname, _dict )                             \
    341           T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict )
    342 
    343 #define T1_FIELD_BBOX( _ident, _fname, _dict )                             \
    344           T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict )
    345 
    346 
    347 #define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict )         \
    348           T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
    349                               _fname, _fmax, _dict )
    350 
    351 #define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict )     \
    352           T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
    353                               _fname, _fmax, _dict )
    354 
    355 #define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict )         \
    356           T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
    357                                _fname, _fmax, _dict )
    358 
    359 #define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict )     \
    360           T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
    361                                _fname, _fmax, _dict )
    362 
    363 #define T1_FIELD_CALLBACK( _ident, _name, _dict )       \
    364           T1_NEW_CALLBACK_FIELD( _ident, _name, _dict )
    365 
    366 
    367   /*************************************************************************/
    368   /*************************************************************************/
    369   /*****                                                               *****/
    370   /*****                            T1 PARSER                          *****/
    371   /*****                                                               *****/
    372   /*************************************************************************/
    373   /*************************************************************************/
    374 
    375   typedef const struct PS_Parser_FuncsRec_*  PS_Parser_Funcs;
    376 
    377   typedef struct  PS_Parser_FuncsRec_
    378   {
    379     void
    380     (*init)( PS_Parser  parser,
    381              FT_Byte*   base,
    382              FT_Byte*   limit,
    383              FT_Memory  memory );
    384 
    385     void
    386     (*done)( PS_Parser  parser );
    387 
    388     void
    389     (*skip_spaces)( PS_Parser  parser );
    390     void
    391     (*skip_PS_token)( PS_Parser  parser );
    392 
    393     FT_Long
    394     (*to_int)( PS_Parser  parser );
    395     FT_Fixed
    396     (*to_fixed)( PS_Parser  parser,
    397                  FT_Int     power_ten );
    398 
    399     FT_Error
    400     (*to_bytes)( PS_Parser  parser,
    401                  FT_Byte*   bytes,
    402                  FT_Offset  max_bytes,
    403                  FT_ULong*  pnum_bytes,
    404                  FT_Bool    delimiters );
    405 
    406     FT_Int
    407     (*to_coord_array)( PS_Parser  parser,
    408                        FT_Int     max_coords,
    409                        FT_Short*  coords );
    410     FT_Int
    411     (*to_fixed_array)( PS_Parser  parser,
    412                        FT_Int     max_values,
    413                        FT_Fixed*  values,
    414                        FT_Int     power_ten );
    415 
    416     void
    417     (*to_token)( PS_Parser  parser,
    418                  T1_Token   token );
    419     void
    420     (*to_token_array)( PS_Parser  parser,
    421                        T1_Token   tokens,
    422                        FT_UInt    max_tokens,
    423                        FT_Int*    pnum_tokens );
    424 
    425     FT_Error
    426     (*load_field)( PS_Parser       parser,
    427                    const T1_Field  field,
    428                    void**          objects,
    429                    FT_UInt         max_objects,
    430                    FT_ULong*       pflags );
    431 
    432     FT_Error
    433     (*load_field_table)( PS_Parser       parser,
    434                          const T1_Field  field,
    435                          void**          objects,
    436                          FT_UInt         max_objects,
    437                          FT_ULong*       pflags );
    438 
    439   } PS_Parser_FuncsRec;
    440 
    441 
    442   /**************************************************************************
    443    *
    444    * @struct:
    445    *   PS_ParserRec
    446    *
    447    * @description:
    448    *   A PS_Parser is an object used to parse a Type 1 font very quickly.
    449    *
    450    * @fields:
    451    *   cursor ::
    452    *     The current position in the text.
    453    *
    454    *   base ::
    455    *     Start of the processed text.
    456    *
    457    *   limit ::
    458    *     End of the processed text.
    459    *
    460    *   error ::
    461    *     The last error returned.
    462    *
    463    *   memory ::
    464    *     The object used for memory operations (alloc/realloc).
    465    *
    466    *   funcs ::
    467    *     A table of functions for the parser.
    468    */
    469   typedef struct  PS_ParserRec_
    470   {
    471     FT_Byte*   cursor;
    472     FT_Byte*   base;
    473     FT_Byte*   limit;
    474     FT_Error   error;
    475     FT_Memory  memory;
    476 
    477     PS_Parser_FuncsRec  funcs;
    478 
    479   } PS_ParserRec;
    480 
    481 
    482   /*************************************************************************/
    483   /*************************************************************************/
    484   /*****                                                               *****/
    485   /*****                         PS BUILDER                            *****/
    486   /*****                                                               *****/
    487   /*************************************************************************/
    488   /*************************************************************************/
    489 
    490 
    491   typedef struct PS_Builder_  PS_Builder;
    492   typedef const struct PS_Builder_FuncsRec_*  PS_Builder_Funcs;
    493 
    494   typedef struct  PS_Builder_FuncsRec_
    495   {
    496     void
    497     (*init)( PS_Builder*  ps_builder,
    498              void*        builder,
    499              FT_Bool      is_t1 );
    500 
    501     void
    502     (*done)( PS_Builder*  builder );
    503 
    504   } PS_Builder_FuncsRec;
    505 
    506 
    507   /**************************************************************************
    508    *
    509    * @struct:
    510    *   PS_Builder
    511    *
    512    * @description:
    513    *    A structure used during glyph loading to store its outline.
    514    *
    515    * @fields:
    516    *   memory ::
    517    *     The current memory object.
    518    *
    519    *   face ::
    520    *     The current face object.
    521    *
    522    *   glyph ::
    523    *     The current glyph slot.
    524    *
    525    *   loader ::
    526    *     XXX
    527    *
    528    *   base ::
    529    *     The base glyph outline.
    530    *
    531    *   current ::
    532    *     The current glyph outline.
    533    *
    534    *   pos_x ::
    535    *     The horizontal translation (if composite glyph).
    536    *
    537    *   pos_y ::
    538    *     The vertical translation (if composite glyph).
    539    *
    540    *   left_bearing ::
    541    *     The left side bearing point.
    542    *
    543    *   advance ::
    544    *     The horizontal advance vector.
    545    *
    546    *   bbox ::
    547    *     Unused.
    548    *
    549    *   path_begun ::
    550    *     A flag which indicates that a new path has begun.
    551    *
    552    *   load_points ::
    553    *     If this flag is not set, no points are loaded.
    554    *
    555    *   no_recurse ::
    556    *     Set but not used.
    557    *
    558    *   metrics_only ::
    559    *     A boolean indicating that we only want to compute
    560    *     the metrics of a given glyph, not load all of its
    561    *     points.
    562    *
    563    *   is_t1 ::
    564    *     Set if current font type is Type 1.
    565    *
    566    *   funcs ::
    567    *     An array of function pointers for the builder.
    568    */
    569   struct  PS_Builder_
    570   {
    571     FT_Memory       memory;
    572     FT_Face         face;
    573     CFF_GlyphSlot   glyph;
    574     FT_GlyphLoader  loader;
    575     FT_Outline*     base;
    576     FT_Outline*     current;
    577 
    578     FT_Pos*  pos_x;
    579     FT_Pos*  pos_y;
    580 
    581     FT_Vector*  left_bearing;
    582     FT_Vector*  advance;
    583 
    584     FT_BBox*  bbox;          /* bounding box */
    585     FT_Bool   path_begun;
    586     FT_Bool   load_points;
    587     FT_Bool   no_recurse;
    588 
    589     FT_Bool  metrics_only;
    590     FT_Bool  is_t1;
    591 
    592     PS_Builder_FuncsRec  funcs;
    593 
    594   };
    595 
    596 
    597   /*************************************************************************/
    598   /*************************************************************************/
    599   /*****                                                               *****/
    600   /*****                            PS DECODER                         *****/
    601   /*****                                                               *****/
    602   /*************************************************************************/
    603   /*************************************************************************/
    604 
    605 #define PS_MAX_OPERANDS        48
    606 #define PS_MAX_SUBRS_CALLS     16   /* maximum subroutine nesting;         */
    607                                     /* only 10 are allowed but there exist */
    608                                     /* fonts like `HiraKakuProN-W3.ttf'    */
    609                                     /* (Hiragino Kaku Gothic ProN W3;      */
    610                                     /* 8.2d6e1; 2014-12-19) that exceed    */
    611                                     /* this limit                          */
    612 
    613   /* execution context charstring zone */
    614 
    615   typedef struct  PS_Decoder_Zone_
    616   {
    617     FT_Byte*  base;
    618     FT_Byte*  limit;
    619     FT_Byte*  cursor;
    620 
    621   } PS_Decoder_Zone;
    622 
    623 
    624   typedef FT_Error
    625   (*CFF_Decoder_Get_Glyph_Callback)( TT_Face    face,
    626                                      FT_UInt    glyph_index,
    627                                      FT_Byte**  pointer,
    628                                      FT_ULong*  length );
    629 
    630   typedef void
    631   (*CFF_Decoder_Free_Glyph_Callback)( TT_Face    face,
    632                                       FT_Byte**  pointer,
    633                                       FT_ULong   length );
    634 
    635 
    636   typedef struct  PS_Decoder_
    637   {
    638     PS_Builder  builder;
    639 
    640     FT_Fixed   stack[PS_MAX_OPERANDS + 1];
    641     FT_Fixed*  top;
    642 
    643     PS_Decoder_Zone   zones[PS_MAX_SUBRS_CALLS + 1];
    644     PS_Decoder_Zone*  zone;
    645 
    646     FT_Int     flex_state;
    647     FT_Int     num_flex_vectors;
    648     FT_Vector  flex_vectors[7];
    649 
    650     CFF_Font     cff;
    651     CFF_SubFont  current_subfont; /* for current glyph_index */
    652     FT_Generic*  cf2_instance;
    653 
    654     FT_Pos*  glyph_width;
    655     FT_Bool  width_only;
    656     FT_Int   num_hints;
    657 
    658     FT_UInt  num_locals;
    659     FT_UInt  num_globals;
    660 
    661     FT_Int  locals_bias;
    662     FT_Int  globals_bias;
    663 
    664     FT_Byte**  locals;
    665     FT_Byte**  globals;
    666 
    667     FT_Byte**  glyph_names;   /* for pure CFF fonts only  */
    668     FT_UInt    num_glyphs;    /* number of glyphs in font */
    669 
    670     FT_Render_Mode  hint_mode;
    671 
    672     FT_Bool  seac;
    673 
    674     CFF_Decoder_Get_Glyph_Callback   get_glyph_callback;
    675     CFF_Decoder_Free_Glyph_Callback  free_glyph_callback;
    676 
    677     /* Type 1 stuff */
    678     FT_Service_PsCMaps  psnames;      /* for seac */
    679 
    680     FT_Int    lenIV;         /* internal for sub routine calls   */
    681     FT_UInt*  locals_len;    /* array of subrs length (optional) */
    682     FT_Hash   locals_hash;   /* used if `num_subrs' was massaged */
    683 
    684     FT_Matrix  font_matrix;
    685     FT_Vector  font_offset;
    686 
    687     PS_Blend  blend;         /* for multiple master support */
    688 
    689     FT_Long*  buildchar;
    690     FT_UInt   len_buildchar;
    691 
    692   } PS_Decoder;
    693 
    694 
    695   /*************************************************************************/
    696   /*************************************************************************/
    697   /*****                                                               *****/
    698   /*****                         T1 BUILDER                            *****/
    699   /*****                                                               *****/
    700   /*************************************************************************/
    701   /*************************************************************************/
    702 
    703 
    704   typedef struct T1_BuilderRec_*  T1_Builder;
    705 
    706 
    707   typedef FT_Error
    708   (*T1_Builder_Check_Points_Func)( T1_Builder  builder,
    709                                    FT_Int      count );
    710 
    711   typedef void
    712   (*T1_Builder_Add_Point_Func)( T1_Builder  builder,
    713                                 FT_Pos      x,
    714                                 FT_Pos      y,
    715                                 FT_Byte     flag );
    716 
    717   typedef FT_Error
    718   (*T1_Builder_Add_Point1_Func)( T1_Builder  builder,
    719                                  FT_Pos      x,
    720                                  FT_Pos      y );
    721 
    722   typedef FT_Error
    723   (*T1_Builder_Add_Contour_Func)( T1_Builder  builder );
    724 
    725   typedef FT_Error
    726   (*T1_Builder_Start_Point_Func)( T1_Builder  builder,
    727                                   FT_Pos      x,
    728                                   FT_Pos      y );
    729 
    730   typedef void
    731   (*T1_Builder_Close_Contour_Func)( T1_Builder  builder );
    732 
    733 
    734   typedef const struct T1_Builder_FuncsRec_*  T1_Builder_Funcs;
    735 
    736   typedef struct  T1_Builder_FuncsRec_
    737   {
    738     void
    739     (*init)( T1_Builder    builder,
    740              FT_Face       face,
    741              FT_Size       size,
    742              FT_GlyphSlot  slot,
    743              FT_Bool       hinting );
    744 
    745     void
    746     (*done)( T1_Builder   builder );
    747 
    748     T1_Builder_Check_Points_Func   check_points;
    749     T1_Builder_Add_Point_Func      add_point;
    750     T1_Builder_Add_Point1_Func     add_point1;
    751     T1_Builder_Add_Contour_Func    add_contour;
    752     T1_Builder_Start_Point_Func    start_point;
    753     T1_Builder_Close_Contour_Func  close_contour;
    754 
    755   } T1_Builder_FuncsRec;
    756 
    757 
    758   /* an enumeration type to handle charstring parsing states */
    759   typedef enum  T1_ParseState_
    760   {
    761     T1_Parse_Start,
    762     T1_Parse_Have_Width,
    763     T1_Parse_Have_Moveto,
    764     T1_Parse_Have_Path
    765 
    766   } T1_ParseState;
    767 
    768 
    769   /**************************************************************************
    770    *
    771    * @struct:
    772    *   T1_BuilderRec
    773    *
    774    * @description:
    775    *    A structure used during glyph loading to store its outline.
    776    *
    777    * @fields:
    778    *   memory ::
    779    *     The current memory object.
    780    *
    781    *   face ::
    782    *     The current face object.
    783    *
    784    *   glyph ::
    785    *     The current glyph slot.
    786    *
    787    *   loader ::
    788    *     XXX
    789    *
    790    *   base ::
    791    *     The base glyph outline.
    792    *
    793    *   current ::
    794    *     The current glyph outline.
    795    *
    796    *   max_points ::
    797    *     maximum points in builder outline
    798    *
    799    *   max_contours ::
    800    *     Maximum number of contours in builder outline.
    801    *
    802    *   pos_x ::
    803    *     The horizontal translation (if composite glyph).
    804    *
    805    *   pos_y ::
    806    *     The vertical translation (if composite glyph).
    807    *
    808    *   left_bearing ::
    809    *     The left side bearing point.
    810    *
    811    *   advance ::
    812    *     The horizontal advance vector.
    813    *
    814    *   bbox ::
    815    *     Unused.
    816    *
    817    *   parse_state ::
    818    *     An enumeration which controls the charstring
    819    *     parsing state.
    820    *
    821    *   load_points ::
    822    *     If this flag is not set, no points are loaded.
    823    *
    824    *   no_recurse ::
    825    *     Set but not used.
    826    *
    827    *   metrics_only ::
    828    *     A boolean indicating that we only want to compute
    829    *     the metrics of a given glyph, not load all of its
    830    *     points.
    831    *
    832    *   funcs ::
    833    *     An array of function pointers for the builder.
    834    */
    835   typedef struct  T1_BuilderRec_
    836   {
    837     FT_Memory       memory;
    838     FT_Face         face;
    839     FT_GlyphSlot    glyph;
    840     FT_GlyphLoader  loader;
    841     FT_Outline*     base;
    842     FT_Outline*     current;
    843 
    844     FT_Pos          pos_x;
    845     FT_Pos          pos_y;
    846 
    847     FT_Vector       left_bearing;
    848     FT_Vector       advance;
    849 
    850     FT_BBox         bbox;          /* bounding box */
    851     T1_ParseState   parse_state;
    852     FT_Bool         load_points;
    853     FT_Bool         no_recurse;
    854 
    855     FT_Bool         metrics_only;
    856 
    857     void*           hints_funcs;    /* hinter-specific */
    858     void*           hints_globals;  /* hinter-specific */
    859 
    860     T1_Builder_FuncsRec  funcs;
    861 
    862   } T1_BuilderRec;
    863 
    864 
    865   /*************************************************************************/
    866   /*************************************************************************/
    867   /*****                                                               *****/
    868   /*****                         T1 DECODER                            *****/
    869   /*****                                                               *****/
    870   /*************************************************************************/
    871   /*************************************************************************/
    872 
    873 #if 0
    874 
    875   /**************************************************************************
    876    *
    877    * T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine
    878    * calls during glyph loading.
    879    */
    880 #define T1_MAX_SUBRS_CALLS  8
    881 
    882 
    883   /**************************************************************************
    884    *
    885    * T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity.  A
    886    * minimum of 16 is required.
    887    */
    888 #define T1_MAX_CHARSTRINGS_OPERANDS  32
    889 
    890 #endif /* 0 */
    891 
    892 
    893   typedef struct  T1_Decoder_ZoneRec_
    894   {
    895     FT_Byte*  cursor;
    896     FT_Byte*  base;
    897     FT_Byte*  limit;
    898 
    899   } T1_Decoder_ZoneRec, *T1_Decoder_Zone;
    900 
    901 
    902   typedef struct T1_DecoderRec_*              T1_Decoder;
    903   typedef const struct T1_Decoder_FuncsRec_*  T1_Decoder_Funcs;
    904 
    905 
    906   typedef FT_Error
    907   (*T1_Decoder_Callback)( T1_Decoder  decoder,
    908                           FT_UInt     glyph_index );
    909 
    910 
    911   typedef struct  T1_Decoder_FuncsRec_
    912   {
    913     FT_Error
    914     (*init)( T1_Decoder           decoder,
    915              FT_Face              face,
    916              FT_Size              size,
    917              FT_GlyphSlot         slot,
    918              FT_Byte**            glyph_names,
    919              PS_Blend             blend,
    920              FT_Bool              hinting,
    921              FT_Render_Mode       hint_mode,
    922              T1_Decoder_Callback  callback );
    923 
    924     void
    925     (*done)( T1_Decoder  decoder );
    926 
    927 #ifdef T1_CONFIG_OPTION_OLD_ENGINE
    928     FT_Error
    929     (*parse_charstrings_old)( T1_Decoder  decoder,
    930                               FT_Byte*    base,
    931                               FT_UInt     len );
    932 #else
    933     FT_Error
    934     (*parse_metrics)( T1_Decoder  decoder,
    935                       FT_Byte*    base,
    936                       FT_UInt     len );
    937 #endif
    938 
    939     FT_Error
    940     (*parse_charstrings)( PS_Decoder*  decoder,
    941                           FT_Byte*     charstring_base,
    942                           FT_ULong     charstring_len );
    943 
    944 
    945   } T1_Decoder_FuncsRec;
    946 
    947 
    948   typedef struct  T1_DecoderRec_
    949   {
    950     T1_BuilderRec        builder;
    951 
    952     FT_Long              stack[T1_MAX_CHARSTRINGS_OPERANDS];
    953     FT_Long*             top;
    954 
    955     T1_Decoder_ZoneRec   zones[T1_MAX_SUBRS_CALLS + 1];
    956     T1_Decoder_Zone      zone;
    957 
    958     FT_Service_PsCMaps   psnames;      /* for seac */
    959     FT_UInt              num_glyphs;
    960     FT_Byte**            glyph_names;
    961 
    962     FT_Int               lenIV;        /* internal for sub routine calls */
    963     FT_Int               num_subrs;
    964     FT_Byte**            subrs;
    965     FT_UInt*             subrs_len;    /* array of subrs length (optional) */
    966     FT_Hash              subrs_hash;   /* used if `num_subrs' was massaged */
    967 
    968     FT_Matrix            font_matrix;
    969     FT_Vector            font_offset;
    970 
    971     FT_Int               flex_state;
    972     FT_Int               num_flex_vectors;
    973     FT_Vector            flex_vectors[7];
    974 
    975     PS_Blend             blend;       /* for multiple master support */
    976 
    977     FT_Render_Mode       hint_mode;
    978 
    979     T1_Decoder_Callback  parse_callback;
    980     T1_Decoder_FuncsRec  funcs;
    981 
    982     FT_Long*             buildchar;
    983     FT_UInt              len_buildchar;
    984 
    985     FT_Bool              seac;
    986 
    987     FT_Generic           cf2_instance;
    988 
    989   } T1_DecoderRec;
    990 
    991 
    992   /*************************************************************************/
    993   /*************************************************************************/
    994   /*****                                                               *****/
    995   /*****                        CFF BUILDER                            *****/
    996   /*****                                                               *****/
    997   /*************************************************************************/
    998   /*************************************************************************/
    999 
   1000 
   1001   typedef struct CFF_Builder_  CFF_Builder;
   1002 
   1003 
   1004   typedef FT_Error
   1005   (*CFF_Builder_Check_Points_Func)( CFF_Builder*  builder,
   1006                                     FT_Int        count );
   1007 
   1008   typedef void
   1009   (*CFF_Builder_Add_Point_Func)( CFF_Builder*  builder,
   1010                                  FT_Pos        x,
   1011                                  FT_Pos        y,
   1012                                  FT_Byte       flag );
   1013   typedef FT_Error
   1014   (*CFF_Builder_Add_Point1_Func)( CFF_Builder*  builder,
   1015                                   FT_Pos        x,
   1016                                   FT_Pos        y );
   1017   typedef FT_Error
   1018   (*CFF_Builder_Start_Point_Func)( CFF_Builder*  builder,
   1019                                    FT_Pos        x,
   1020                                    FT_Pos        y );
   1021   typedef void
   1022   (*CFF_Builder_Close_Contour_Func)( CFF_Builder*  builder );
   1023 
   1024   typedef FT_Error
   1025   (*CFF_Builder_Add_Contour_Func)( CFF_Builder*  builder );
   1026 
   1027   typedef const struct CFF_Builder_FuncsRec_*  CFF_Builder_Funcs;
   1028 
   1029   typedef struct  CFF_Builder_FuncsRec_
   1030   {
   1031     void
   1032     (*init)( CFF_Builder*   builder,
   1033              TT_Face        face,
   1034              CFF_Size       size,
   1035              CFF_GlyphSlot  glyph,
   1036              FT_Bool        hinting );
   1037 
   1038     void
   1039     (*done)( CFF_Builder*  builder );
   1040 
   1041     CFF_Builder_Check_Points_Func   check_points;
   1042     CFF_Builder_Add_Point_Func      add_point;
   1043     CFF_Builder_Add_Point1_Func     add_point1;
   1044     CFF_Builder_Add_Contour_Func    add_contour;
   1045     CFF_Builder_Start_Point_Func    start_point;
   1046     CFF_Builder_Close_Contour_Func  close_contour;
   1047 
   1048   } CFF_Builder_FuncsRec;
   1049 
   1050 
   1051   /**************************************************************************
   1052    *
   1053    * @struct:
   1054    *   CFF_Builder
   1055    *
   1056    * @description:
   1057    *    A structure used during glyph loading to store its outline.
   1058    *
   1059    * @fields:
   1060    *   memory ::
   1061    *     The current memory object.
   1062    *
   1063    *   face ::
   1064    *     The current face object.
   1065    *
   1066    *   glyph ::
   1067    *     The current glyph slot.
   1068    *
   1069    *   loader ::
   1070    *     The current glyph loader.
   1071    *
   1072    *   base ::
   1073    *     The base glyph outline.
   1074    *
   1075    *   current ::
   1076    *     The current glyph outline.
   1077    *
   1078    *   pos_x ::
   1079    *     The horizontal translation (if composite glyph).
   1080    *
   1081    *   pos_y ::
   1082    *     The vertical translation (if composite glyph).
   1083    *
   1084    *   left_bearing ::
   1085    *     The left side bearing point.
   1086    *
   1087    *   advance ::
   1088    *     The horizontal advance vector.
   1089    *
   1090    *   bbox ::
   1091    *     Unused.
   1092    *
   1093    *   path_begun ::
   1094    *     A flag which indicates that a new path has begun.
   1095    *
   1096    *   load_points ::
   1097    *     If this flag is not set, no points are loaded.
   1098    *
   1099    *   no_recurse ::
   1100    *     Set but not used.
   1101    *
   1102    *   metrics_only ::
   1103    *     A boolean indicating that we only want to compute
   1104    *     the metrics of a given glyph, not load all of its
   1105    *     points.
   1106    *
   1107    *   hints_funcs ::
   1108    *     Auxiliary pointer for hinting.
   1109    *
   1110    *   hints_globals ::
   1111    *     Auxiliary pointer for hinting.
   1112    *
   1113    *   funcs ::
   1114    *     A table of method pointers for this object.
   1115    */
   1116   struct  CFF_Builder_
   1117   {
   1118     FT_Memory       memory;
   1119     TT_Face         face;
   1120     CFF_GlyphSlot   glyph;
   1121     FT_GlyphLoader  loader;
   1122     FT_Outline*     base;
   1123     FT_Outline*     current;
   1124 
   1125     FT_Pos  pos_x;
   1126     FT_Pos  pos_y;
   1127 
   1128     FT_Vector  left_bearing;
   1129     FT_Vector  advance;
   1130 
   1131     FT_BBox  bbox;          /* bounding box */
   1132 
   1133     FT_Bool  path_begun;
   1134     FT_Bool  load_points;
   1135     FT_Bool  no_recurse;
   1136 
   1137     FT_Bool  metrics_only;
   1138 
   1139     void*  hints_funcs;     /* hinter-specific */
   1140     void*  hints_globals;   /* hinter-specific */
   1141 
   1142     CFF_Builder_FuncsRec  funcs;
   1143   };
   1144 
   1145 
   1146   /*************************************************************************/
   1147   /*************************************************************************/
   1148   /*****                                                               *****/
   1149   /*****                        CFF DECODER                            *****/
   1150   /*****                                                               *****/
   1151   /*************************************************************************/
   1152   /*************************************************************************/
   1153 
   1154 
   1155 #define CFF_MAX_OPERANDS        48
   1156 #define CFF_MAX_SUBRS_CALLS     16  /* maximum subroutine nesting;         */
   1157                                     /* only 10 are allowed but there exist */
   1158                                     /* fonts like `HiraKakuProN-W3.ttf'    */
   1159                                     /* (Hiragino Kaku Gothic ProN W3;      */
   1160                                     /* 8.2d6e1; 2014-12-19) that exceed    */
   1161                                     /* this limit                          */
   1162 #define CFF_MAX_TRANS_ELEMENTS  32
   1163 
   1164   /* execution context charstring zone */
   1165 
   1166   typedef struct  CFF_Decoder_Zone_
   1167   {
   1168     FT_Byte*  base;
   1169     FT_Byte*  limit;
   1170     FT_Byte*  cursor;
   1171 
   1172   } CFF_Decoder_Zone;
   1173 
   1174 
   1175   typedef struct  CFF_Decoder_
   1176   {
   1177     CFF_Builder  builder;
   1178     CFF_Font     cff;
   1179 
   1180     FT_Fixed   stack[CFF_MAX_OPERANDS + 1];
   1181     FT_Fixed*  top;
   1182 
   1183     CFF_Decoder_Zone   zones[CFF_MAX_SUBRS_CALLS + 1];
   1184     CFF_Decoder_Zone*  zone;
   1185 
   1186     FT_Int     flex_state;
   1187     FT_Int     num_flex_vectors;
   1188     FT_Vector  flex_vectors[7];
   1189 
   1190     FT_Pos  glyph_width;
   1191     FT_Pos  nominal_width;
   1192 
   1193     FT_Bool   read_width;
   1194     FT_Bool   width_only;
   1195     FT_Int    num_hints;
   1196     FT_Fixed  buildchar[CFF_MAX_TRANS_ELEMENTS];
   1197 
   1198     FT_UInt  num_locals;
   1199     FT_UInt  num_globals;
   1200 
   1201     FT_Int  locals_bias;
   1202     FT_Int  globals_bias;
   1203 
   1204     FT_Byte**  locals;
   1205     FT_Byte**  globals;
   1206 
   1207     FT_Byte**  glyph_names;   /* for pure CFF fonts only  */
   1208     FT_UInt    num_glyphs;    /* number of glyphs in font */
   1209 
   1210     FT_Render_Mode  hint_mode;
   1211 
   1212     FT_Bool  seac;
   1213 
   1214     CFF_SubFont  current_subfont; /* for current glyph_index */
   1215 
   1216     CFF_Decoder_Get_Glyph_Callback   get_glyph_callback;
   1217     CFF_Decoder_Free_Glyph_Callback  free_glyph_callback;
   1218 
   1219   } CFF_Decoder;
   1220 
   1221 
   1222   typedef const struct CFF_Decoder_FuncsRec_*  CFF_Decoder_Funcs;
   1223 
   1224   typedef struct  CFF_Decoder_FuncsRec_
   1225   {
   1226     void
   1227     (*init)( CFF_Decoder*                     decoder,
   1228              TT_Face                          face,
   1229              CFF_Size                         size,
   1230              CFF_GlyphSlot                    slot,
   1231              FT_Bool                          hinting,
   1232              FT_Render_Mode                   hint_mode,
   1233              CFF_Decoder_Get_Glyph_Callback   get_callback,
   1234              CFF_Decoder_Free_Glyph_Callback  free_callback );
   1235 
   1236     FT_Error
   1237     (*prepare)( CFF_Decoder*  decoder,
   1238                 CFF_Size      size,
   1239                 FT_UInt       glyph_index );
   1240 
   1241 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
   1242     FT_Error
   1243     (*parse_charstrings_old)( CFF_Decoder*  decoder,
   1244                               FT_Byte*      charstring_base,
   1245                               FT_ULong      charstring_len,
   1246                               FT_Bool       in_dict );
   1247 #endif
   1248 
   1249     FT_Error
   1250     (*parse_charstrings)( PS_Decoder*  decoder,
   1251                           FT_Byte*     charstring_base,
   1252                           FT_ULong     charstring_len );
   1253 
   1254   } CFF_Decoder_FuncsRec;
   1255 
   1256 
   1257   /*************************************************************************/
   1258   /*************************************************************************/
   1259   /*****                                                               *****/
   1260   /*****                            AFM PARSER                         *****/
   1261   /*****                                                               *****/
   1262   /*************************************************************************/
   1263   /*************************************************************************/
   1264 
   1265   typedef struct AFM_ParserRec_*  AFM_Parser;
   1266 
   1267   typedef struct  AFM_Parser_FuncsRec_
   1268   {
   1269     FT_Error
   1270     (*init)( AFM_Parser  parser,
   1271              FT_Memory   memory,
   1272              FT_Byte*    base,
   1273              FT_Byte*    limit );
   1274 
   1275     void
   1276     (*done)( AFM_Parser  parser );
   1277 
   1278     FT_Error
   1279     (*parse)( AFM_Parser  parser );
   1280 
   1281   } AFM_Parser_FuncsRec;
   1282 
   1283 
   1284   typedef struct AFM_StreamRec_*  AFM_Stream;
   1285 
   1286 
   1287   /**************************************************************************
   1288    *
   1289    * @struct:
   1290    *   AFM_ParserRec
   1291    *
   1292    * @description:
   1293    *   An AFM_Parser is a parser for the AFM files.
   1294    *
   1295    * @fields:
   1296    *   memory ::
   1297    *     The object used for memory operations (alloc and
   1298    *     realloc).
   1299    *
   1300    *   stream ::
   1301    *     This is an opaque object.
   1302    *
   1303    *   FontInfo ::
   1304    *     The result will be stored here.
   1305    *
   1306    *   get_index ::
   1307    *     A user provided function to get a glyph index by its
   1308    *     name.
   1309    */
   1310   typedef struct  AFM_ParserRec_
   1311   {
   1312     FT_Memory     memory;
   1313     AFM_Stream    stream;
   1314 
   1315     AFM_FontInfo  FontInfo;
   1316 
   1317     FT_Int
   1318     (*get_index)( const char*  name,
   1319                   FT_Offset    len,
   1320                   void*        user_data );
   1321 
   1322     void*         user_data;
   1323 
   1324   } AFM_ParserRec;
   1325 
   1326 
   1327   /*************************************************************************/
   1328   /*************************************************************************/
   1329   /*****                                                               *****/
   1330   /*****                     TYPE1 CHARMAPS                            *****/
   1331   /*****                                                               *****/
   1332   /*************************************************************************/
   1333   /*************************************************************************/
   1334 
   1335   typedef const struct T1_CMap_ClassesRec_*  T1_CMap_Classes;
   1336 
   1337   typedef struct T1_CMap_ClassesRec_
   1338   {
   1339     FT_CMap_Class  standard;
   1340     FT_CMap_Class  expert;
   1341     FT_CMap_Class  custom;
   1342     FT_CMap_Class  unicode;
   1343 
   1344   } T1_CMap_ClassesRec;
   1345 
   1346 
   1347   /*************************************************************************/
   1348   /*************************************************************************/
   1349   /*****                                                               *****/
   1350   /*****                        PSAux Module Interface                 *****/
   1351   /*****                                                               *****/
   1352   /*************************************************************************/
   1353   /*************************************************************************/
   1354 
   1355   typedef struct  PSAux_ServiceRec_
   1356   {
   1357     /* don't use `PS_Table_Funcs' and friends to avoid compiler warnings */
   1358     const PS_Table_FuncsRec*    ps_table_funcs;
   1359     const PS_Parser_FuncsRec*   ps_parser_funcs;
   1360     const T1_Builder_FuncsRec*  t1_builder_funcs;
   1361     const T1_Decoder_FuncsRec*  t1_decoder_funcs;
   1362 
   1363     void
   1364     (*t1_decrypt)( FT_Byte*   buffer,
   1365                    FT_Offset  length,
   1366                    FT_UShort  seed );
   1367 
   1368     FT_UInt32
   1369     (*cff_random)( FT_UInt32  r );
   1370 
   1371     void
   1372     (*ps_decoder_init)( PS_Decoder*  ps_decoder,
   1373                         void*        decoder,
   1374                         FT_Bool      is_t1 );
   1375 
   1376     void
   1377     (*t1_make_subfont)( FT_Face      face,
   1378                         PS_Private   priv,
   1379                         CFF_SubFont  subfont );
   1380 
   1381     T1_CMap_Classes  t1_cmap_classes;
   1382 
   1383     /* fields after this comment line were added after version 2.1.10 */
   1384     const AFM_Parser_FuncsRec*  afm_parser_funcs;
   1385 
   1386     const CFF_Decoder_FuncsRec*  cff_decoder_funcs;
   1387 
   1388   } PSAux_ServiceRec, *PSAux_Service;
   1389 
   1390   /* backward compatible type definition */
   1391   typedef PSAux_ServiceRec   PSAux_Interface;
   1392 
   1393 
   1394   /*************************************************************************/
   1395   /*************************************************************************/
   1396   /*****                                                               *****/
   1397   /*****                 Some convenience functions                    *****/
   1398   /*****                                                               *****/
   1399   /*************************************************************************/
   1400   /*************************************************************************/
   1401 
   1402 #define IS_PS_NEWLINE( ch ) \
   1403   ( (ch) == '\r' ||         \
   1404     (ch) == '\n' )
   1405 
   1406 #define IS_PS_SPACE( ch )  \
   1407   ( (ch) == ' '         || \
   1408     IS_PS_NEWLINE( ch ) || \
   1409     (ch) == '\t'        || \
   1410     (ch) == '\f'        || \
   1411     (ch) == '\0' )
   1412 
   1413 #define IS_PS_SPECIAL( ch )       \
   1414   ( (ch) == '/'                || \
   1415     (ch) == '(' || (ch) == ')' || \
   1416     (ch) == '<' || (ch) == '>' || \
   1417     (ch) == '[' || (ch) == ']' || \
   1418     (ch) == '{' || (ch) == '}' || \
   1419     (ch) == '%'                )
   1420 
   1421 #define IS_PS_DELIM( ch )  \
   1422   ( IS_PS_SPACE( ch )   || \
   1423     IS_PS_SPECIAL( ch ) )
   1424 
   1425 #define IS_PS_DIGIT( ch )        \
   1426   ( (ch) >= '0' && (ch) <= '9' )
   1427 
   1428 #define IS_PS_XDIGIT( ch )            \
   1429   ( IS_PS_DIGIT( ch )              || \
   1430     ( (ch) >= 'A' && (ch) <= 'F' ) || \
   1431     ( (ch) >= 'a' && (ch) <= 'f' ) )
   1432 
   1433 #define IS_PS_BASE85( ch )       \
   1434   ( (ch) >= '!' && (ch) <= 'u' )
   1435 
   1436 #define IS_PS_TOKEN( cur, limit, token )                                \
   1437   ( (char)(cur)[0] == (token)[0]                                     && \
   1438     ( (cur) + sizeof ( (token) ) == (limit) ||                          \
   1439       ( (cur) + sizeof( (token) ) < (limit)          &&                 \
   1440         IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) )             && \
   1441     ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 )
   1442 
   1443 
   1444 FT_END_HEADER
   1445 
   1446 #endif /* PSAUX_H_ */
   1447 
   1448 
   1449 /* END */
   1450