00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PSAUX_H__
00021 #define __PSAUX_H__
00022
00023
00024 #include <ft2build.h>
00025 #include FT_INTERNAL_OBJECTS_H
00026 #include FT_INTERNAL_TYPE1_TYPES_H
00027 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
00028
00029
00030 FT_BEGIN_HEADER
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 typedef struct PS_TableRec_* PS_Table;
00043 typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs;
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 typedef struct PS_Table_FuncsRec_
00064 {
00065 FT_Error
00066 (*init)( PS_Table table,
00067 FT_Int count,
00068 FT_Memory memory );
00069
00070 void
00071 (*done)( PS_Table table );
00072
00073 FT_Error
00074 (*add)( PS_Table table,
00075 FT_Int idx,
00076 void* object,
00077 FT_PtrDist length );
00078
00079 void
00080 (*release)( PS_Table table );
00081
00082 } PS_Table_FuncsRec;
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 typedef struct PS_TableRec_
00118 {
00119 FT_Byte* block;
00120 FT_Offset cursor;
00121 FT_Offset capacity;
00122 FT_Long init;
00123
00124 FT_Int max_elems;
00125 FT_Int num_elems;
00126 FT_Byte** elements;
00127 FT_PtrDist* lengths;
00128
00129 FT_Memory memory;
00130 PS_Table_FuncsRec funcs;
00131
00132 } PS_TableRec;
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 typedef struct PS_ParserRec_* PS_Parser;
00144
00145 typedef struct T1_TokenRec_* T1_Token;
00146
00147 typedef struct T1_FieldRec_* T1_Field;
00148
00149
00150
00151 typedef enum T1_TokenType_
00152 {
00153 T1_TOKEN_TYPE_NONE = 0,
00154 T1_TOKEN_TYPE_ANY,
00155 T1_TOKEN_TYPE_STRING,
00156 T1_TOKEN_TYPE_ARRAY,
00157 T1_TOKEN_TYPE_KEY,
00158
00159
00160 T1_TOKEN_TYPE_MAX
00161
00162 } T1_TokenType;
00163
00164
00165
00166 typedef struct T1_TokenRec_
00167 {
00168 FT_Byte* start;
00169 FT_Byte* limit;
00170 T1_TokenType type;
00171
00172 } T1_TokenRec;
00173
00174
00175
00176 typedef enum T1_FieldType_
00177 {
00178 T1_FIELD_TYPE_NONE = 0,
00179 T1_FIELD_TYPE_BOOL,
00180 T1_FIELD_TYPE_INTEGER,
00181 T1_FIELD_TYPE_FIXED,
00182 T1_FIELD_TYPE_FIXED_1000,
00183 T1_FIELD_TYPE_STRING,
00184 T1_FIELD_TYPE_KEY,
00185 T1_FIELD_TYPE_BBOX,
00186 T1_FIELD_TYPE_INTEGER_ARRAY,
00187 T1_FIELD_TYPE_FIXED_ARRAY,
00188 T1_FIELD_TYPE_CALLBACK,
00189
00190
00191 T1_FIELD_TYPE_MAX
00192
00193 } T1_FieldType;
00194
00195
00196 typedef enum T1_FieldLocation_
00197 {
00198 T1_FIELD_LOCATION_CID_INFO,
00199 T1_FIELD_LOCATION_FONT_DICT,
00200 T1_FIELD_LOCATION_FONT_EXTRA,
00201 T1_FIELD_LOCATION_FONT_INFO,
00202 T1_FIELD_LOCATION_PRIVATE,
00203 T1_FIELD_LOCATION_BBOX,
00204 T1_FIELD_LOCATION_LOADER,
00205 T1_FIELD_LOCATION_FACE,
00206 T1_FIELD_LOCATION_BLEND,
00207
00208
00209 T1_FIELD_LOCATION_MAX
00210
00211 } T1_FieldLocation;
00212
00213
00214 typedef void
00215 (*T1_Field_ParseFunc)( FT_Face face,
00216 FT_Pointer parser );
00217
00218
00219
00220 typedef struct T1_FieldRec_
00221 {
00222 const char* ident;
00223 T1_FieldLocation location;
00224 T1_FieldType type;
00225 T1_Field_ParseFunc reader;
00226 FT_UInt offset;
00227 FT_Byte size;
00228 FT_UInt array_max;
00229
00230 FT_UInt count_offset;
00231
00232
00233
00234
00235
00236 FT_UInt dict;
00237 } T1_FieldRec;
00238
00239 #define T1_FIELD_DICT_FONTDICT ( 1 << 0 )
00240 #define T1_FIELD_DICT_PRIVATE ( 1 << 1 )
00241
00242
00243
00244 #define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \
00245 { \
00246 _ident, T1CODE, _type, \
00247 0, \
00248 FT_FIELD_OFFSET( _fname ), \
00249 FT_FIELD_SIZE( _fname ), \
00250 0, 0, \
00251 _dict \
00252 },
00253
00254 #define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \
00255 { \
00256 _ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \
00257 (T1_Field_ParseFunc)_reader, \
00258 0, 0, \
00259 0, 0, \
00260 _dict \
00261 },
00262
00263 #define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \
00264 { \
00265 _ident, T1CODE, _type, \
00266 0, \
00267 FT_FIELD_OFFSET( _fname ), \
00268 FT_FIELD_SIZE_DELTA( _fname ), \
00269 _max, \
00270 FT_FIELD_OFFSET( num_ ## _fname ), \
00271 _dict \
00272 },
00273
00274 #define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \
00275 { \
00276 _ident, T1CODE, _type, \
00277 0, \
00278 FT_FIELD_OFFSET( _fname ), \
00279 FT_FIELD_SIZE_DELTA( _fname ), \
00280 _max, 0, \
00281 _dict \
00282 },
00283
00284
00285 #define T1_FIELD_BOOL( _ident, _fname, _dict ) \
00286 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict )
00287
00288 #define T1_FIELD_NUM( _ident, _fname, _dict ) \
00289 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict )
00290
00291 #define T1_FIELD_FIXED( _ident, _fname, _dict ) \
00292 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict )
00293
00294 #define T1_FIELD_FIXED_1000( _ident, _fname, _dict ) \
00295 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \
00296 _dict )
00297
00298 #define T1_FIELD_STRING( _ident, _fname, _dict ) \
00299 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict )
00300
00301 #define T1_FIELD_KEY( _ident, _fname, _dict ) \
00302 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict )
00303
00304 #define T1_FIELD_BBOX( _ident, _fname, _dict ) \
00305 T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict )
00306
00307
00308 #define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict ) \
00309 T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
00310 _fname, _fmax, _dict )
00311
00312 #define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict ) \
00313 T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
00314 _fname, _fmax, _dict )
00315
00316 #define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict ) \
00317 T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
00318 _fname, _fmax, _dict )
00319
00320 #define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict ) \
00321 T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
00322 _fname, _fmax, _dict )
00323
00324 #define T1_FIELD_CALLBACK( _ident, _name, _dict ) \
00325 T1_NEW_CALLBACK_FIELD( _ident, _name, _dict )
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336 typedef const struct PS_Parser_FuncsRec_* PS_Parser_Funcs;
00337
00338 typedef struct PS_Parser_FuncsRec_
00339 {
00340 void
00341 (*init)( PS_Parser parser,
00342 FT_Byte* base,
00343 FT_Byte* limit,
00344 FT_Memory memory );
00345
00346 void
00347 (*done)( PS_Parser parser );
00348
00349 void
00350 (*skip_spaces)( PS_Parser parser );
00351 void
00352 (*skip_PS_token)( PS_Parser parser );
00353
00354 FT_Long
00355 (*to_int)( PS_Parser parser );
00356 FT_Fixed
00357 (*to_fixed)( PS_Parser parser,
00358 FT_Int power_ten );
00359
00360 FT_Error
00361 (*to_bytes)( PS_Parser parser,
00362 FT_Byte* bytes,
00363 FT_Offset max_bytes,
00364 FT_Long* pnum_bytes,
00365 FT_Bool delimiters );
00366
00367 FT_Int
00368 (*to_coord_array)( PS_Parser parser,
00369 FT_Int max_coords,
00370 FT_Short* coords );
00371 FT_Int
00372 (*to_fixed_array)( PS_Parser parser,
00373 FT_Int max_values,
00374 FT_Fixed* values,
00375 FT_Int power_ten );
00376
00377 void
00378 (*to_token)( PS_Parser parser,
00379 T1_Token token );
00380 void
00381 (*to_token_array)( PS_Parser parser,
00382 T1_Token tokens,
00383 FT_UInt max_tokens,
00384 FT_Int* pnum_tokens );
00385
00386 FT_Error
00387 (*load_field)( PS_Parser parser,
00388 const T1_Field field,
00389 void** objects,
00390 FT_UInt max_objects,
00391 FT_ULong* pflags );
00392
00393 FT_Error
00394 (*load_field_table)( PS_Parser parser,
00395 const T1_Field field,
00396 void** objects,
00397 FT_UInt max_objects,
00398 FT_ULong* pflags );
00399
00400 } PS_Parser_FuncsRec;
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424 typedef struct PS_ParserRec_
00425 {
00426 FT_Byte* cursor;
00427 FT_Byte* base;
00428 FT_Byte* limit;
00429 FT_Error error;
00430 FT_Memory memory;
00431
00432 PS_Parser_FuncsRec funcs;
00433
00434 } PS_ParserRec;
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 typedef struct T1_BuilderRec_* T1_Builder;
00447
00448
00449 typedef FT_Error
00450 (*T1_Builder_Check_Points_Func)( T1_Builder builder,
00451 FT_Int count );
00452
00453 typedef void
00454 (*T1_Builder_Add_Point_Func)( T1_Builder builder,
00455 FT_Pos x,
00456 FT_Pos y,
00457 FT_Byte flag );
00458
00459 typedef FT_Error
00460 (*T1_Builder_Add_Point1_Func)( T1_Builder builder,
00461 FT_Pos x,
00462 FT_Pos y );
00463
00464 typedef FT_Error
00465 (*T1_Builder_Add_Contour_Func)( T1_Builder builder );
00466
00467 typedef FT_Error
00468 (*T1_Builder_Start_Point_Func)( T1_Builder builder,
00469 FT_Pos x,
00470 FT_Pos y );
00471
00472 typedef void
00473 (*T1_Builder_Close_Contour_Func)( T1_Builder builder );
00474
00475
00476 typedef const struct T1_Builder_FuncsRec_* T1_Builder_Funcs;
00477
00478 typedef struct T1_Builder_FuncsRec_
00479 {
00480 void
00481 (*init)( T1_Builder builder,
00482 FT_Face face,
00483 FT_Size size,
00484 FT_GlyphSlot slot,
00485 FT_Bool hinting );
00486
00487 void
00488 (*done)( T1_Builder builder );
00489
00490 T1_Builder_Check_Points_Func check_points;
00491 T1_Builder_Add_Point_Func add_point;
00492 T1_Builder_Add_Point1_Func add_point1;
00493 T1_Builder_Add_Contour_Func add_contour;
00494 T1_Builder_Start_Point_Func start_point;
00495 T1_Builder_Close_Contour_Func close_contour;
00496
00497 } T1_Builder_FuncsRec;
00498
00499
00500
00501 typedef enum T1_ParseState_
00502 {
00503 T1_Parse_Start,
00504 T1_Parse_Have_Width,
00505 T1_Parse_Have_Moveto,
00506 T1_Parse_Have_Path
00507
00508 } T1_ParseState;
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559 typedef struct T1_BuilderRec_
00560 {
00561 FT_Memory memory;
00562 FT_Face face;
00563 FT_GlyphSlot glyph;
00564 FT_GlyphLoader loader;
00565 FT_Outline* base;
00566 FT_Outline* current;
00567
00568 FT_Pos pos_x;
00569 FT_Pos pos_y;
00570
00571 FT_Vector left_bearing;
00572 FT_Vector advance;
00573
00574 FT_BBox bbox;
00575 T1_ParseState parse_state;
00576 FT_Bool load_points;
00577 FT_Bool no_recurse;
00578
00579 FT_Bool metrics_only;
00580
00581 void* hints_funcs;
00582 void* hints_globals;
00583
00584 T1_Builder_FuncsRec funcs;
00585
00586 } T1_BuilderRec;
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597 #if 0
00598
00599
00600
00601
00602
00603
00604 #define T1_MAX_SUBRS_CALLS 8
00605
00606
00607
00608
00609
00610
00611
00612 #define T1_MAX_CHARSTRINGS_OPERANDS 32
00613
00614 #endif
00615
00616
00617 typedef struct T1_Decoder_ZoneRec_
00618 {
00619 FT_Byte* cursor;
00620 FT_Byte* base;
00621 FT_Byte* limit;
00622
00623 } T1_Decoder_ZoneRec, *T1_Decoder_Zone;
00624
00625
00626 typedef struct T1_DecoderRec_* T1_Decoder;
00627 typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs;
00628
00629
00630 typedef FT_Error
00631 (*T1_Decoder_Callback)( T1_Decoder decoder,
00632 FT_UInt glyph_index );
00633
00634
00635 typedef struct T1_Decoder_FuncsRec_
00636 {
00637 FT_Error
00638 (*init)( T1_Decoder decoder,
00639 FT_Face face,
00640 FT_Size size,
00641 FT_GlyphSlot slot,
00642 FT_Byte** glyph_names,
00643 PS_Blend blend,
00644 FT_Bool hinting,
00645 FT_Render_Mode hint_mode,
00646 T1_Decoder_Callback callback );
00647
00648 void
00649 (*done)( T1_Decoder decoder );
00650
00651 FT_Error
00652 (*parse_charstrings)( T1_Decoder decoder,
00653 FT_Byte* base,
00654 FT_UInt len );
00655
00656 } T1_Decoder_FuncsRec;
00657
00658
00659 typedef struct T1_DecoderRec_
00660 {
00661 T1_BuilderRec builder;
00662
00663 FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS];
00664 FT_Long* top;
00665
00666 T1_Decoder_ZoneRec zones[T1_MAX_SUBRS_CALLS + 1];
00667 T1_Decoder_Zone zone;
00668
00669 FT_Service_PsCMaps psnames;
00670 FT_UInt num_glyphs;
00671 FT_Byte** glyph_names;
00672
00673 FT_Int lenIV;
00674 FT_UInt num_subrs;
00675 FT_Byte** subrs;
00676 FT_PtrDist* subrs_len;
00677
00678 FT_Matrix font_matrix;
00679 FT_Vector font_offset;
00680
00681 FT_Int flex_state;
00682 FT_Int num_flex_vectors;
00683 FT_Vector flex_vectors[7];
00684
00685 PS_Blend blend;
00686
00687 FT_Render_Mode hint_mode;
00688
00689 T1_Decoder_Callback parse_callback;
00690 T1_Decoder_FuncsRec funcs;
00691
00692 FT_Long* buildchar;
00693 FT_UInt len_buildchar;
00694
00695 FT_Bool seac;
00696
00697 } T1_DecoderRec;
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708 typedef struct AFM_ParserRec_* AFM_Parser;
00709
00710 typedef struct AFM_Parser_FuncsRec_
00711 {
00712 FT_Error
00713 (*init)( AFM_Parser parser,
00714 FT_Memory memory,
00715 FT_Byte* base,
00716 FT_Byte* limit );
00717
00718 void
00719 (*done)( AFM_Parser parser );
00720
00721 FT_Error
00722 (*parse)( AFM_Parser parser );
00723
00724 } AFM_Parser_FuncsRec;
00725
00726
00727 typedef struct AFM_StreamRec_* AFM_Stream;
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749 typedef struct AFM_ParserRec_
00750 {
00751 FT_Memory memory;
00752 AFM_Stream stream;
00753
00754 AFM_FontInfo FontInfo;
00755
00756 FT_Int
00757 (*get_index)( const char* name,
00758 FT_Offset len,
00759 void* user_data );
00760
00761 void* user_data;
00762
00763 } AFM_ParserRec;
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774 typedef const struct T1_CMap_ClassesRec_* T1_CMap_Classes;
00775
00776 typedef struct T1_CMap_ClassesRec_
00777 {
00778 FT_CMap_Class standard;
00779 FT_CMap_Class expert;
00780 FT_CMap_Class custom;
00781 FT_CMap_Class unicode;
00782
00783 } T1_CMap_ClassesRec;
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794 typedef struct PSAux_ServiceRec_
00795 {
00796
00797 const PS_Table_FuncsRec* ps_table_funcs;
00798 const PS_Parser_FuncsRec* ps_parser_funcs;
00799 const T1_Builder_FuncsRec* t1_builder_funcs;
00800 const T1_Decoder_FuncsRec* t1_decoder_funcs;
00801
00802 void
00803 (*t1_decrypt)( FT_Byte* buffer,
00804 FT_Offset length,
00805 FT_UShort seed );
00806
00807 T1_CMap_Classes t1_cmap_classes;
00808
00809
00810 const AFM_Parser_FuncsRec* afm_parser_funcs;
00811
00812 } PSAux_ServiceRec, *PSAux_Service;
00813
00814
00815 typedef PSAux_ServiceRec PSAux_Interface;
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826 #define IS_PS_NEWLINE( ch ) \
00827 ( (ch) == '\r' || \
00828 (ch) == '\n' )
00829
00830 #define IS_PS_SPACE( ch ) \
00831 ( (ch) == ' ' || \
00832 IS_PS_NEWLINE( ch ) || \
00833 (ch) == '\t' || \
00834 (ch) == '\f' || \
00835 (ch) == '\0' )
00836
00837 #define IS_PS_SPECIAL( ch ) \
00838 ( (ch) == '/' || \
00839 (ch) == '(' || (ch) == ')' || \
00840 (ch) == '<' || (ch) == '>' || \
00841 (ch) == '[' || (ch) == ']' || \
00842 (ch) == '{' || (ch) == '}' || \
00843 (ch) == '%' )
00844
00845 #define IS_PS_DELIM( ch ) \
00846 ( IS_PS_SPACE( ch ) || \
00847 IS_PS_SPECIAL( ch ) )
00848
00849 #define IS_PS_DIGIT( ch ) \
00850 ( (ch) >= '0' && (ch) <= '9' )
00851
00852 #define IS_PS_XDIGIT( ch ) \
00853 ( IS_PS_DIGIT( ch ) || \
00854 ( (ch) >= 'A' && (ch) <= 'F' ) || \
00855 ( (ch) >= 'a' && (ch) <= 'f' ) )
00856
00857 #define IS_PS_BASE85( ch ) \
00858 ( (ch) >= '!' && (ch) <= 'u' )
00859
00860 #define IS_PS_TOKEN( cur, limit, token ) \
00861 ( (char)(cur)[0] == (token)[0] && \
00862 ( (cur) + sizeof ( (token) ) == (limit) || \
00863 ( (cur) + sizeof( (token) ) < (limit) && \
00864 IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) ) && \
00865 ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 )
00866
00867
00868 FT_END_HEADER
00869
00870 #endif
00871
00872
00873