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 :: Used to initialize a table. */ 77 /* */ 78 /* table_done :: Finalizes resp. destroy a given table. */ 79 /* */ 80 /* table_add :: Adds a new object to a table. */ 81 /* */ 82 /* table_release :: Releases table data, then finalizes it. */ 83 /* */ 84 typedef struct PS_Table_FuncsRec_ 85 { 86 FT_Error 87 (*init)( PS_Table table, 88 FT_Int count, 89 FT_Memory memory ); 90 91 void 92 (*done)( PS_Table table ); 93 94 FT_Error 95 (*add)( PS_Table table, 96 FT_Int idx, 97 void* object, 98 FT_UInt length ); 99 100 void 101 (*release)( PS_Table table ); 102 103 } PS_Table_FuncsRec; 104 105 106 /*************************************************************************/ 107 /* */ 108 /* <Struct> */ 109 /* PS_TableRec */ 110 /* */ 111 /* <Description> */ 112 /* A PS_Table is a simple object used to store an array of objects in */ 113 /* a single memory block. */ 114 /* */ 115 /* <Fields> */ 116 /* block :: The address in memory of the growheap's block. This */ 117 /* can change between two object adds, due to */ 118 /* reallocation. */ 119 /* */ 120 /* cursor :: The current top of the grow heap within its block. */ 121 /* */ 122 /* capacity :: The current size of the heap block. Increments by */ 123 /* 1kByte chunks. */ 124 /* */ 125 /* init :: Set to 0xDEADBEEF if `elements' and `lengths' have */ 126 /* been allocated. */ 127 /* */ 128 /* max_elems :: The maximum number of elements in table. */ 129 /* */ 130 /* num_elems :: The current number of elements in table. */ 131 /* */ 132 /* elements :: A table of element addresses within the block. */ 133 /* */ 134 /* lengths :: A table of element sizes within the block. */ 135 /* */ 136 /* memory :: The object used for memory operations */ 137 /* (alloc/realloc). */ 138 /* */ 139 /* funcs :: A table of method pointers for this object. */ 140 /* */ 141 typedef struct PS_TableRec_ 142 { 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 */ 146 FT_ULong init; 147 148 FT_Int max_elems; 149 FT_Int num_elems; 150 FT_Byte** elements; /* addresses of table elements */ 151 FT_UInt* lengths; /* lengths of table elements */ 152 153 FT_Memory memory; 154 PS_Table_FuncsRec funcs; 155 156 } PS_TableRec; 157 158 159 /*************************************************************************/ 160 /*************************************************************************/ 408 FT_UInt max_tokens, 409 FT_Int* pnum_tokens ); 410 411 FT_Error 412 (*load_field)( PS_Parser parser, 413 const T1_Field field, 414 void** objects, 415 FT_UInt max_objects, 416 FT_ULong* pflags ); 417 418 FT_Error 419 (*load_field_table)( PS_Parser parser, 420 const T1_Field field, 421 void** objects, 422 FT_UInt max_objects, 423 FT_ULong* pflags ); 424 425 } PS_Parser_FuncsRec; 426 427 428 /*************************************************************************/ 429 /* */ 430 /* <Struct> */ 431 /* PS_ParserRec */ 432 /* */ 433 /* <Description> */ 434 /* A PS_Parser is an object used to parse a Type 1 font very quickly. */ 435 /* */ 436 /* <Fields> */ 437 /* cursor :: The current position in the text. */ 438 /* */ 439 /* base :: Start of the processed text. */ 440 /* */ 441 /* limit :: End of the processed text. */ 442 /* */ 443 /* error :: The last error returned. */ 444 /* */ 445 /* memory :: The object used for memory operations (alloc/realloc). */ 446 /* */ 447 /* funcs :: A table of functions for the parser. */ 448 /* */ 449 typedef struct PS_ParserRec_ 450 { 451 FT_Byte* cursor; 452 FT_Byte* base; 453 FT_Byte* limit; 454 FT_Error error; 455 FT_Memory memory; 456 457 PS_Parser_FuncsRec funcs; 458 459 } PS_ParserRec; 460 461 462 /*************************************************************************/ 463 /*************************************************************************/ 464 /***** *****/ 465 /***** PS BUILDER *****/ 466 /***** *****/ 467 /*************************************************************************/ 468 /*************************************************************************/ 469 470 471 typedef struct PS_Builder_ PS_Builder; 472 typedef const struct PS_Builder_FuncsRec_* PS_Builder_Funcs; 473 474 typedef struct PS_Builder_FuncsRec_ 475 { 476 void 477 (*init)( PS_Builder* ps_builder, 478 void* builder, 479 FT_Bool is_t1 ); 480 481 void 482 (*done)( PS_Builder* builder ); 483 484 } PS_Builder_FuncsRec; 485 486 487 /*************************************************************************/ 488 /* */ 489 /* <Structure> */ 490 /* PS_Builder */ 491 /* */ 492 /* <Description> */ 493 /* A structure used during glyph loading to store its outline. */ 494 /* */ 495 /* <Fields> */ 496 /* memory :: The current memory object. */ 497 /* */ 498 /* face :: The current face object. */ 499 /* */ 500 /* glyph :: The current glyph slot. */ 501 /* */ 502 /* loader :: XXX */ 503 /* */ 504 /* base :: The base glyph outline. */ 505 /* */ 506 /* current :: The current glyph outline. */ 507 /* */ 508 /* pos_x :: The horizontal translation (if composite glyph). */ 509 /* */ 510 /* pos_y :: The vertical translation (if composite glyph). */ 511 /* */ 512 /* left_bearing :: The left side bearing point. */ 513 /* */ 514 /* advance :: The horizontal advance vector. */ 515 /* */ 516 /* bbox :: Unused. */ 517 /* */ 518 /* path_begun :: A flag which indicates that a new path has begun. */ 519 /* */ 520 /* load_points :: If this flag is not set, no points are loaded. */ 521 /* */ 522 /* no_recurse :: Set but not used. */ 523 /* */ 524 /* metrics_only :: A boolean indicating that we only want to compute */ 525 /* the metrics of a given glyph, not load all of its */ 526 /* points. */ 527 /* */ 528 /* is_t1 :: Set if current font type is Type 1. */ 529 /* */ 530 /* funcs :: An array of function pointers for the builder. */ 531 /* */ 532 struct PS_Builder_ 533 { 534 FT_Memory memory; 535 FT_Face face; 536 CFF_GlyphSlot glyph; 537 FT_GlyphLoader loader; 538 FT_Outline* base; 539 FT_Outline* current; 540 541 FT_Pos* pos_x; 542 FT_Pos* pos_y; 543 544 FT_Vector* left_bearing; 545 FT_Vector* advance; 546 547 FT_BBox* bbox; /* bounding box */ 548 FT_Bool path_begun; 549 FT_Bool load_points; 550 FT_Bool no_recurse; 551 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; 717 718 } T1_Builder_FuncsRec; 719 720 721 /* an enumeration type to handle charstring parsing states */ 722 typedef enum T1_ParseState_ 723 { 724 T1_Parse_Start, 725 T1_Parse_Have_Width, 726 T1_Parse_Have_Moveto, 727 T1_Parse_Have_Path 728 729 } T1_ParseState; 730 731 732 /*************************************************************************/ 733 /* */ 734 /* <Structure> */ 735 /* T1_BuilderRec */ 736 /* */ 737 /* <Description> */ 738 /* A structure used during glyph loading to store its outline. */ 739 /* */ 740 /* <Fields> */ 741 /* memory :: The current memory object. */ 742 /* */ 743 /* face :: The current face object. */ 744 /* */ 745 /* glyph :: The current glyph slot. */ 746 /* */ 747 /* loader :: XXX */ 748 /* */ 749 /* base :: The base glyph outline. */ 750 /* */ 751 /* current :: The current glyph outline. */ 752 /* */ 753 /* max_points :: maximum points in builder outline */ 754 /* */ 755 /* max_contours :: Maximum number of contours in builder outline. */ 756 /* */ 757 /* pos_x :: The horizontal translation (if composite glyph). */ 758 /* */ 759 /* pos_y :: The vertical translation (if composite glyph). */ 760 /* */ 761 /* left_bearing :: The left side bearing point. */ 762 /* */ 763 /* advance :: The horizontal advance vector. */ 764 /* */ 765 /* bbox :: Unused. */ 766 /* */ 767 /* parse_state :: An enumeration which controls the charstring */ 768 /* parsing state. */ 769 /* */ 770 /* load_points :: If this flag is not set, no points are loaded. */ 771 /* */ 772 /* no_recurse :: Set but not used. */ 773 /* */ 774 /* metrics_only :: A boolean indicating that we only want to compute */ 775 /* the metrics of a given glyph, not load all of its */ 776 /* points. */ 777 /* */ 778 /* funcs :: An array of function pointers for the builder. */ 779 /* */ 780 typedef struct T1_BuilderRec_ 781 { 782 FT_Memory memory; 783 FT_Face face; 784 FT_GlyphSlot glyph; 785 FT_GlyphLoader loader; 786 FT_Outline* base; 787 FT_Outline* current; 788 789 FT_Pos pos_x; 790 FT_Pos pos_y; 791 792 FT_Vector left_bearing; 793 FT_Vector advance; 794 795 FT_BBox bbox; /* bounding box */ 796 T1_ParseState parse_state; 797 FT_Bool load_points; 798 FT_Bool no_recurse; 799 800 FT_Bool metrics_only; 801 802 void* hints_funcs; /* hinter-specific */ 803 void* hints_globals; /* hinter-specific */ 804 805 T1_Builder_FuncsRec funcs; 806 807 } T1_BuilderRec; 808 809 810 /*************************************************************************/ 811 /*************************************************************************/ 812 /***** *****/ 813 /***** T1 DECODER *****/ 814 /***** *****/ 815 /*************************************************************************/ 816 /*************************************************************************/ 817 818 #if 0 819 820 /*************************************************************************/ 821 /* */ 822 /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ 823 /* calls during glyph loading. */ 824 /* */ 825 #define T1_MAX_SUBRS_CALLS 8 826 827 828 /*************************************************************************/ 829 /* */ 830 /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ 831 /* minimum of 16 is required. */ 832 /* */ 833 #define T1_MAX_CHARSTRINGS_OPERANDS 32 834 835 #endif /* 0 */ 836 837 838 typedef struct T1_Decoder_ZoneRec_ 839 { 840 FT_Byte* cursor; 841 FT_Byte* base; 842 FT_Byte* limit; 843 844 } T1_Decoder_ZoneRec, *T1_Decoder_Zone; 845 846 847 typedef struct T1_DecoderRec_* T1_Decoder; 848 typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs; 849 850 851 typedef FT_Error 852 (*T1_Decoder_Callback)( T1_Decoder decoder, 976 void 977 (*init)( CFF_Builder* builder, 978 TT_Face face, 979 CFF_Size size, 980 CFF_GlyphSlot glyph, 981 FT_Bool hinting ); 982 983 void 984 (*done)( CFF_Builder* builder ); 985 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; 992 993 } CFF_Builder_FuncsRec; 994 995 996 /*************************************************************************/ 997 /* */ 998 /* <Structure> */ 999 /* CFF_Builder */ 1000 /* */ 1001 /* <Description> */ 1002 /* A structure used during glyph loading to store its outline. */ 1003 /* */ 1004 /* <Fields> */ 1005 /* memory :: The current memory object. */ 1006 /* */ 1007 /* face :: The current face object. */ 1008 /* */ 1009 /* glyph :: The current glyph slot. */ 1010 /* */ 1011 /* loader :: The current glyph loader. */ 1012 /* */ 1013 /* base :: The base glyph outline. */ 1014 /* */ 1015 /* current :: The current glyph outline. */ 1016 /* */ 1017 /* pos_x :: The horizontal translation (if composite glyph). */ 1018 /* */ 1019 /* pos_y :: The vertical translation (if composite glyph). */ 1020 /* */ 1021 /* left_bearing :: The left side bearing point. */ 1022 /* */ 1023 /* advance :: The horizontal advance vector. */ 1024 /* */ 1025 /* bbox :: Unused. */ 1026 /* */ 1027 /* path_begun :: A flag which indicates that a new path has begun. */ 1028 /* */ 1029 /* load_points :: If this flag is not set, no points are loaded. */ 1030 /* */ 1031 /* no_recurse :: Set but not used. */ 1032 /* */ 1033 /* metrics_only :: A boolean indicating that we only want to compute */ 1034 /* the metrics of a given glyph, not load all of its */ 1035 /* points. */ 1036 /* */ 1037 /* hints_funcs :: Auxiliary pointer for hinting. */ 1038 /* */ 1039 /* hints_globals :: Auxiliary pointer for hinting. */ 1040 /* */ 1041 /* funcs :: A table of method pointers for this object. */ 1042 /* */ 1043 struct CFF_Builder_ 1044 { 1045 FT_Memory memory; 1046 TT_Face face; 1047 CFF_GlyphSlot glyph; 1048 FT_GlyphLoader loader; 1049 FT_Outline* base; 1050 FT_Outline* current; 1051 1052 FT_Pos pos_x; 1053 FT_Pos pos_y; 1054 1055 FT_Vector left_bearing; 1056 FT_Vector advance; 1057 1058 FT_BBox bbox; /* bounding box */ 1059 1060 FT_Bool path_begun; 1061 FT_Bool load_points; 1062 FT_Bool no_recurse; 1194 typedef struct AFM_Parser_FuncsRec_ 1195 { 1196 FT_Error 1197 (*init)( AFM_Parser parser, 1198 FT_Memory memory, 1199 FT_Byte* base, 1200 FT_Byte* limit ); 1201 1202 void 1203 (*done)( AFM_Parser parser ); 1204 1205 FT_Error 1206 (*parse)( AFM_Parser parser ); 1207 1208 } AFM_Parser_FuncsRec; 1209 1210 1211 typedef struct AFM_StreamRec_* AFM_Stream; 1212 1213 1214 /*************************************************************************/ 1215 /* */ 1216 /* <Struct> */ 1217 /* AFM_ParserRec */ 1218 /* */ 1219 /* <Description> */ 1220 /* An AFM_Parser is a parser for the AFM files. */ 1221 /* */ 1222 /* <Fields> */ 1223 /* memory :: The object used for memory operations (alloc and */ 1224 /* realloc). */ 1225 /* */ 1226 /* stream :: This is an opaque object. */ 1227 /* */ 1228 /* FontInfo :: The result will be stored here. */ 1229 /* */ 1230 /* get_index :: A user provided function to get a glyph index by its */ 1231 /* name. */ 1232 /* */ 1233 typedef struct AFM_ParserRec_ 1234 { 1235 FT_Memory memory; 1236 AFM_Stream stream; 1237 1238 AFM_FontInfo FontInfo; 1239 1240 FT_Int 1241 (*get_index)( const char* name, 1242 FT_Offset len, 1243 void* user_data ); 1244 1245 void* user_data; 1246 1247 } AFM_ParserRec; 1248 1249 1250 /*************************************************************************/ 1251 /*************************************************************************/ 1252 /***** *****/ | 1 /**************************************************************************** 2 * 3 * psaux.h 4 * 5 * Auxiliary functions and data structures related to PostScript fonts 6 * (specification). 7 * 8 * Copyright (C) 1996-2019 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 a 117 * single memory block. 118 * 119 * @fields: 120 * block :: 121 * The address in memory of the growheap's block. This can change 122 * between two object adds, due to reallocation. 123 * 124 * cursor :: 125 * The current top of the grow heap within its block. 126 * 127 * capacity :: 128 * The current size of the heap block. Increments by 1kByte chunks. 129 * 130 * init :: 131 * Set to 0xDEADBEEF if 'elements' and 'lengths' have been allocated. 132 * 133 * max_elems :: 134 * The maximum number of elements in table. 135 * 136 * num_elems :: 137 * The current number of elements in table. 138 * 139 * elements :: 140 * A table of element addresses within the block. 141 * 142 * lengths :: 143 * A table of element sizes within the block. 144 * 145 * memory :: 146 * The object used for memory operations (alloc/realloc). 147 * 148 * funcs :: 149 * A table of method pointers for this object. 150 */ 151 typedef struct PS_TableRec_ 152 { 153 FT_Byte* block; /* current memory block */ 154 FT_Offset cursor; /* current cursor in memory block */ 155 FT_Offset capacity; /* current size of memory block */ 156 FT_ULong init; 157 158 FT_Int max_elems; 159 FT_Int num_elems; 160 FT_Byte** elements; /* addresses of table elements */ 161 FT_UInt* lengths; /* lengths of table elements */ 162 163 FT_Memory memory; 164 PS_Table_FuncsRec funcs; 165 166 } PS_TableRec; 167 168 169 /*************************************************************************/ 170 /*************************************************************************/ 418 FT_UInt max_tokens, 419 FT_Int* pnum_tokens ); 420 421 FT_Error 422 (*load_field)( PS_Parser parser, 423 const T1_Field field, 424 void** objects, 425 FT_UInt max_objects, 426 FT_ULong* pflags ); 427 428 FT_Error 429 (*load_field_table)( PS_Parser parser, 430 const T1_Field field, 431 void** objects, 432 FT_UInt max_objects, 433 FT_ULong* pflags ); 434 435 } PS_Parser_FuncsRec; 436 437 438 /************************************************************************** 439 * 440 * @struct: 441 * PS_ParserRec 442 * 443 * @description: 444 * A PS_Parser is an object used to parse a Type 1 font very quickly. 445 * 446 * @fields: 447 * cursor :: 448 * The current position in the text. 449 * 450 * base :: 451 * Start of the processed text. 452 * 453 * limit :: 454 * End of the processed text. 455 * 456 * error :: 457 * The last error returned. 458 * 459 * memory :: 460 * The object used for memory operations (alloc/realloc). 461 * 462 * funcs :: 463 * A table of functions for the parser. 464 */ 465 typedef struct PS_ParserRec_ 466 { 467 FT_Byte* cursor; 468 FT_Byte* base; 469 FT_Byte* limit; 470 FT_Error error; 471 FT_Memory memory; 472 473 PS_Parser_FuncsRec funcs; 474 475 } PS_ParserRec; 476 477 478 /*************************************************************************/ 479 /*************************************************************************/ 480 /***** *****/ 481 /***** PS BUILDER *****/ 482 /***** *****/ 483 /*************************************************************************/ 484 /*************************************************************************/ 485 486 487 typedef struct PS_Builder_ PS_Builder; 488 typedef const struct PS_Builder_FuncsRec_* PS_Builder_Funcs; 489 490 typedef struct PS_Builder_FuncsRec_ 491 { 492 void 493 (*init)( PS_Builder* ps_builder, 494 void* builder, 495 FT_Bool is_t1 ); 496 497 void 498 (*done)( PS_Builder* builder ); 499 500 } PS_Builder_FuncsRec; 501 502 503 /************************************************************************** 504 * 505 * @struct: 506 * PS_Builder 507 * 508 * @description: 509 * A structure used during glyph loading to store its outline. 510 * 511 * @fields: 512 * memory :: 513 * The current memory object. 514 * 515 * face :: 516 * The current face object. 517 * 518 * glyph :: 519 * The current glyph slot. 520 * 521 * loader :: 522 * XXX 523 * 524 * base :: 525 * The base glyph outline. 526 * 527 * current :: 528 * The current glyph outline. 529 * 530 * pos_x :: 531 * The horizontal translation (if composite glyph). 532 * 533 * pos_y :: 534 * The vertical translation (if composite glyph). 535 * 536 * left_bearing :: 537 * The left side bearing point. 538 * 539 * advance :: 540 * The horizontal advance vector. 541 * 542 * bbox :: 543 * Unused. 544 * 545 * path_begun :: 546 * A flag which indicates that a new path has begun. 547 * 548 * load_points :: 549 * If this flag is not set, no points are loaded. 550 * 551 * no_recurse :: 552 * Set but not used. 553 * 554 * metrics_only :: 555 * A boolean indicating that we only want to compute the metrics of a 556 * given glyph, not load all of its points. 557 * 558 * is_t1 :: 559 * Set if current font type is Type 1. 560 * 561 * funcs :: 562 * An array of function pointers for the builder. 563 */ 564 struct PS_Builder_ 565 { 566 FT_Memory memory; 567 FT_Face face; 568 CFF_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 FT_Bool path_begun; 581 FT_Bool load_points; 582 FT_Bool no_recurse; 583 744 T1_Builder_Add_Point_Func add_point; 745 T1_Builder_Add_Point1_Func add_point1; 746 T1_Builder_Add_Contour_Func add_contour; 747 T1_Builder_Start_Point_Func start_point; 748 T1_Builder_Close_Contour_Func close_contour; 749 750 } T1_Builder_FuncsRec; 751 752 753 /* an enumeration type to handle charstring parsing states */ 754 typedef enum T1_ParseState_ 755 { 756 T1_Parse_Start, 757 T1_Parse_Have_Width, 758 T1_Parse_Have_Moveto, 759 T1_Parse_Have_Path 760 761 } T1_ParseState; 762 763 764 /************************************************************************** 765 * 766 * @struct: 767 * T1_BuilderRec 768 * 769 * @description: 770 * A structure used during glyph loading to store its outline. 771 * 772 * @fields: 773 * memory :: 774 * The current memory object. 775 * 776 * face :: 777 * The current face object. 778 * 779 * glyph :: 780 * The current glyph slot. 781 * 782 * loader :: 783 * XXX 784 * 785 * base :: 786 * The base glyph outline. 787 * 788 * current :: 789 * The current glyph outline. 790 * 791 * max_points :: 792 * maximum points in builder outline 793 * 794 * max_contours :: 795 * Maximum number of contours in builder outline. 796 * 797 * pos_x :: 798 * The horizontal translation (if composite glyph). 799 * 800 * pos_y :: 801 * The vertical translation (if composite glyph). 802 * 803 * left_bearing :: 804 * The left side bearing point. 805 * 806 * advance :: 807 * The horizontal advance vector. 808 * 809 * bbox :: 810 * Unused. 811 * 812 * parse_state :: 813 * An enumeration which controls the charstring parsing state. 814 * 815 * load_points :: 816 * If this flag is not set, no points are loaded. 817 * 818 * no_recurse :: 819 * Set but not used. 820 * 821 * metrics_only :: 822 * A boolean indicating that we only want to compute the metrics of a 823 * given glyph, not load all of its points. 824 * 825 * funcs :: 826 * An array of function pointers for the builder. 827 */ 828 typedef struct T1_BuilderRec_ 829 { 830 FT_Memory memory; 831 FT_Face face; 832 FT_GlyphSlot glyph; 833 FT_GlyphLoader loader; 834 FT_Outline* base; 835 FT_Outline* current; 836 837 FT_Pos pos_x; 838 FT_Pos pos_y; 839 840 FT_Vector left_bearing; 841 FT_Vector advance; 842 843 FT_BBox bbox; /* bounding box */ 844 T1_ParseState parse_state; 845 FT_Bool load_points; 846 FT_Bool no_recurse; 847 848 FT_Bool metrics_only; 849 850 void* hints_funcs; /* hinter-specific */ 851 void* hints_globals; /* hinter-specific */ 852 853 T1_Builder_FuncsRec funcs; 854 855 } T1_BuilderRec; 856 857 858 /*************************************************************************/ 859 /*************************************************************************/ 860 /***** *****/ 861 /***** T1 DECODER *****/ 862 /***** *****/ 863 /*************************************************************************/ 864 /*************************************************************************/ 865 866 #if 0 867 868 /************************************************************************** 869 * 870 * T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine 871 * calls during glyph loading. 872 */ 873 #define T1_MAX_SUBRS_CALLS 8 874 875 876 /************************************************************************** 877 * 878 * T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A 879 * minimum of 16 is required. 880 */ 881 #define T1_MAX_CHARSTRINGS_OPERANDS 32 882 883 #endif /* 0 */ 884 885 886 typedef struct T1_Decoder_ZoneRec_ 887 { 888 FT_Byte* cursor; 889 FT_Byte* base; 890 FT_Byte* limit; 891 892 } T1_Decoder_ZoneRec, *T1_Decoder_Zone; 893 894 895 typedef struct T1_DecoderRec_* T1_Decoder; 896 typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs; 897 898 899 typedef FT_Error 900 (*T1_Decoder_Callback)( T1_Decoder decoder, 1024 void 1025 (*init)( CFF_Builder* builder, 1026 TT_Face face, 1027 CFF_Size size, 1028 CFF_GlyphSlot glyph, 1029 FT_Bool hinting ); 1030 1031 void 1032 (*done)( CFF_Builder* builder ); 1033 1034 CFF_Builder_Check_Points_Func check_points; 1035 CFF_Builder_Add_Point_Func add_point; 1036 CFF_Builder_Add_Point1_Func add_point1; 1037 CFF_Builder_Add_Contour_Func add_contour; 1038 CFF_Builder_Start_Point_Func start_point; 1039 CFF_Builder_Close_Contour_Func close_contour; 1040 1041 } CFF_Builder_FuncsRec; 1042 1043 1044 /************************************************************************** 1045 * 1046 * @struct: 1047 * CFF_Builder 1048 * 1049 * @description: 1050 * A structure used during glyph loading to store its outline. 1051 * 1052 * @fields: 1053 * memory :: 1054 * The current memory object. 1055 * 1056 * face :: 1057 * The current face object. 1058 * 1059 * glyph :: 1060 * The current glyph slot. 1061 * 1062 * loader :: 1063 * The current glyph loader. 1064 * 1065 * base :: 1066 * The base glyph outline. 1067 * 1068 * current :: 1069 * The current glyph outline. 1070 * 1071 * pos_x :: 1072 * The horizontal translation (if composite glyph). 1073 * 1074 * pos_y :: 1075 * The vertical translation (if composite glyph). 1076 * 1077 * left_bearing :: 1078 * The left side bearing point. 1079 * 1080 * advance :: 1081 * The horizontal advance vector. 1082 * 1083 * bbox :: 1084 * Unused. 1085 * 1086 * path_begun :: 1087 * A flag which indicates that a new path has begun. 1088 * 1089 * load_points :: 1090 * If this flag is not set, no points are loaded. 1091 * 1092 * no_recurse :: 1093 * Set but not used. 1094 * 1095 * metrics_only :: 1096 * A boolean indicating that we only want to compute the metrics of a 1097 * given glyph, not load all of its points. 1098 * 1099 * hints_funcs :: 1100 * Auxiliary pointer for hinting. 1101 * 1102 * hints_globals :: 1103 * Auxiliary pointer for hinting. 1104 * 1105 * funcs :: 1106 * A table of method pointers for this object. 1107 */ 1108 struct CFF_Builder_ 1109 { 1110 FT_Memory memory; 1111 TT_Face face; 1112 CFF_GlyphSlot glyph; 1113 FT_GlyphLoader loader; 1114 FT_Outline* base; 1115 FT_Outline* current; 1116 1117 FT_Pos pos_x; 1118 FT_Pos pos_y; 1119 1120 FT_Vector left_bearing; 1121 FT_Vector advance; 1122 1123 FT_BBox bbox; /* bounding box */ 1124 1125 FT_Bool path_begun; 1126 FT_Bool load_points; 1127 FT_Bool no_recurse; 1259 typedef struct AFM_Parser_FuncsRec_ 1260 { 1261 FT_Error 1262 (*init)( AFM_Parser parser, 1263 FT_Memory memory, 1264 FT_Byte* base, 1265 FT_Byte* limit ); 1266 1267 void 1268 (*done)( AFM_Parser parser ); 1269 1270 FT_Error 1271 (*parse)( AFM_Parser parser ); 1272 1273 } AFM_Parser_FuncsRec; 1274 1275 1276 typedef struct AFM_StreamRec_* AFM_Stream; 1277 1278 1279 /************************************************************************** 1280 * 1281 * @struct: 1282 * AFM_ParserRec 1283 * 1284 * @description: 1285 * An AFM_Parser is a parser for the AFM files. 1286 * 1287 * @fields: 1288 * memory :: 1289 * The object used for memory operations (alloc and realloc). 1290 * 1291 * stream :: 1292 * This is an opaque object. 1293 * 1294 * FontInfo :: 1295 * The result will be stored here. 1296 * 1297 * get_index :: 1298 * A user provided function to get a glyph index by its name. 1299 */ 1300 typedef struct AFM_ParserRec_ 1301 { 1302 FT_Memory memory; 1303 AFM_Stream stream; 1304 1305 AFM_FontInfo FontInfo; 1306 1307 FT_Int 1308 (*get_index)( const char* name, 1309 FT_Offset len, 1310 void* user_data ); 1311 1312 void* user_data; 1313 1314 } AFM_ParserRec; 1315 1316 1317 /*************************************************************************/ 1318 /*************************************************************************/ 1319 /***** *****/ |