1 /***************************************************************************/
5 /* Auxiliary functions and data structures related to PostScript fonts */
8 /* Copyright 1996-2018 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
17 /***************************************************************************/
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
38 /***********************************************************************/
40 /* PostScript modules driver class. */
42 typedef struct PS_DriverRec_
46 FT_UInt hinting_engine
;
47 FT_Bool no_stem_darkening
;
48 FT_Int darken_params
[8];
51 } PS_DriverRec
, *PS_Driver
;
54 /*************************************************************************/
55 /*************************************************************************/
57 /***** T1_TABLE *****/
59 /*************************************************************************/
60 /*************************************************************************/
63 typedef struct PS_TableRec_
* PS_Table
;
64 typedef const struct PS_Table_FuncsRec_
* PS_Table_Funcs
;
67 /*************************************************************************/
70 /* PS_Table_FuncsRec */
73 /* A set of function pointers to manage PS_Table objects. */
76 /* table_init :: Used to initialize a table. */
78 /* table_done :: Finalizes resp. destroy a given table. */
80 /* table_add :: Adds a new object to a table. */
82 /* table_release :: Releases table data, then finalizes it. */
84 typedef struct PS_Table_FuncsRec_
87 (*init
)( PS_Table table
,
92 (*done
)( PS_Table table
);
95 (*add
)( PS_Table table
,
101 (*release
)( PS_Table table
);
106 /*************************************************************************/
112 /* A PS_Table is a simple object used to store an array of objects in */
113 /* a single memory block. */
116 /* block :: The address in memory of the growheap's block. This */
117 /* can change between two object adds, due to */
120 /* cursor :: The current top of the grow heap within its block. */
122 /* capacity :: The current size of the heap block. Increments by */
125 /* init :: Set to 0xDEADBEEF if `elements' and `lengths' have */
126 /* been allocated. */
128 /* max_elems :: The maximum number of elements in table. */
130 /* num_elems :: The current number of elements in table. */
132 /* elements :: A table of element addresses within the block. */
134 /* lengths :: A table of element sizes within the block. */
136 /* memory :: The object used for memory operations */
137 /* (alloc/realloc). */
139 /* funcs :: A table of method pointers for this object. */
141 typedef struct PS_TableRec_
143 FT_Byte
* block
; /* current memory block */
144 FT_Offset cursor
; /* current cursor in memory block */
145 FT_Offset capacity
; /* current size of memory block */
150 FT_Byte
** elements
; /* addresses of table elements */
151 FT_UInt
* lengths
; /* lengths of table elements */
154 PS_Table_FuncsRec funcs
;
159 /*************************************************************************/
160 /*************************************************************************/
162 /***** T1 FIELDS & TOKENS *****/
164 /*************************************************************************/
165 /*************************************************************************/
167 typedef struct PS_ParserRec_
* PS_Parser
;
169 typedef struct T1_TokenRec_
* T1_Token
;
171 typedef struct T1_FieldRec_
* T1_Field
;
174 /* simple enumeration type used to identify token types */
175 typedef enum T1_TokenType_
177 T1_TOKEN_TYPE_NONE
= 0,
179 T1_TOKEN_TYPE_STRING
,
181 T1_TOKEN_TYPE_KEY
, /* aka `name' */
189 /* a simple structure used to identify tokens */
190 typedef struct T1_TokenRec_
192 FT_Byte
* start
; /* first character of token in input stream */
193 FT_Byte
* limit
; /* first character after the token */
194 T1_TokenType type
; /* type of token */
199 /* enumeration type used to identify object fields */
200 typedef enum T1_FieldType_
202 T1_FIELD_TYPE_NONE
= 0,
204 T1_FIELD_TYPE_INTEGER
,
206 T1_FIELD_TYPE_FIXED_1000
,
207 T1_FIELD_TYPE_STRING
,
210 T1_FIELD_TYPE_MM_BBOX
,
211 T1_FIELD_TYPE_INTEGER_ARRAY
,
212 T1_FIELD_TYPE_FIXED_ARRAY
,
213 T1_FIELD_TYPE_CALLBACK
,
221 typedef enum T1_FieldLocation_
223 T1_FIELD_LOCATION_CID_INFO
,
224 T1_FIELD_LOCATION_FONT_DICT
,
225 T1_FIELD_LOCATION_FONT_EXTRA
,
226 T1_FIELD_LOCATION_FONT_INFO
,
227 T1_FIELD_LOCATION_PRIVATE
,
228 T1_FIELD_LOCATION_BBOX
,
229 T1_FIELD_LOCATION_LOADER
,
230 T1_FIELD_LOCATION_FACE
,
231 T1_FIELD_LOCATION_BLEND
,
234 T1_FIELD_LOCATION_MAX
240 (*T1_Field_ParseFunc
)( FT_Face face
,
244 /* structure type used to model object fields */
245 typedef struct T1_FieldRec_
247 const char* ident
; /* field identifier */
248 T1_FieldLocation location
;
249 T1_FieldType type
; /* type of field */
250 T1_Field_ParseFunc reader
;
251 FT_UInt offset
; /* offset of field in object */
252 FT_Byte size
; /* size of field in bytes */
253 FT_UInt array_max
; /* maximum number of elements for */
255 FT_UInt count_offset
; /* offset of element count for */
256 /* arrays; must not be zero if in */
257 /* use -- in other words, a */
258 /* `num_FOO' element must not */
259 /* start the used structure if we */
260 /* parse a `FOO' array */
261 FT_UInt dict
; /* where we expect it */
264 #define T1_FIELD_DICT_FONTDICT ( 1 << 0 ) /* also FontInfo and FDArray */
265 #define T1_FIELD_DICT_PRIVATE ( 1 << 1 )
269 #define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \
271 _ident, T1CODE, _type, \
273 FT_FIELD_OFFSET( _fname ), \
274 FT_FIELD_SIZE( _fname ), \
279 #define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \
281 _ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \
282 (T1_Field_ParseFunc)_reader, \
288 #define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \
290 _ident, T1CODE, _type, \
292 FT_FIELD_OFFSET( _fname ), \
293 FT_FIELD_SIZE_DELTA( _fname ), \
295 FT_FIELD_OFFSET( num_ ## _fname ), \
299 #define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \
301 _ident, T1CODE, _type, \
303 FT_FIELD_OFFSET( _fname ), \
304 FT_FIELD_SIZE_DELTA( _fname ), \
310 #define T1_FIELD_BOOL( _ident, _fname, _dict ) \
311 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict )
313 #define T1_FIELD_NUM( _ident, _fname, _dict ) \
314 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict )
316 #define T1_FIELD_FIXED( _ident, _fname, _dict ) \
317 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict )
319 #define T1_FIELD_FIXED_1000( _ident, _fname, _dict ) \
320 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \
323 #define T1_FIELD_STRING( _ident, _fname, _dict ) \
324 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict )
326 #define T1_FIELD_KEY( _ident, _fname, _dict ) \
327 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict )
329 #define T1_FIELD_BBOX( _ident, _fname, _dict ) \
330 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict )
333 #define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict ) \
334 T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
335 _fname, _fmax, _dict )
337 #define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict ) \
338 T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
339 _fname, _fmax, _dict )
341 #define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict ) \
342 T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
343 _fname, _fmax, _dict )
345 #define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict ) \
346 T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
347 _fname, _fmax, _dict )
349 #define T1_FIELD_CALLBACK( _ident, _name, _dict ) \
350 T1_NEW_CALLBACK_FIELD( _ident, _name, _dict )
353 /*************************************************************************/
354 /*************************************************************************/
356 /***** T1 PARSER *****/
358 /*************************************************************************/
359 /*************************************************************************/
361 typedef const struct PS_Parser_FuncsRec_
* PS_Parser_Funcs
;
363 typedef struct PS_Parser_FuncsRec_
366 (*init
)( PS_Parser parser
,
372 (*done
)( PS_Parser parser
);
375 (*skip_spaces
)( PS_Parser parser
);
377 (*skip_PS_token
)( PS_Parser parser
);
380 (*to_int
)( PS_Parser parser
);
382 (*to_fixed
)( PS_Parser parser
,
386 (*to_bytes
)( PS_Parser parser
,
389 FT_ULong
* pnum_bytes
,
390 FT_Bool delimiters
);
393 (*to_coord_array
)( PS_Parser parser
,
397 (*to_fixed_array
)( PS_Parser parser
,
403 (*to_token
)( PS_Parser parser
,
406 (*to_token_array
)( PS_Parser parser
,
409 FT_Int
* pnum_tokens
);
412 (*load_field
)( PS_Parser parser
,
413 const T1_Field field
,
419 (*load_field_table
)( PS_Parser parser
,
420 const T1_Field field
,
425 } PS_Parser_FuncsRec
;
428 /*************************************************************************/
434 /* A PS_Parser is an object used to parse a Type 1 font very quickly. */
437 /* cursor :: The current position in the text. */
439 /* base :: Start of the processed text. */
441 /* limit :: End of the processed text. */
443 /* error :: The last error returned. */
445 /* memory :: The object used for memory operations (alloc/realloc). */
447 /* funcs :: A table of functions for the parser. */
449 typedef struct PS_ParserRec_
457 PS_Parser_FuncsRec funcs
;
462 /*************************************************************************/
463 /*************************************************************************/
465 /***** PS BUILDER *****/
467 /*************************************************************************/
468 /*************************************************************************/
471 typedef struct PS_Builder_ PS_Builder
;
472 typedef const struct PS_Builder_FuncsRec_
* PS_Builder_Funcs
;
474 typedef struct PS_Builder_FuncsRec_
477 (*init
)( PS_Builder
* ps_builder
,
482 (*done
)( PS_Builder
* builder
);
484 } PS_Builder_FuncsRec
;
487 /*************************************************************************/
493 /* A structure used during glyph loading to store its outline. */
496 /* memory :: The current memory object. */
498 /* face :: The current face object. */
500 /* glyph :: The current glyph slot. */
504 /* base :: The base glyph outline. */
506 /* current :: The current glyph outline. */
508 /* pos_x :: The horizontal translation (if composite glyph). */
510 /* pos_y :: The vertical translation (if composite glyph). */
512 /* left_bearing :: The left side bearing point. */
514 /* advance :: The horizontal advance vector. */
516 /* bbox :: Unused. */
518 /* path_begun :: A flag which indicates that a new path has begun. */
520 /* load_points :: If this flag is not set, no points are loaded. */
522 /* no_recurse :: Set but not used. */
524 /* metrics_only :: A boolean indicating that we only want to compute */
525 /* the metrics of a given glyph, not load all of its */
528 /* is_t1 :: Set if current font type is Type 1. */
530 /* funcs :: An array of function pointers for the builder. */
537 FT_GlyphLoader loader
;
544 FT_Vector
* left_bearing
;
547 FT_BBox
* bbox
; /* bounding box */
552 FT_Bool metrics_only
;
555 PS_Builder_FuncsRec funcs
;
560 /*************************************************************************/
561 /*************************************************************************/
563 /***** PS DECODER *****/
565 /*************************************************************************/
566 /*************************************************************************/
568 #define PS_MAX_OPERANDS 48
569 #define PS_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */
570 /* only 10 are allowed but there exist */
571 /* fonts like `HiraKakuProN-W3.ttf' */
572 /* (Hiragino Kaku Gothic ProN W3; */
573 /* 8.2d6e1; 2014-12-19) that exceed */
576 /* execution context charstring zone */
578 typedef struct PS_Decoder_Zone_
588 (*CFF_Decoder_Get_Glyph_Callback
)( TT_Face face
,
594 (*CFF_Decoder_Free_Glyph_Callback
)( TT_Face face
,
599 typedef struct PS_Decoder_
603 FT_Fixed stack
[PS_MAX_OPERANDS
+ 1];
606 PS_Decoder_Zone zones
[PS_MAX_SUBRS_CALLS
+ 1];
607 PS_Decoder_Zone
* zone
;
610 FT_Int num_flex_vectors
;
611 FT_Vector flex_vectors
[7];
614 CFF_SubFont current_subfont
; /* for current glyph_index */
615 FT_Generic
* cf2_instance
;
630 FT_Byte
** glyph_names
; /* for pure CFF fonts only */
631 FT_UInt num_glyphs
; /* number of glyphs in font */
633 FT_Render_Mode hint_mode
;
637 CFF_Decoder_Get_Glyph_Callback get_glyph_callback
;
638 CFF_Decoder_Free_Glyph_Callback free_glyph_callback
;
641 FT_Service_PsCMaps psnames
; /* for seac */
643 FT_Int lenIV
; /* internal for sub routine calls */
644 FT_UInt
* locals_len
; /* array of subrs length (optional) */
645 FT_Hash locals_hash
; /* used if `num_subrs' was massaged */
647 FT_Matrix font_matrix
;
648 FT_Vector font_offset
;
650 PS_Blend blend
; /* for multiple master support */
653 FT_UInt len_buildchar
;
658 /*************************************************************************/
659 /*************************************************************************/
661 /***** T1 BUILDER *****/
663 /*************************************************************************/
664 /*************************************************************************/
667 typedef struct T1_BuilderRec_
* T1_Builder
;
671 (*T1_Builder_Check_Points_Func
)( T1_Builder builder
,
675 (*T1_Builder_Add_Point_Func
)( T1_Builder builder
,
681 (*T1_Builder_Add_Point1_Func
)( T1_Builder builder
,
686 (*T1_Builder_Add_Contour_Func
)( T1_Builder builder
);
689 (*T1_Builder_Start_Point_Func
)( T1_Builder builder
,
694 (*T1_Builder_Close_Contour_Func
)( T1_Builder builder
);
697 typedef const struct T1_Builder_FuncsRec_
* T1_Builder_Funcs
;
699 typedef struct T1_Builder_FuncsRec_
702 (*init
)( T1_Builder builder
,
709 (*done
)( T1_Builder builder
);
711 T1_Builder_Check_Points_Func check_points
;
712 T1_Builder_Add_Point_Func add_point
;
713 T1_Builder_Add_Point1_Func add_point1
;
714 T1_Builder_Add_Contour_Func add_contour
;
715 T1_Builder_Start_Point_Func start_point
;
716 T1_Builder_Close_Contour_Func close_contour
;
718 } T1_Builder_FuncsRec
;
721 /* an enumeration type to handle charstring parsing states */
722 typedef enum T1_ParseState_
726 T1_Parse_Have_Moveto
,
732 /*************************************************************************/
738 /* A structure used during glyph loading to store its outline. */
741 /* memory :: The current memory object. */
743 /* face :: The current face object. */
745 /* glyph :: The current glyph slot. */
749 /* base :: The base glyph outline. */
751 /* current :: The current glyph outline. */
753 /* max_points :: maximum points in builder outline */
755 /* max_contours :: Maximum number of contours in builder outline. */
757 /* pos_x :: The horizontal translation (if composite glyph). */
759 /* pos_y :: The vertical translation (if composite glyph). */
761 /* left_bearing :: The left side bearing point. */
763 /* advance :: The horizontal advance vector. */
765 /* bbox :: Unused. */
767 /* parse_state :: An enumeration which controls the charstring */
770 /* load_points :: If this flag is not set, no points are loaded. */
772 /* no_recurse :: Set but not used. */
774 /* metrics_only :: A boolean indicating that we only want to compute */
775 /* the metrics of a given glyph, not load all of its */
778 /* funcs :: An array of function pointers for the builder. */
780 typedef struct T1_BuilderRec_
785 FT_GlyphLoader loader
;
792 FT_Vector left_bearing
;
795 FT_BBox bbox
; /* bounding box */
796 T1_ParseState parse_state
;
800 FT_Bool metrics_only
;
802 void* hints_funcs
; /* hinter-specific */
803 void* hints_globals
; /* hinter-specific */
805 T1_Builder_FuncsRec funcs
;
810 /*************************************************************************/
811 /*************************************************************************/
813 /***** T1 DECODER *****/
815 /*************************************************************************/
816 /*************************************************************************/
820 /*************************************************************************/
822 /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
823 /* calls during glyph loading. */
825 #define T1_MAX_SUBRS_CALLS 8
828 /*************************************************************************/
830 /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
831 /* minimum of 16 is required. */
833 #define T1_MAX_CHARSTRINGS_OPERANDS 32
838 typedef struct T1_Decoder_ZoneRec_
844 } T1_Decoder_ZoneRec
, *T1_Decoder_Zone
;
847 typedef struct T1_DecoderRec_
* T1_Decoder
;
848 typedef const struct T1_Decoder_FuncsRec_
* T1_Decoder_Funcs
;
852 (*T1_Decoder_Callback
)( T1_Decoder decoder
,
853 FT_UInt glyph_index
);
856 typedef struct T1_Decoder_FuncsRec_
859 (*init
)( T1_Decoder decoder
,
863 FT_Byte
** glyph_names
,
866 FT_Render_Mode hint_mode
,
867 T1_Decoder_Callback callback
);
870 (*done
)( T1_Decoder decoder
);
872 #ifdef T1_CONFIG_OPTION_OLD_ENGINE
874 (*parse_charstrings_old
)( T1_Decoder decoder
,
879 (*parse_metrics
)( T1_Decoder decoder
,
885 (*parse_charstrings
)( PS_Decoder
* decoder
,
886 FT_Byte
* charstring_base
,
887 FT_ULong charstring_len
);
890 } T1_Decoder_FuncsRec
;
893 typedef struct T1_DecoderRec_
895 T1_BuilderRec builder
;
897 FT_Long stack
[T1_MAX_CHARSTRINGS_OPERANDS
];
900 T1_Decoder_ZoneRec zones
[T1_MAX_SUBRS_CALLS
+ 1];
901 T1_Decoder_Zone zone
;
903 FT_Service_PsCMaps psnames
; /* for seac */
905 FT_Byte
** glyph_names
;
907 FT_Int lenIV
; /* internal for sub routine calls */
910 FT_UInt
* subrs_len
; /* array of subrs length (optional) */
911 FT_Hash subrs_hash
; /* used if `num_subrs' was massaged */
913 FT_Matrix font_matrix
;
914 FT_Vector font_offset
;
917 FT_Int num_flex_vectors
;
918 FT_Vector flex_vectors
[7];
920 PS_Blend blend
; /* for multiple master support */
922 FT_Render_Mode hint_mode
;
924 T1_Decoder_Callback parse_callback
;
925 T1_Decoder_FuncsRec funcs
;
928 FT_UInt len_buildchar
;
932 FT_Generic cf2_instance
;
937 /*************************************************************************/
938 /*************************************************************************/
940 /***** CFF BUILDER *****/
942 /*************************************************************************/
943 /*************************************************************************/
946 typedef struct CFF_Builder_ CFF_Builder
;
950 (*CFF_Builder_Check_Points_Func
)( CFF_Builder
* builder
,
954 (*CFF_Builder_Add_Point_Func
)( CFF_Builder
* builder
,
959 (*CFF_Builder_Add_Point1_Func
)( CFF_Builder
* builder
,
963 (*CFF_Builder_Start_Point_Func
)( CFF_Builder
* builder
,
967 (*CFF_Builder_Close_Contour_Func
)( CFF_Builder
* builder
);
970 (*CFF_Builder_Add_Contour_Func
)( CFF_Builder
* builder
);
972 typedef const struct CFF_Builder_FuncsRec_
* CFF_Builder_Funcs
;
974 typedef struct CFF_Builder_FuncsRec_
977 (*init
)( CFF_Builder
* builder
,
984 (*done
)( CFF_Builder
* builder
);
986 CFF_Builder_Check_Points_Func check_points
;
987 CFF_Builder_Add_Point_Func add_point
;
988 CFF_Builder_Add_Point1_Func add_point1
;
989 CFF_Builder_Add_Contour_Func add_contour
;
990 CFF_Builder_Start_Point_Func start_point
;
991 CFF_Builder_Close_Contour_Func close_contour
;
993 } CFF_Builder_FuncsRec
;
996 /*************************************************************************/
1002 /* A structure used during glyph loading to store its outline. */
1005 /* memory :: The current memory object. */
1007 /* face :: The current face object. */
1009 /* glyph :: The current glyph slot. */
1011 /* loader :: The current glyph loader. */
1013 /* base :: The base glyph outline. */
1015 /* current :: The current glyph outline. */
1017 /* pos_x :: The horizontal translation (if composite glyph). */
1019 /* pos_y :: The vertical translation (if composite glyph). */
1021 /* left_bearing :: The left side bearing point. */
1023 /* advance :: The horizontal advance vector. */
1025 /* bbox :: Unused. */
1027 /* path_begun :: A flag which indicates that a new path has begun. */
1029 /* load_points :: If this flag is not set, no points are loaded. */
1031 /* no_recurse :: Set but not used. */
1033 /* metrics_only :: A boolean indicating that we only want to compute */
1034 /* the metrics of a given glyph, not load all of its */
1037 /* hints_funcs :: Auxiliary pointer for hinting. */
1039 /* hints_globals :: Auxiliary pointer for hinting. */
1041 /* funcs :: A table of method pointers for this object. */
1047 CFF_GlyphSlot glyph
;
1048 FT_GlyphLoader loader
;
1050 FT_Outline
* current
;
1055 FT_Vector left_bearing
;
1058 FT_BBox bbox
; /* bounding box */
1061 FT_Bool load_points
;
1064 FT_Bool metrics_only
;
1066 void* hints_funcs
; /* hinter-specific */
1067 void* hints_globals
; /* hinter-specific */
1069 CFF_Builder_FuncsRec funcs
;
1073 /*************************************************************************/
1074 /*************************************************************************/
1076 /***** CFF DECODER *****/
1078 /*************************************************************************/
1079 /*************************************************************************/
1082 #define CFF_MAX_OPERANDS 48
1083 #define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */
1084 /* only 10 are allowed but there exist */
1085 /* fonts like `HiraKakuProN-W3.ttf' */
1086 /* (Hiragino Kaku Gothic ProN W3; */
1087 /* 8.2d6e1; 2014-12-19) that exceed */
1089 #define CFF_MAX_TRANS_ELEMENTS 32
1091 /* execution context charstring zone */
1093 typedef struct CFF_Decoder_Zone_
1102 typedef struct CFF_Decoder_
1104 CFF_Builder builder
;
1107 FT_Fixed stack
[CFF_MAX_OPERANDS
+ 1];
1110 CFF_Decoder_Zone zones
[CFF_MAX_SUBRS_CALLS
+ 1];
1111 CFF_Decoder_Zone
* zone
;
1114 FT_Int num_flex_vectors
;
1115 FT_Vector flex_vectors
[7];
1118 FT_Pos nominal_width
;
1123 FT_Fixed buildchar
[CFF_MAX_TRANS_ELEMENTS
];
1126 FT_UInt num_globals
;
1129 FT_Int globals_bias
;
1134 FT_Byte
** glyph_names
; /* for pure CFF fonts only */
1135 FT_UInt num_glyphs
; /* number of glyphs in font */
1137 FT_Render_Mode hint_mode
;
1141 CFF_SubFont current_subfont
; /* for current glyph_index */
1143 CFF_Decoder_Get_Glyph_Callback get_glyph_callback
;
1144 CFF_Decoder_Free_Glyph_Callback free_glyph_callback
;
1149 typedef const struct CFF_Decoder_FuncsRec_
* CFF_Decoder_Funcs
;
1151 typedef struct CFF_Decoder_FuncsRec_
1154 (*init
)( CFF_Decoder
* decoder
,
1159 FT_Render_Mode hint_mode
,
1160 CFF_Decoder_Get_Glyph_Callback get_callback
,
1161 CFF_Decoder_Free_Glyph_Callback free_callback
);
1164 (*prepare
)( CFF_Decoder
* decoder
,
1166 FT_UInt glyph_index
);
1168 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
1170 (*parse_charstrings_old
)( CFF_Decoder
* decoder
,
1171 FT_Byte
* charstring_base
,
1172 FT_ULong charstring_len
,
1177 (*parse_charstrings
)( PS_Decoder
* decoder
,
1178 FT_Byte
* charstring_base
,
1179 FT_ULong charstring_len
);
1181 } CFF_Decoder_FuncsRec
;
1184 /*************************************************************************/
1185 /*************************************************************************/
1187 /***** AFM PARSER *****/
1189 /*************************************************************************/
1190 /*************************************************************************/
1192 typedef struct AFM_ParserRec_
* AFM_Parser
;
1194 typedef struct AFM_Parser_FuncsRec_
1197 (*init
)( AFM_Parser parser
,
1203 (*done
)( AFM_Parser parser
);
1206 (*parse
)( AFM_Parser parser
);
1208 } AFM_Parser_FuncsRec
;
1211 typedef struct AFM_StreamRec_
* AFM_Stream
;
1214 /*************************************************************************/
1220 /* An AFM_Parser is a parser for the AFM files. */
1223 /* memory :: The object used for memory operations (alloc and */
1226 /* stream :: This is an opaque object. */
1228 /* FontInfo :: The result will be stored here. */
1230 /* get_index :: A user provided function to get a glyph index by its */
1233 typedef struct AFM_ParserRec_
1238 AFM_FontInfo FontInfo
;
1241 (*get_index
)( const char* name
,
1250 /*************************************************************************/
1251 /*************************************************************************/
1253 /***** TYPE1 CHARMAPS *****/
1255 /*************************************************************************/
1256 /*************************************************************************/
1258 typedef const struct T1_CMap_ClassesRec_
* T1_CMap_Classes
;
1260 typedef struct T1_CMap_ClassesRec_
1262 FT_CMap_Class standard
;
1263 FT_CMap_Class expert
;
1264 FT_CMap_Class custom
;
1265 FT_CMap_Class unicode
;
1267 } T1_CMap_ClassesRec
;
1270 /*************************************************************************/
1271 /*************************************************************************/
1273 /***** PSAux Module Interface *****/
1275 /*************************************************************************/
1276 /*************************************************************************/
1278 typedef struct PSAux_ServiceRec_
1280 /* don't use `PS_Table_Funcs' and friends to avoid compiler warnings */
1281 const PS_Table_FuncsRec
* ps_table_funcs
;
1282 const PS_Parser_FuncsRec
* ps_parser_funcs
;
1283 const T1_Builder_FuncsRec
* t1_builder_funcs
;
1284 const T1_Decoder_FuncsRec
* t1_decoder_funcs
;
1287 (*t1_decrypt
)( FT_Byte
* buffer
,
1292 (*cff_random
)( FT_UInt32 r
);
1295 (*ps_decoder_init
)( PS_Decoder
* ps_decoder
,
1300 (*t1_make_subfont
)( FT_Face face
,
1302 CFF_SubFont subfont
);
1304 T1_CMap_Classes t1_cmap_classes
;
1306 /* fields after this comment line were added after version 2.1.10 */
1307 const AFM_Parser_FuncsRec
* afm_parser_funcs
;
1309 const CFF_Decoder_FuncsRec
* cff_decoder_funcs
;
1311 } PSAux_ServiceRec
, *PSAux_Service
;
1313 /* backward compatible type definition */
1314 typedef PSAux_ServiceRec PSAux_Interface
;
1317 /*************************************************************************/
1318 /*************************************************************************/
1320 /***** Some convenience functions *****/
1322 /*************************************************************************/
1323 /*************************************************************************/
1325 #define IS_PS_NEWLINE( ch ) \
1329 #define IS_PS_SPACE( ch ) \
1331 IS_PS_NEWLINE( ch ) || \
1336 #define IS_PS_SPECIAL( ch ) \
1338 (ch) == '(' || (ch) == ')' || \
1339 (ch) == '<' || (ch) == '>' || \
1340 (ch) == '[' || (ch) == ']' || \
1341 (ch) == '{' || (ch) == '}' || \
1344 #define IS_PS_DELIM( ch ) \
1345 ( IS_PS_SPACE( ch ) || \
1346 IS_PS_SPECIAL( ch ) )
1348 #define IS_PS_DIGIT( ch ) \
1349 ( (ch) >= '0' && (ch) <= '9' )
1351 #define IS_PS_XDIGIT( ch ) \
1352 ( IS_PS_DIGIT( ch ) || \
1353 ( (ch) >= 'A' && (ch) <= 'F' ) || \
1354 ( (ch) >= 'a' && (ch) <= 'f' ) )
1356 #define IS_PS_BASE85( ch ) \
1357 ( (ch) >= '!' && (ch) <= 'u' )
1359 #define IS_PS_TOKEN( cur, limit, token ) \
1360 ( (char)(cur)[0] == (token)[0] && \
1361 ( (cur) + sizeof ( (token) ) == (limit) || \
1362 ( (cur) + sizeof( (token) ) < (limit) && \
1363 IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) ) && \
1364 ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 )
1369 #endif /* PSAUX_H_ */