1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* psaux.h */ |
3 * psaux.h |
4 /* */ |
4 * |
5 /* Auxiliary functions and data structures related to PostScript fonts */ |
5 * Auxiliary functions and data structures related to PostScript fonts |
6 /* (specification). */ |
6 * (specification). |
7 /* */ |
7 * |
8 /* Copyright 1996-2018 by */ |
8 * Copyright (C) 1996-2019 by |
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 * David Turner, Robert Wilhelm, and Werner Lemberg. |
10 /* */ |
10 * |
11 /* This file is part of the FreeType project, and may only be used, */ |
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 */ |
12 * modified, and distributed under the terms of the FreeType project |
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
14 /* this file you indicate that you have read the license and */ |
14 * this file you indicate that you have read the license and |
15 /* understand and accept it fully. */ |
15 * understand and accept it fully. |
16 /* */ |
16 * |
17 /***************************************************************************/ |
17 */ |
18 |
18 |
19 |
19 |
20 #ifndef PSAUX_H_ |
20 #ifndef PSAUX_H_ |
21 #define PSAUX_H_ |
21 #define PSAUX_H_ |
22 |
22 |
62 |
62 |
63 typedef struct PS_TableRec_* PS_Table; |
63 typedef struct PS_TableRec_* PS_Table; |
64 typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs; |
64 typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs; |
65 |
65 |
66 |
66 |
67 /*************************************************************************/ |
67 /************************************************************************** |
68 /* */ |
68 * |
69 /* <Struct> */ |
69 * @struct: |
70 /* PS_Table_FuncsRec */ |
70 * PS_Table_FuncsRec |
71 /* */ |
71 * |
72 /* <Description> */ |
72 * @description: |
73 /* A set of function pointers to manage PS_Table objects. */ |
73 * A set of function pointers to manage PS_Table objects. |
74 /* */ |
74 * |
75 /* <Fields> */ |
75 * @fields: |
76 /* table_init :: Used to initialize a table. */ |
76 * table_init :: |
77 /* */ |
77 * Used to initialize a table. |
78 /* table_done :: Finalizes resp. destroy a given table. */ |
78 * |
79 /* */ |
79 * table_done :: |
80 /* table_add :: Adds a new object to a table. */ |
80 * Finalizes resp. destroy a given table. |
81 /* */ |
81 * |
82 /* table_release :: Releases table data, then finalizes it. */ |
82 * table_add :: |
83 /* */ |
83 * Adds a new object to a table. |
|
84 * |
|
85 * table_release :: |
|
86 * Releases table data, then finalizes it. |
|
87 */ |
84 typedef struct PS_Table_FuncsRec_ |
88 typedef struct PS_Table_FuncsRec_ |
85 { |
89 { |
86 FT_Error |
90 FT_Error |
87 (*init)( PS_Table table, |
91 (*init)( PS_Table table, |
88 FT_Int count, |
92 FT_Int count, |
101 (*release)( PS_Table table ); |
105 (*release)( PS_Table table ); |
102 |
106 |
103 } PS_Table_FuncsRec; |
107 } PS_Table_FuncsRec; |
104 |
108 |
105 |
109 |
106 /*************************************************************************/ |
110 /************************************************************************** |
107 /* */ |
111 * |
108 /* <Struct> */ |
112 * @struct: |
109 /* PS_TableRec */ |
113 * PS_TableRec |
110 /* */ |
114 * |
111 /* <Description> */ |
115 * @description: |
112 /* A PS_Table is a simple object used to store an array of objects in */ |
116 * A PS_Table is a simple object used to store an array of objects in a |
113 /* a single memory block. */ |
117 * single memory block. |
114 /* */ |
118 * |
115 /* <Fields> */ |
119 * @fields: |
116 /* block :: The address in memory of the growheap's block. This */ |
120 * block :: |
117 /* can change between two object adds, due to */ |
121 * The address in memory of the growheap's block. This can change |
118 /* reallocation. */ |
122 * between two object adds, due to reallocation. |
119 /* */ |
123 * |
120 /* cursor :: The current top of the grow heap within its block. */ |
124 * cursor :: |
121 /* */ |
125 * The current top of the grow heap within its block. |
122 /* capacity :: The current size of the heap block. Increments by */ |
126 * |
123 /* 1kByte chunks. */ |
127 * capacity :: |
124 /* */ |
128 * The current size of the heap block. Increments by 1kByte chunks. |
125 /* init :: Set to 0xDEADBEEF if `elements' and `lengths' have */ |
129 * |
126 /* been allocated. */ |
130 * init :: |
127 /* */ |
131 * Set to 0xDEADBEEF if 'elements' and 'lengths' have been allocated. |
128 /* max_elems :: The maximum number of elements in table. */ |
132 * |
129 /* */ |
133 * max_elems :: |
130 /* num_elems :: The current number of elements in table. */ |
134 * The maximum number of elements in table. |
131 /* */ |
135 * |
132 /* elements :: A table of element addresses within the block. */ |
136 * num_elems :: |
133 /* */ |
137 * The current number of elements in table. |
134 /* lengths :: A table of element sizes within the block. */ |
138 * |
135 /* */ |
139 * elements :: |
136 /* memory :: The object used for memory operations */ |
140 * A table of element addresses within the block. |
137 /* (alloc/realloc). */ |
141 * |
138 /* */ |
142 * lengths :: |
139 /* funcs :: A table of method pointers for this object. */ |
143 * A table of element sizes within the block. |
140 /* */ |
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 */ |
141 typedef struct PS_TableRec_ |
151 typedef struct PS_TableRec_ |
142 { |
152 { |
143 FT_Byte* block; /* current memory block */ |
153 FT_Byte* block; /* current memory block */ |
144 FT_Offset cursor; /* current cursor in memory block */ |
154 FT_Offset cursor; /* current cursor in memory block */ |
145 FT_Offset capacity; /* current size of memory block */ |
155 FT_Offset capacity; /* current size of memory block */ |
423 FT_ULong* pflags ); |
433 FT_ULong* pflags ); |
424 |
434 |
425 } PS_Parser_FuncsRec; |
435 } PS_Parser_FuncsRec; |
426 |
436 |
427 |
437 |
428 /*************************************************************************/ |
438 /************************************************************************** |
429 /* */ |
439 * |
430 /* <Struct> */ |
440 * @struct: |
431 /* PS_ParserRec */ |
441 * PS_ParserRec |
432 /* */ |
442 * |
433 /* <Description> */ |
443 * @description: |
434 /* A PS_Parser is an object used to parse a Type 1 font very quickly. */ |
444 * A PS_Parser is an object used to parse a Type 1 font very quickly. |
435 /* */ |
445 * |
436 /* <Fields> */ |
446 * @fields: |
437 /* cursor :: The current position in the text. */ |
447 * cursor :: |
438 /* */ |
448 * The current position in the text. |
439 /* base :: Start of the processed text. */ |
449 * |
440 /* */ |
450 * base :: |
441 /* limit :: End of the processed text. */ |
451 * Start of the processed text. |
442 /* */ |
452 * |
443 /* error :: The last error returned. */ |
453 * limit :: |
444 /* */ |
454 * End of the processed text. |
445 /* memory :: The object used for memory operations (alloc/realloc). */ |
455 * |
446 /* */ |
456 * error :: |
447 /* funcs :: A table of functions for the parser. */ |
457 * The last error returned. |
448 /* */ |
458 * |
|
459 * memory :: |
|
460 * The object used for memory operations (alloc/realloc). |
|
461 * |
|
462 * funcs :: |
|
463 * A table of functions for the parser. |
|
464 */ |
449 typedef struct PS_ParserRec_ |
465 typedef struct PS_ParserRec_ |
450 { |
466 { |
451 FT_Byte* cursor; |
467 FT_Byte* cursor; |
452 FT_Byte* base; |
468 FT_Byte* base; |
453 FT_Byte* limit; |
469 FT_Byte* limit; |
482 (*done)( PS_Builder* builder ); |
498 (*done)( PS_Builder* builder ); |
483 |
499 |
484 } PS_Builder_FuncsRec; |
500 } PS_Builder_FuncsRec; |
485 |
501 |
486 |
502 |
487 /*************************************************************************/ |
503 /************************************************************************** |
488 /* */ |
504 * |
489 /* <Structure> */ |
505 * @struct: |
490 /* PS_Builder */ |
506 * PS_Builder |
491 /* */ |
507 * |
492 /* <Description> */ |
508 * @description: |
493 /* A structure used during glyph loading to store its outline. */ |
509 * A structure used during glyph loading to store its outline. |
494 /* */ |
510 * |
495 /* <Fields> */ |
511 * @fields: |
496 /* memory :: The current memory object. */ |
512 * memory :: |
497 /* */ |
513 * The current memory object. |
498 /* face :: The current face object. */ |
514 * |
499 /* */ |
515 * face :: |
500 /* glyph :: The current glyph slot. */ |
516 * The current face object. |
501 /* */ |
517 * |
502 /* loader :: XXX */ |
518 * glyph :: |
503 /* */ |
519 * The current glyph slot. |
504 /* base :: The base glyph outline. */ |
520 * |
505 /* */ |
521 * loader :: |
506 /* current :: The current glyph outline. */ |
522 * XXX |
507 /* */ |
523 * |
508 /* pos_x :: The horizontal translation (if composite glyph). */ |
524 * base :: |
509 /* */ |
525 * The base glyph outline. |
510 /* pos_y :: The vertical translation (if composite glyph). */ |
526 * |
511 /* */ |
527 * current :: |
512 /* left_bearing :: The left side bearing point. */ |
528 * The current glyph outline. |
513 /* */ |
529 * |
514 /* advance :: The horizontal advance vector. */ |
530 * pos_x :: |
515 /* */ |
531 * The horizontal translation (if composite glyph). |
516 /* bbox :: Unused. */ |
532 * |
517 /* */ |
533 * pos_y :: |
518 /* path_begun :: A flag which indicates that a new path has begun. */ |
534 * The vertical translation (if composite glyph). |
519 /* */ |
535 * |
520 /* load_points :: If this flag is not set, no points are loaded. */ |
536 * left_bearing :: |
521 /* */ |
537 * The left side bearing point. |
522 /* no_recurse :: Set but not used. */ |
538 * |
523 /* */ |
539 * advance :: |
524 /* metrics_only :: A boolean indicating that we only want to compute */ |
540 * The horizontal advance vector. |
525 /* the metrics of a given glyph, not load all of its */ |
541 * |
526 /* points. */ |
542 * bbox :: |
527 /* */ |
543 * Unused. |
528 /* is_t1 :: Set if current font type is Type 1. */ |
544 * |
529 /* */ |
545 * path_begun :: |
530 /* funcs :: An array of function pointers for the builder. */ |
546 * A flag which indicates that a new path has begun. |
531 /* */ |
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 */ |
532 struct PS_Builder_ |
564 struct PS_Builder_ |
533 { |
565 { |
534 FT_Memory memory; |
566 FT_Memory memory; |
535 FT_Face face; |
567 FT_Face face; |
536 CFF_GlyphSlot glyph; |
568 CFF_GlyphSlot glyph; |
727 T1_Parse_Have_Path |
759 T1_Parse_Have_Path |
728 |
760 |
729 } T1_ParseState; |
761 } T1_ParseState; |
730 |
762 |
731 |
763 |
732 /*************************************************************************/ |
764 /************************************************************************** |
733 /* */ |
765 * |
734 /* <Structure> */ |
766 * @struct: |
735 /* T1_BuilderRec */ |
767 * T1_BuilderRec |
736 /* */ |
768 * |
737 /* <Description> */ |
769 * @description: |
738 /* A structure used during glyph loading to store its outline. */ |
770 * A structure used during glyph loading to store its outline. |
739 /* */ |
771 * |
740 /* <Fields> */ |
772 * @fields: |
741 /* memory :: The current memory object. */ |
773 * memory :: |
742 /* */ |
774 * The current memory object. |
743 /* face :: The current face object. */ |
775 * |
744 /* */ |
776 * face :: |
745 /* glyph :: The current glyph slot. */ |
777 * The current face object. |
746 /* */ |
778 * |
747 /* loader :: XXX */ |
779 * glyph :: |
748 /* */ |
780 * The current glyph slot. |
749 /* base :: The base glyph outline. */ |
781 * |
750 /* */ |
782 * loader :: |
751 /* current :: The current glyph outline. */ |
783 * XXX |
752 /* */ |
784 * |
753 /* max_points :: maximum points in builder outline */ |
785 * base :: |
754 /* */ |
786 * The base glyph outline. |
755 /* max_contours :: Maximum number of contours in builder outline. */ |
787 * |
756 /* */ |
788 * current :: |
757 /* pos_x :: The horizontal translation (if composite glyph). */ |
789 * The current glyph outline. |
758 /* */ |
790 * |
759 /* pos_y :: The vertical translation (if composite glyph). */ |
791 * max_points :: |
760 /* */ |
792 * maximum points in builder outline |
761 /* left_bearing :: The left side bearing point. */ |
793 * |
762 /* */ |
794 * max_contours :: |
763 /* advance :: The horizontal advance vector. */ |
795 * Maximum number of contours in builder outline. |
764 /* */ |
796 * |
765 /* bbox :: Unused. */ |
797 * pos_x :: |
766 /* */ |
798 * The horizontal translation (if composite glyph). |
767 /* parse_state :: An enumeration which controls the charstring */ |
799 * |
768 /* parsing state. */ |
800 * pos_y :: |
769 /* */ |
801 * The vertical translation (if composite glyph). |
770 /* load_points :: If this flag is not set, no points are loaded. */ |
802 * |
771 /* */ |
803 * left_bearing :: |
772 /* no_recurse :: Set but not used. */ |
804 * The left side bearing point. |
773 /* */ |
805 * |
774 /* metrics_only :: A boolean indicating that we only want to compute */ |
806 * advance :: |
775 /* the metrics of a given glyph, not load all of its */ |
807 * The horizontal advance vector. |
776 /* points. */ |
808 * |
777 /* */ |
809 * bbox :: |
778 /* funcs :: An array of function pointers for the builder. */ |
810 * Unused. |
779 /* */ |
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 */ |
780 typedef struct T1_BuilderRec_ |
828 typedef struct T1_BuilderRec_ |
781 { |
829 { |
782 FT_Memory memory; |
830 FT_Memory memory; |
783 FT_Face face; |
831 FT_Face face; |
784 FT_GlyphSlot glyph; |
832 FT_GlyphSlot glyph; |
815 /*************************************************************************/ |
863 /*************************************************************************/ |
816 /*************************************************************************/ |
864 /*************************************************************************/ |
817 |
865 |
818 #if 0 |
866 #if 0 |
819 |
867 |
820 /*************************************************************************/ |
868 /************************************************************************** |
821 /* */ |
869 * |
822 /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ |
870 * T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine |
823 /* calls during glyph loading. */ |
871 * calls during glyph loading. |
824 /* */ |
872 */ |
825 #define T1_MAX_SUBRS_CALLS 8 |
873 #define T1_MAX_SUBRS_CALLS 8 |
826 |
874 |
827 |
875 |
828 /*************************************************************************/ |
876 /************************************************************************** |
829 /* */ |
877 * |
830 /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ |
878 * T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A |
831 /* minimum of 16 is required. */ |
879 * minimum of 16 is required. |
832 /* */ |
880 */ |
833 #define T1_MAX_CHARSTRINGS_OPERANDS 32 |
881 #define T1_MAX_CHARSTRINGS_OPERANDS 32 |
834 |
882 |
835 #endif /* 0 */ |
883 #endif /* 0 */ |
836 |
884 |
837 |
885 |
991 CFF_Builder_Close_Contour_Func close_contour; |
1039 CFF_Builder_Close_Contour_Func close_contour; |
992 |
1040 |
993 } CFF_Builder_FuncsRec; |
1041 } CFF_Builder_FuncsRec; |
994 |
1042 |
995 |
1043 |
996 /*************************************************************************/ |
1044 /************************************************************************** |
997 /* */ |
1045 * |
998 /* <Structure> */ |
1046 * @struct: |
999 /* CFF_Builder */ |
1047 * CFF_Builder |
1000 /* */ |
1048 * |
1001 /* <Description> */ |
1049 * @description: |
1002 /* A structure used during glyph loading to store its outline. */ |
1050 * A structure used during glyph loading to store its outline. |
1003 /* */ |
1051 * |
1004 /* <Fields> */ |
1052 * @fields: |
1005 /* memory :: The current memory object. */ |
1053 * memory :: |
1006 /* */ |
1054 * The current memory object. |
1007 /* face :: The current face object. */ |
1055 * |
1008 /* */ |
1056 * face :: |
1009 /* glyph :: The current glyph slot. */ |
1057 * The current face object. |
1010 /* */ |
1058 * |
1011 /* loader :: The current glyph loader. */ |
1059 * glyph :: |
1012 /* */ |
1060 * The current glyph slot. |
1013 /* base :: The base glyph outline. */ |
1061 * |
1014 /* */ |
1062 * loader :: |
1015 /* current :: The current glyph outline. */ |
1063 * The current glyph loader. |
1016 /* */ |
1064 * |
1017 /* pos_x :: The horizontal translation (if composite glyph). */ |
1065 * base :: |
1018 /* */ |
1066 * The base glyph outline. |
1019 /* pos_y :: The vertical translation (if composite glyph). */ |
1067 * |
1020 /* */ |
1068 * current :: |
1021 /* left_bearing :: The left side bearing point. */ |
1069 * The current glyph outline. |
1022 /* */ |
1070 * |
1023 /* advance :: The horizontal advance vector. */ |
1071 * pos_x :: |
1024 /* */ |
1072 * The horizontal translation (if composite glyph). |
1025 /* bbox :: Unused. */ |
1073 * |
1026 /* */ |
1074 * pos_y :: |
1027 /* path_begun :: A flag which indicates that a new path has begun. */ |
1075 * The vertical translation (if composite glyph). |
1028 /* */ |
1076 * |
1029 /* load_points :: If this flag is not set, no points are loaded. */ |
1077 * left_bearing :: |
1030 /* */ |
1078 * The left side bearing point. |
1031 /* no_recurse :: Set but not used. */ |
1079 * |
1032 /* */ |
1080 * advance :: |
1033 /* metrics_only :: A boolean indicating that we only want to compute */ |
1081 * The horizontal advance vector. |
1034 /* the metrics of a given glyph, not load all of its */ |
1082 * |
1035 /* points. */ |
1083 * bbox :: |
1036 /* */ |
1084 * Unused. |
1037 /* hints_funcs :: Auxiliary pointer for hinting. */ |
1085 * |
1038 /* */ |
1086 * path_begun :: |
1039 /* hints_globals :: Auxiliary pointer for hinting. */ |
1087 * A flag which indicates that a new path has begun. |
1040 /* */ |
1088 * |
1041 /* funcs :: A table of method pointers for this object. */ |
1089 * load_points :: |
1042 /* */ |
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 */ |
1043 struct CFF_Builder_ |
1108 struct CFF_Builder_ |
1044 { |
1109 { |
1045 FT_Memory memory; |
1110 FT_Memory memory; |
1046 TT_Face face; |
1111 TT_Face face; |
1047 CFF_GlyphSlot glyph; |
1112 CFF_GlyphSlot glyph; |
1209 |
1274 |
1210 |
1275 |
1211 typedef struct AFM_StreamRec_* AFM_Stream; |
1276 typedef struct AFM_StreamRec_* AFM_Stream; |
1212 |
1277 |
1213 |
1278 |
1214 /*************************************************************************/ |
1279 /************************************************************************** |
1215 /* */ |
1280 * |
1216 /* <Struct> */ |
1281 * @struct: |
1217 /* AFM_ParserRec */ |
1282 * AFM_ParserRec |
1218 /* */ |
1283 * |
1219 /* <Description> */ |
1284 * @description: |
1220 /* An AFM_Parser is a parser for the AFM files. */ |
1285 * An AFM_Parser is a parser for the AFM files. |
1221 /* */ |
1286 * |
1222 /* <Fields> */ |
1287 * @fields: |
1223 /* memory :: The object used for memory operations (alloc and */ |
1288 * memory :: |
1224 /* realloc). */ |
1289 * The object used for memory operations (alloc and realloc). |
1225 /* */ |
1290 * |
1226 /* stream :: This is an opaque object. */ |
1291 * stream :: |
1227 /* */ |
1292 * This is an opaque object. |
1228 /* FontInfo :: The result will be stored here. */ |
1293 * |
1229 /* */ |
1294 * FontInfo :: |
1230 /* get_index :: A user provided function to get a glyph index by its */ |
1295 * The result will be stored here. |
1231 /* name. */ |
1296 * |
1232 /* */ |
1297 * get_index :: |
|
1298 * A user provided function to get a glyph index by its name. |
|
1299 */ |
1233 typedef struct AFM_ParserRec_ |
1300 typedef struct AFM_ParserRec_ |
1234 { |
1301 { |
1235 FT_Memory memory; |
1302 FT_Memory memory; |
1236 AFM_Stream stream; |
1303 AFM_Stream stream; |
1237 |
1304 |