1/***************************************************************************/
2/*                                                                         */
3/*  psaux.h                                                                */
4/*                                                                         */
5/*    Auxiliary functions and data structures related to PostScript fonts  */
6/*    (specification).                                                     */
7/*                                                                         */
8/*  Copyright 1996-2017 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_SERVICE_POSTSCRIPT_CMAPS_H
29
30
31FT_BEGIN_HEADER
32
33
34  /*************************************************************************/
35  /*************************************************************************/
36  /*****                                                               *****/
37  /*****                             T1_TABLE                          *****/
38  /*****                                                               *****/
39  /*************************************************************************/
40  /*************************************************************************/
41
42
43  typedef struct PS_TableRec_*              PS_Table;
44  typedef const struct PS_Table_FuncsRec_*  PS_Table_Funcs;
45
46
47  /*************************************************************************/
48  /*                                                                       */
49  /* <Struct>                                                              */
50  /*    PS_Table_FuncsRec                                                  */
51  /*                                                                       */
52  /* <Description>                                                         */
53  /*    A set of function pointers to manage PS_Table objects.             */
54  /*                                                                       */
55  /* <Fields>                                                              */
56  /*    table_init    :: Used to initialize a table.                       */
57  /*                                                                       */
58  /*    table_done    :: Finalizes resp. destroy a given table.            */
59  /*                                                                       */
60  /*    table_add     :: Adds a new object to a table.                     */
61  /*                                                                       */
62  /*    table_release :: Releases table data, then finalizes it.           */
63  /*                                                                       */
64  typedef struct  PS_Table_FuncsRec_
65  {
66    FT_Error
67    (*init)( PS_Table   table,
68             FT_Int     count,
69             FT_Memory  memory );
70
71    void
72    (*done)( PS_Table  table );
73
74    FT_Error
75    (*add)( PS_Table  table,
76            FT_Int    idx,
77            void*     object,
78            FT_UInt   length );
79
80    void
81    (*release)( PS_Table  table );
82
83  } PS_Table_FuncsRec;
84
85
86  /*************************************************************************/
87  /*                                                                       */
88  /* <Struct>                                                              */
89  /*    PS_TableRec                                                        */
90  /*                                                                       */
91  /* <Description>                                                         */
92  /*    A PS_Table is a simple object used to store an array of objects in */
93  /*    a single memory block.                                             */
94  /*                                                                       */
95  /* <Fields>                                                              */
96  /*    block     :: The address in memory of the growheap's block.  This  */
97  /*                 can change between two object adds, due to            */
98  /*                 reallocation.                                         */
99  /*                                                                       */
100  /*    cursor    :: The current top of the grow heap within its block.    */
101  /*                                                                       */
102  /*    capacity  :: The current size of the heap block.  Increments by    */
103  /*                 1kByte chunks.                                        */
104  /*                                                                       */
105  /*    init      :: Set to 0xDEADBEEF if `elements' and `lengths' have    */
106  /*                 been allocated.                                       */
107  /*                                                                       */
108  /*    max_elems :: The maximum number of elements in table.              */
109  /*                                                                       */
110  /*    num_elems :: The current number of elements in table.              */
111  /*                                                                       */
112  /*    elements  :: A table of element addresses within the block.        */
113  /*                                                                       */
114  /*    lengths   :: A table of element sizes within the block.            */
115  /*                                                                       */
116  /*    memory    :: The object used for memory operations                 */
117  /*                 (alloc/realloc).                                      */
118  /*                                                                       */
119  /*    funcs     :: A table of method pointers for this object.           */
120  /*                                                                       */
121  typedef struct  PS_TableRec_
122  {
123    FT_Byte*           block;          /* current memory block           */
124    FT_Offset          cursor;         /* current cursor in memory block */
125    FT_Offset          capacity;       /* current size of memory block   */
126    FT_ULong           init;
127
128    FT_Int             max_elems;
129    FT_Int             num_elems;
130    FT_Byte**          elements;       /* addresses of table elements */
131    FT_UInt*           lengths;        /* lengths of table elements   */
132
133    FT_Memory          memory;
134    PS_Table_FuncsRec  funcs;
135
136  } PS_TableRec;
137
138
139  /*************************************************************************/
140  /*************************************************************************/
141  /*****                                                               *****/
142  /*****                       T1 FIELDS & TOKENS                      *****/
143  /*****                                                               *****/
144  /*************************************************************************/
145  /*************************************************************************/
146
147  typedef struct PS_ParserRec_*  PS_Parser;
148
149  typedef struct T1_TokenRec_*   T1_Token;
150
151  typedef struct T1_FieldRec_*   T1_Field;
152
153
154  /* simple enumeration type used to identify token types */
155  typedef enum  T1_TokenType_
156  {
157    T1_TOKEN_TYPE_NONE = 0,
158    T1_TOKEN_TYPE_ANY,
159    T1_TOKEN_TYPE_STRING,
160    T1_TOKEN_TYPE_ARRAY,
161    T1_TOKEN_TYPE_KEY, /* aka `name' */
162
163    /* do not remove */
164    T1_TOKEN_TYPE_MAX
165
166  } T1_TokenType;
167
168
169  /* a simple structure used to identify tokens */
170  typedef struct  T1_TokenRec_
171  {
172    FT_Byte*      start;   /* first character of token in input stream */
173    FT_Byte*      limit;   /* first character after the token          */
174    T1_TokenType  type;    /* type of token                            */
175
176  } T1_TokenRec;
177
178
179  /* enumeration type used to identify object fields */
180  typedef enum  T1_FieldType_
181  {
182    T1_FIELD_TYPE_NONE = 0,
183    T1_FIELD_TYPE_BOOL,
184    T1_FIELD_TYPE_INTEGER,
185    T1_FIELD_TYPE_FIXED,
186    T1_FIELD_TYPE_FIXED_1000,
187    T1_FIELD_TYPE_STRING,
188    T1_FIELD_TYPE_KEY,
189    T1_FIELD_TYPE_BBOX,
190    T1_FIELD_TYPE_MM_BBOX,
191    T1_FIELD_TYPE_INTEGER_ARRAY,
192    T1_FIELD_TYPE_FIXED_ARRAY,
193    T1_FIELD_TYPE_CALLBACK,
194
195    /* do not remove */
196    T1_FIELD_TYPE_MAX
197
198  } T1_FieldType;
199
200
201  typedef enum  T1_FieldLocation_
202  {
203    T1_FIELD_LOCATION_CID_INFO,
204    T1_FIELD_LOCATION_FONT_DICT,
205    T1_FIELD_LOCATION_FONT_EXTRA,
206    T1_FIELD_LOCATION_FONT_INFO,
207    T1_FIELD_LOCATION_PRIVATE,
208    T1_FIELD_LOCATION_BBOX,
209    T1_FIELD_LOCATION_LOADER,
210    T1_FIELD_LOCATION_FACE,
211    T1_FIELD_LOCATION_BLEND,
212
213    /* do not remove */
214    T1_FIELD_LOCATION_MAX
215
216  } T1_FieldLocation;
217
218
219  typedef void
220  (*T1_Field_ParseFunc)( FT_Face     face,
221                         FT_Pointer  parser );
222
223
224  /* structure type used to model object fields */
225  typedef struct  T1_FieldRec_
226  {
227    const char*         ident;        /* field identifier               */
228    T1_FieldLocation    location;
229    T1_FieldType        type;         /* type of field                  */
230    T1_Field_ParseFunc  reader;
231    FT_UInt             offset;       /* offset of field in object      */
232    FT_Byte             size;         /* size of field in bytes         */
233    FT_UInt             array_max;    /* maximum number of elements for */
234                                      /* array                          */
235    FT_UInt             count_offset; /* offset of element count for    */
236                                      /* arrays; must not be zero if in */
237                                      /* use -- in other words, a       */
238                                      /* `num_FOO' element must not     */
239                                      /* start the used structure if we */
240                                      /* parse a `FOO' array            */
241    FT_UInt             dict;         /* where we expect it             */
242  } T1_FieldRec;
243
244#define T1_FIELD_DICT_FONTDICT ( 1 << 0 ) /* also FontInfo and FDArray */
245#define T1_FIELD_DICT_PRIVATE  ( 1 << 1 )
246
247
248
249#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \
250          {                                                 \
251            _ident, T1CODE, _type,                          \
252            0,                                              \
253            FT_FIELD_OFFSET( _fname ),                      \
254            FT_FIELD_SIZE( _fname ),                        \
255            0, 0,                                           \
256            _dict                                           \
257          },
258
259#define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \
260          {                                             \
261            _ident, T1CODE, T1_FIELD_TYPE_CALLBACK,     \
262            (T1_Field_ParseFunc)_reader,                \
263            0, 0,                                       \
264            0, 0,                                       \
265            _dict                                       \
266          },
267
268#define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \
269          {                                                      \
270            _ident, T1CODE, _type,                               \
271            0,                                                   \
272            FT_FIELD_OFFSET( _fname ),                           \
273            FT_FIELD_SIZE_DELTA( _fname ),                       \
274            _max,                                                \
275            FT_FIELD_OFFSET( num_ ## _fname ),                   \
276            _dict                                                \
277          },
278
279#define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \
280          {                                                       \
281            _ident, T1CODE, _type,                                \
282            0,                                                    \
283            FT_FIELD_OFFSET( _fname ),                            \
284            FT_FIELD_SIZE_DELTA( _fname ),                        \
285            _max, 0,                                              \
286            _dict                                                 \
287          },
288
289
290#define T1_FIELD_BOOL( _ident, _fname, _dict )                             \
291          T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict )
292
293#define T1_FIELD_NUM( _ident, _fname, _dict )                                 \
294          T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict )
295
296#define T1_FIELD_FIXED( _ident, _fname, _dict )                             \
297          T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict )
298
299#define T1_FIELD_FIXED_1000( _ident, _fname, _dict )                     \
300          T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \
301                               _dict )
302
303#define T1_FIELD_STRING( _ident, _fname, _dict )                             \
304          T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict )
305
306#define T1_FIELD_KEY( _ident, _fname, _dict )                             \
307          T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict )
308
309#define T1_FIELD_BBOX( _ident, _fname, _dict )                             \
310          T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict )
311
312
313#define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict )         \
314          T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
315                              _fname, _fmax, _dict )
316
317#define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict )     \
318          T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
319                              _fname, _fmax, _dict )
320
321#define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict )         \
322          T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
323                               _fname, _fmax, _dict )
324
325#define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict )     \
326          T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
327                               _fname, _fmax, _dict )
328
329#define T1_FIELD_CALLBACK( _ident, _name, _dict )       \
330          T1_NEW_CALLBACK_FIELD( _ident, _name, _dict )
331
332
333  /*************************************************************************/
334  /*************************************************************************/
335  /*****                                                               *****/
336  /*****                            T1 PARSER                          *****/
337  /*****                                                               *****/
338  /*************************************************************************/
339  /*************************************************************************/
340
341  typedef const struct PS_Parser_FuncsRec_*  PS_Parser_Funcs;
342
343  typedef struct  PS_Parser_FuncsRec_
344  {
345    void
346    (*init)( PS_Parser  parser,
347             FT_Byte*   base,
348             FT_Byte*   limit,
349             FT_Memory  memory );
350
351    void
352    (*done)( PS_Parser  parser );
353
354    void
355    (*skip_spaces)( PS_Parser  parser );
356    void
357    (*skip_PS_token)( PS_Parser  parser );
358
359    FT_Long
360    (*to_int)( PS_Parser  parser );
361    FT_Fixed
362    (*to_fixed)( PS_Parser  parser,
363                 FT_Int     power_ten );
364
365    FT_Error
366    (*to_bytes)( PS_Parser  parser,
367                 FT_Byte*   bytes,
368                 FT_Offset  max_bytes,
369                 FT_ULong*  pnum_bytes,
370                 FT_Bool    delimiters );
371
372    FT_Int
373    (*to_coord_array)( PS_Parser  parser,
374                       FT_Int     max_coords,
375                       FT_Short*  coords );
376    FT_Int
377    (*to_fixed_array)( PS_Parser  parser,
378                       FT_Int     max_values,
379                       FT_Fixed*  values,
380                       FT_Int     power_ten );
381
382    void
383    (*to_token)( PS_Parser  parser,
384                 T1_Token   token );
385    void
386    (*to_token_array)( PS_Parser  parser,
387                       T1_Token   tokens,
388                       FT_UInt    max_tokens,
389                       FT_Int*    pnum_tokens );
390
391    FT_Error
392    (*load_field)( PS_Parser       parser,
393                   const T1_Field  field,
394                   void**          objects,
395                   FT_UInt         max_objects,
396                   FT_ULong*       pflags );
397
398    FT_Error
399    (*load_field_table)( PS_Parser       parser,
400                         const T1_Field  field,
401                         void**          objects,
402                         FT_UInt         max_objects,
403                         FT_ULong*       pflags );
404
405  } PS_Parser_FuncsRec;
406
407
408  /*************************************************************************/
409  /*                                                                       */
410  /* <Struct>                                                              */
411  /*    PS_ParserRec                                                       */
412  /*                                                                       */
413  /* <Description>                                                         */
414  /*    A PS_Parser is an object used to parse a Type 1 font very quickly. */
415  /*                                                                       */
416  /* <Fields>                                                              */
417  /*    cursor :: The current position in the text.                        */
418  /*                                                                       */
419  /*    base   :: Start of the processed text.                             */
420  /*                                                                       */
421  /*    limit  :: End of the processed text.                               */
422  /*                                                                       */
423  /*    error  :: The last error returned.                                 */
424  /*                                                                       */
425  /*    memory :: The object used for memory operations (alloc/realloc).   */
426  /*                                                                       */
427  /*    funcs  :: A table of functions for the parser.                     */
428  /*                                                                       */
429  typedef struct  PS_ParserRec_
430  {
431    FT_Byte*   cursor;
432    FT_Byte*   base;
433    FT_Byte*   limit;
434    FT_Error   error;
435    FT_Memory  memory;
436
437    PS_Parser_FuncsRec  funcs;
438
439  } PS_ParserRec;
440
441
442  /*************************************************************************/
443  /*************************************************************************/
444  /*****                                                               *****/
445  /*****                         T1 BUILDER                            *****/
446  /*****                                                               *****/
447  /*************************************************************************/
448  /*************************************************************************/
449
450
451  typedef struct T1_BuilderRec_*  T1_Builder;
452
453
454  typedef FT_Error
455  (*T1_Builder_Check_Points_Func)( T1_Builder  builder,
456                                   FT_Int      count );
457
458  typedef void
459  (*T1_Builder_Add_Point_Func)( T1_Builder  builder,
460                                FT_Pos      x,
461                                FT_Pos      y,
462                                FT_Byte     flag );
463
464  typedef FT_Error
465  (*T1_Builder_Add_Point1_Func)( T1_Builder  builder,
466                                 FT_Pos      x,
467                                 FT_Pos      y );
468
469  typedef FT_Error
470  (*T1_Builder_Add_Contour_Func)( T1_Builder  builder );
471
472  typedef FT_Error
473  (*T1_Builder_Start_Point_Func)( T1_Builder  builder,
474                                  FT_Pos      x,
475                                  FT_Pos      y );
476
477  typedef void
478  (*T1_Builder_Close_Contour_Func)( T1_Builder  builder );
479
480
481  typedef const struct T1_Builder_FuncsRec_*  T1_Builder_Funcs;
482
483  typedef struct  T1_Builder_FuncsRec_
484  {
485    void
486    (*init)( T1_Builder    builder,
487             FT_Face       face,
488             FT_Size       size,
489             FT_GlyphSlot  slot,
490             FT_Bool       hinting );
491
492    void
493    (*done)( T1_Builder   builder );
494
495    T1_Builder_Check_Points_Func   check_points;
496    T1_Builder_Add_Point_Func      add_point;
497    T1_Builder_Add_Point1_Func     add_point1;
498    T1_Builder_Add_Contour_Func    add_contour;
499    T1_Builder_Start_Point_Func    start_point;
500    T1_Builder_Close_Contour_Func  close_contour;
501
502  } T1_Builder_FuncsRec;
503
504
505  /* an enumeration type to handle charstring parsing states */
506  typedef enum  T1_ParseState_
507  {
508    T1_Parse_Start,
509    T1_Parse_Have_Width,
510    T1_Parse_Have_Moveto,
511    T1_Parse_Have_Path
512
513  } T1_ParseState;
514
515
516  /*************************************************************************/
517  /*                                                                       */
518  /* <Structure>                                                           */
519  /*    T1_BuilderRec                                                      */
520  /*                                                                       */
521  /* <Description>                                                         */
522  /*     A structure used during glyph loading to store its outline.       */
523  /*                                                                       */
524  /* <Fields>                                                              */
525  /*    memory       :: The current memory object.                         */
526  /*                                                                       */
527  /*    face         :: The current face object.                           */
528  /*                                                                       */
529  /*    glyph        :: The current glyph slot.                            */
530  /*                                                                       */
531  /*    loader       :: XXX                                                */
532  /*                                                                       */
533  /*    base         :: The base glyph outline.                            */
534  /*                                                                       */
535  /*    current      :: The current glyph outline.                         */
536  /*                                                                       */
537  /*    max_points   :: maximum points in builder outline                  */
538  /*                                                                       */
539  /*    max_contours :: Maximum number of contours in builder outline.     */
540  /*                                                                       */
541  /*    pos_x        :: The horizontal translation (if composite glyph).   */
542  /*                                                                       */
543  /*    pos_y        :: The vertical translation (if composite glyph).     */
544  /*                                                                       */
545  /*    left_bearing :: The left side bearing point.                       */
546  /*                                                                       */
547  /*    advance      :: The horizontal advance vector.                     */
548  /*                                                                       */
549  /*    bbox         :: Unused.                                            */
550  /*                                                                       */
551  /*    parse_state  :: An enumeration which controls the charstring       */
552  /*                    parsing state.                                     */
553  /*                                                                       */
554  /*    load_points  :: If this flag is not set, no points are loaded.     */
555  /*                                                                       */
556  /*    no_recurse   :: Set but not used.                                  */
557  /*                                                                       */
558  /*    metrics_only :: A boolean indicating that we only want to compute  */
559  /*                    the metrics of a given glyph, not load all of its  */
560  /*                    points.                                            */
561  /*                                                                       */
562  /*    funcs        :: An array of function pointers for the builder.     */
563  /*                                                                       */
564  typedef struct  T1_BuilderRec_
565  {
566    FT_Memory       memory;
567    FT_Face         face;
568    FT_GlyphSlot    glyph;
569    FT_GlyphLoader  loader;
570    FT_Outline*     base;
571    FT_Outline*     current;
572
573    FT_Pos          pos_x;
574    FT_Pos          pos_y;
575
576    FT_Vector       left_bearing;
577    FT_Vector       advance;
578
579    FT_BBox         bbox;          /* bounding box */
580    T1_ParseState   parse_state;
581    FT_Bool         load_points;
582    FT_Bool         no_recurse;
583
584    FT_Bool         metrics_only;
585
586    void*           hints_funcs;    /* hinter-specific */
587    void*           hints_globals;  /* hinter-specific */
588
589    T1_Builder_FuncsRec  funcs;
590
591  } T1_BuilderRec;
592
593
594  /*************************************************************************/
595  /*************************************************************************/
596  /*****                                                               *****/
597  /*****                         T1 DECODER                            *****/
598  /*****                                                               *****/
599  /*************************************************************************/
600  /*************************************************************************/
601
602#if 0
603
604  /*************************************************************************/
605  /*                                                                       */
606  /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine   */
607  /* calls during glyph loading.                                           */
608  /*                                                                       */
609#define T1_MAX_SUBRS_CALLS  8
610
611
612  /*************************************************************************/
613  /*                                                                       */
614  /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity.  A     */
615  /* minimum of 16 is required.                                            */
616  /*                                                                       */
617#define T1_MAX_CHARSTRINGS_OPERANDS  32
618
619#endif /* 0 */
620
621
622  typedef struct  T1_Decoder_ZoneRec_
623  {
624    FT_Byte*  cursor;
625    FT_Byte*  base;
626    FT_Byte*  limit;
627
628  } T1_Decoder_ZoneRec, *T1_Decoder_Zone;
629
630
631  typedef struct T1_DecoderRec_*              T1_Decoder;
632  typedef const struct T1_Decoder_FuncsRec_*  T1_Decoder_Funcs;
633
634
635  typedef FT_Error
636  (*T1_Decoder_Callback)( T1_Decoder  decoder,
637                          FT_UInt     glyph_index );
638
639
640  typedef struct  T1_Decoder_FuncsRec_
641  {
642    FT_Error
643    (*init)( T1_Decoder           decoder,
644             FT_Face              face,
645             FT_Size              size,
646             FT_GlyphSlot         slot,
647             FT_Byte**            glyph_names,
648             PS_Blend             blend,
649             FT_Bool              hinting,
650             FT_Render_Mode       hint_mode,
651             T1_Decoder_Callback  callback );
652
653    void
654    (*done)( T1_Decoder  decoder );
655
656    FT_Error
657    (*parse_charstrings)( T1_Decoder  decoder,
658                          FT_Byte*    base,
659                          FT_UInt     len );
660
661  } T1_Decoder_FuncsRec;
662
663
664  typedef struct  T1_DecoderRec_
665  {
666    T1_BuilderRec        builder;
667
668    FT_Long              stack[T1_MAX_CHARSTRINGS_OPERANDS];
669    FT_Long*             top;
670
671    T1_Decoder_ZoneRec   zones[T1_MAX_SUBRS_CALLS + 1];
672    T1_Decoder_Zone      zone;
673
674    FT_Service_PsCMaps   psnames;      /* for seac */
675    FT_UInt              num_glyphs;
676    FT_Byte**            glyph_names;
677
678    FT_Int               lenIV;        /* internal for sub routine calls */
679    FT_Int               num_subrs;
680    FT_Byte**            subrs;
681    FT_UInt*             subrs_len;    /* array of subrs length (optional) */
682    FT_Hash              subrs_hash;   /* used if `num_subrs' was massaged */
683
684    FT_Matrix            font_matrix;
685    FT_Vector            font_offset;
686
687    FT_Int               flex_state;
688    FT_Int               num_flex_vectors;
689    FT_Vector            flex_vectors[7];
690
691    PS_Blend             blend;       /* for multiple master support */
692
693    FT_Render_Mode       hint_mode;
694
695    T1_Decoder_Callback  parse_callback;
696    T1_Decoder_FuncsRec  funcs;
697
698    FT_Long*             buildchar;
699    FT_UInt              len_buildchar;
700
701    FT_Bool              seac;
702
703  } T1_DecoderRec;
704
705
706  /*************************************************************************/
707  /*************************************************************************/
708  /*****                                                               *****/
709  /*****                            AFM PARSER                         *****/
710  /*****                                                               *****/
711  /*************************************************************************/
712  /*************************************************************************/
713
714  typedef struct AFM_ParserRec_*  AFM_Parser;
715
716  typedef struct  AFM_Parser_FuncsRec_
717  {
718    FT_Error
719    (*init)( AFM_Parser  parser,
720             FT_Memory   memory,
721             FT_Byte*    base,
722             FT_Byte*    limit );
723
724    void
725    (*done)( AFM_Parser  parser );
726
727    FT_Error
728    (*parse)( AFM_Parser  parser );
729
730  } AFM_Parser_FuncsRec;
731
732
733  typedef struct AFM_StreamRec_*  AFM_Stream;
734
735
736  /*************************************************************************/
737  /*                                                                       */
738  /* <Struct>                                                              */
739  /*    AFM_ParserRec                                                      */
740  /*                                                                       */
741  /* <Description>                                                         */
742  /*    An AFM_Parser is a parser for the AFM files.                       */
743  /*                                                                       */
744  /* <Fields>                                                              */
745  /*    memory    :: The object used for memory operations (alloc and      */
746  /*                 realloc).                                             */
747  /*                                                                       */
748  /*    stream    :: This is an opaque object.                             */
749  /*                                                                       */
750  /*    FontInfo  :: The result will be stored here.                       */
751  /*                                                                       */
752  /*    get_index :: A user provided function to get a glyph index by its  */
753  /*                 name.                                                 */
754  /*                                                                       */
755  typedef struct  AFM_ParserRec_
756  {
757    FT_Memory     memory;
758    AFM_Stream    stream;
759
760    AFM_FontInfo  FontInfo;
761
762    FT_Int
763    (*get_index)( const char*  name,
764                  FT_Offset    len,
765                  void*        user_data );
766
767    void*         user_data;
768
769  } AFM_ParserRec;
770
771
772  /*************************************************************************/
773  /*************************************************************************/
774  /*****                                                               *****/
775  /*****                     TYPE1 CHARMAPS                            *****/
776  /*****                                                               *****/
777  /*************************************************************************/
778  /*************************************************************************/
779
780  typedef const struct T1_CMap_ClassesRec_*  T1_CMap_Classes;
781
782  typedef struct T1_CMap_ClassesRec_
783  {
784    FT_CMap_Class  standard;
785    FT_CMap_Class  expert;
786    FT_CMap_Class  custom;
787    FT_CMap_Class  unicode;
788
789  } T1_CMap_ClassesRec;
790
791
792  /*************************************************************************/
793  /*************************************************************************/
794  /*****                                                               *****/
795  /*****                        PSAux Module Interface                 *****/
796  /*****                                                               *****/
797  /*************************************************************************/
798  /*************************************************************************/
799
800  typedef struct  PSAux_ServiceRec_
801  {
802    /* don't use `PS_Table_Funcs' and friends to avoid compiler warnings */
803    const PS_Table_FuncsRec*    ps_table_funcs;
804    const PS_Parser_FuncsRec*   ps_parser_funcs;
805    const T1_Builder_FuncsRec*  t1_builder_funcs;
806    const T1_Decoder_FuncsRec*  t1_decoder_funcs;
807
808    void
809    (*t1_decrypt)( FT_Byte*   buffer,
810                   FT_Offset  length,
811                   FT_UShort  seed );
812
813    T1_CMap_Classes  t1_cmap_classes;
814
815    /* fields after this comment line were added after version 2.1.10 */
816    const AFM_Parser_FuncsRec*  afm_parser_funcs;
817
818  } PSAux_ServiceRec, *PSAux_Service;
819
820  /* backwards-compatible type definition */
821  typedef PSAux_ServiceRec   PSAux_Interface;
822
823
824  /*************************************************************************/
825  /*************************************************************************/
826  /*****                                                               *****/
827  /*****                 Some convenience functions                    *****/
828  /*****                                                               *****/
829  /*************************************************************************/
830  /*************************************************************************/
831
832#define IS_PS_NEWLINE( ch ) \
833  ( (ch) == '\r' ||         \
834    (ch) == '\n' )
835
836#define IS_PS_SPACE( ch )  \
837  ( (ch) == ' '         || \
838    IS_PS_NEWLINE( ch ) || \
839    (ch) == '\t'        || \
840    (ch) == '\f'        || \
841    (ch) == '\0' )
842
843#define IS_PS_SPECIAL( ch )       \
844  ( (ch) == '/'                || \
845    (ch) == '(' || (ch) == ')' || \
846    (ch) == '<' || (ch) == '>' || \
847    (ch) == '[' || (ch) == ']' || \
848    (ch) == '{' || (ch) == '}' || \
849    (ch) == '%'                )
850
851#define IS_PS_DELIM( ch )  \
852  ( IS_PS_SPACE( ch )   || \
853    IS_PS_SPECIAL( ch ) )
854
855#define IS_PS_DIGIT( ch )        \
856  ( (ch) >= '0' && (ch) <= '9' )
857
858#define IS_PS_XDIGIT( ch )            \
859  ( IS_PS_DIGIT( ch )              || \
860    ( (ch) >= 'A' && (ch) <= 'F' ) || \
861    ( (ch) >= 'a' && (ch) <= 'f' ) )
862
863#define IS_PS_BASE85( ch )       \
864  ( (ch) >= '!' && (ch) <= 'u' )
865
866#define IS_PS_TOKEN( cur, limit, token )                                \
867  ( (char)(cur)[0] == (token)[0]                                     && \
868    ( (cur) + sizeof ( (token) ) == (limit) ||                          \
869      ( (cur) + sizeof( (token) ) < (limit)          &&                 \
870        IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) )             && \
871    ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 )
872
873
874FT_END_HEADER
875
876#endif /* PSAUX_H_ */
877
878
879/* END */
880