1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* cffdrivr.c */ |
3 * cffdrivr.c |
4 /* */ |
4 * |
5 /* OpenType font driver implementation (body). */ |
5 * OpenType font driver implementation (body). |
6 /* */ |
6 * |
7 /* Copyright 1996-2018 by */ |
7 * Copyright (C) 1996-2019 by |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
8 * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 /* */ |
9 * |
10 /* This file is part of the FreeType project, and may only be used, */ |
10 * This file is part of the FreeType project, and may only be used, |
11 /* modified, and distributed under the terms of the FreeType project */ |
11 * modified, and distributed under the terms of the FreeType project |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
13 /* this file you indicate that you have read the license and */ |
13 * this file you indicate that you have read the license and |
14 /* understand and accept it fully. */ |
14 * understand and accept it fully. |
15 /* */ |
15 * |
16 /***************************************************************************/ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <ft2build.h> |
19 #include <ft2build.h> |
20 #include FT_FREETYPE_H |
20 #include FT_FREETYPE_H |
21 #include FT_INTERNAL_DEBUG_H |
21 #include FT_INTERNAL_DEBUG_H |
40 #include FT_SERVICE_MULTIPLE_MASTERS_H |
40 #include FT_SERVICE_MULTIPLE_MASTERS_H |
41 #include FT_SERVICE_METRICS_VARIATIONS_H |
41 #include FT_SERVICE_METRICS_VARIATIONS_H |
42 #endif |
42 #endif |
43 |
43 |
44 #include "cfferrs.h" |
44 #include "cfferrs.h" |
45 #include "cffpic.h" |
|
46 |
45 |
47 #include FT_SERVICE_FONT_FORMAT_H |
46 #include FT_SERVICE_FONT_FORMAT_H |
48 #include FT_SERVICE_GLYPH_DICT_H |
47 #include FT_SERVICE_GLYPH_DICT_H |
49 #include FT_SERVICE_PROPERTIES_H |
48 #include FT_SERVICE_PROPERTIES_H |
50 #include FT_DRIVER_H |
49 #include FT_DRIVER_H |
51 |
50 |
52 |
51 |
53 /*************************************************************************/ |
52 /************************************************************************** |
54 /* */ |
53 * |
55 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
54 * The macro FT_COMPONENT is used in trace mode. It is an implicit |
56 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
55 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log |
57 /* messages during execution. */ |
56 * messages during execution. |
58 /* */ |
57 */ |
59 #undef FT_COMPONENT |
58 #undef FT_COMPONENT |
60 #define FT_COMPONENT trace_cffdriver |
59 #define FT_COMPONENT cffdriver |
61 |
60 |
62 |
61 |
63 /*************************************************************************/ |
62 /*************************************************************************/ |
64 /*************************************************************************/ |
63 /*************************************************************************/ |
65 /*************************************************************************/ |
64 /*************************************************************************/ |
71 /*************************************************************************/ |
70 /*************************************************************************/ |
72 /*************************************************************************/ |
71 /*************************************************************************/ |
73 /*************************************************************************/ |
72 /*************************************************************************/ |
74 |
73 |
75 |
74 |
76 /*************************************************************************/ |
75 /************************************************************************** |
77 /* */ |
76 * |
78 /* <Function> */ |
77 * @Function: |
79 /* cff_get_kerning */ |
78 * cff_get_kerning |
80 /* */ |
79 * |
81 /* <Description> */ |
80 * @Description: |
82 /* A driver method used to return the kerning vector between two */ |
81 * A driver method used to return the kerning vector between two |
83 /* glyphs of the same face. */ |
82 * glyphs of the same face. |
84 /* */ |
83 * |
85 /* <Input> */ |
84 * @Input: |
86 /* face :: A handle to the source face object. */ |
85 * face :: |
87 /* */ |
86 * A handle to the source face object. |
88 /* left_glyph :: The index of the left glyph in the kern pair. */ |
87 * |
89 /* */ |
88 * left_glyph :: |
90 /* right_glyph :: The index of the right glyph in the kern pair. */ |
89 * The index of the left glyph in the kern pair. |
91 /* */ |
90 * |
92 /* <Output> */ |
91 * right_glyph :: |
93 /* kerning :: The kerning vector. This is in font units for */ |
92 * The index of the right glyph in the kern pair. |
94 /* scalable formats, and in pixels for fixed-sizes */ |
93 * |
95 /* formats. */ |
94 * @Output: |
96 /* */ |
95 * kerning :: |
97 /* <Return> */ |
96 * The kerning vector. This is in font units for |
98 /* FreeType error code. 0 means success. */ |
97 * scalable formats, and in pixels for fixed-sizes |
99 /* */ |
98 * formats. |
100 /* <Note> */ |
99 * |
101 /* Only horizontal layouts (left-to-right & right-to-left) are */ |
100 * @Return: |
102 /* supported by this function. Other layouts, or more sophisticated */ |
101 * FreeType error code. 0 means success. |
103 /* kernings, are out of scope of this method (the basic driver */ |
102 * |
104 /* interface is meant to be simple). */ |
103 * @Note: |
105 /* */ |
104 * Only horizontal layouts (left-to-right & right-to-left) are |
106 /* They can be implemented by format-specific interfaces. */ |
105 * supported by this function. Other layouts, or more sophisticated |
107 /* */ |
106 * kernings, are out of scope of this method (the basic driver |
|
107 * interface is meant to be simple). |
|
108 * |
|
109 * They can be implemented by format-specific interfaces. |
|
110 */ |
108 FT_CALLBACK_DEF( FT_Error ) |
111 FT_CALLBACK_DEF( FT_Error ) |
109 cff_get_kerning( FT_Face ttface, /* TT_Face */ |
112 cff_get_kerning( FT_Face ttface, /* TT_Face */ |
110 FT_UInt left_glyph, |
113 FT_UInt left_glyph, |
111 FT_UInt right_glyph, |
114 FT_UInt right_glyph, |
112 FT_Vector* kerning ) |
115 FT_Vector* kerning ) |
123 |
126 |
124 return FT_Err_Ok; |
127 return FT_Err_Ok; |
125 } |
128 } |
126 |
129 |
127 |
130 |
128 /*************************************************************************/ |
131 /************************************************************************** |
129 /* */ |
132 * |
130 /* <Function> */ |
133 * @Function: |
131 /* cff_glyph_load */ |
134 * cff_glyph_load |
132 /* */ |
135 * |
133 /* <Description> */ |
136 * @Description: |
134 /* A driver method used to load a glyph within a given glyph slot. */ |
137 * A driver method used to load a glyph within a given glyph slot. |
135 /* */ |
138 * |
136 /* <Input> */ |
139 * @Input: |
137 /* slot :: A handle to the target slot object where the glyph */ |
140 * slot :: |
138 /* will be loaded. */ |
141 * A handle to the target slot object where the glyph |
139 /* */ |
142 * will be loaded. |
140 /* size :: A handle to the source face size at which the glyph */ |
143 * |
141 /* must be scaled, loaded, etc. */ |
144 * size :: |
142 /* */ |
145 * A handle to the source face size at which the glyph |
143 /* glyph_index :: The index of the glyph in the font file. */ |
146 * must be scaled, loaded, etc. |
144 /* */ |
147 * |
145 /* load_flags :: A flag indicating what to load for this glyph. The */ |
148 * glyph_index :: |
146 /* FT_LOAD_??? constants can be used to control the */ |
149 * The index of the glyph in the font file. |
147 /* glyph loading process (e.g., whether the outline */ |
150 * |
148 /* should be scaled, whether to load bitmaps or not, */ |
151 * load_flags :: |
149 /* whether to hint the outline, etc). */ |
152 * A flag indicating what to load for this glyph. The |
150 /* */ |
153 * FT_LOAD_??? constants can be used to control the |
151 /* <Return> */ |
154 * glyph loading process (e.g., whether the outline |
152 /* FreeType error code. 0 means success. */ |
155 * should be scaled, whether to load bitmaps or not, |
153 /* */ |
156 * whether to hint the outline, etc). |
|
157 * |
|
158 * @Return: |
|
159 * FreeType error code. 0 means success. |
|
160 */ |
154 FT_CALLBACK_DEF( FT_Error ) |
161 FT_CALLBACK_DEF( FT_Error ) |
155 cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ |
162 cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ |
156 FT_Size cffsize, /* CFF_Size */ |
163 FT_Size cffsize, /* CFF_Size */ |
157 FT_UInt glyph_index, |
164 FT_UInt glyph_index, |
158 FT_Int32 load_flags ) |
165 FT_Int32 load_flags ) |
907 |
938 |
908 |
939 |
909 FT_DEFINE_SERVICE_MULTIMASTERSREC( |
940 FT_DEFINE_SERVICE_MULTIMASTERSREC( |
910 cff_service_multi_masters, |
941 cff_service_multi_masters, |
911 |
942 |
912 (FT_Get_MM_Func) NULL, /* get_mm */ |
943 (FT_Get_MM_Func) NULL, /* get_mm */ |
913 (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ |
944 (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ |
914 (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */ |
945 (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */ |
915 (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */ |
946 (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */ |
916 (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ |
947 (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ |
917 (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */ |
948 (FT_Set_Var_Design_Func) cff_set_var_design, /* set_var_design */ |
918 (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */ |
949 (FT_Get_Var_Design_Func) cff_get_var_design, /* get_var_design */ |
919 (FT_Set_Instance_Func) cff_set_instance, /* set_instance */ |
950 (FT_Set_Instance_Func) cff_set_instance, /* set_instance */ |
920 |
951 (FT_Set_MM_WeightVector_Func)cff_set_mm_weightvector, /* set_mm_weightvector */ |
921 (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ |
952 (FT_Get_MM_WeightVector_Func)cff_get_mm_weightvector, /* get_mm_weightvector */ |
922 (FT_Done_Blend_Func) cff_done_blend /* done_blend */ |
953 |
|
954 (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ |
|
955 (FT_Done_Blend_Func) cff_done_blend /* done_blend */ |
923 ) |
956 ) |
924 |
957 |
925 |
958 |
926 /* |
959 /* |
927 * METRICS VARIATIONS SERVICE |
960 * METRICS VARIATIONS SERVICE |
928 * |
961 * |
929 */ |
962 */ |
930 |
963 |
931 static FT_Error |
964 static FT_Error |
932 cff_hadvance_adjust( CFF_Face face, |
965 cff_hadvance_adjust( CFF_Face face, |
999 defined TT_CONFIG_OPTION_GX_VAR_SUPPORT |
1032 defined TT_CONFIG_OPTION_GX_VAR_SUPPORT |
1000 FT_DEFINE_SERVICEDESCREC10( |
1033 FT_DEFINE_SERVICEDESCREC10( |
1001 cff_services, |
1034 cff_services, |
1002 |
1035 |
1003 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
1036 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
1004 FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET, |
1037 FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters, |
1005 FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET, |
1038 FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_variations, |
1006 FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, |
1039 FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, |
1007 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, |
1040 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, |
1008 FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, |
1041 FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict, |
1009 FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, |
1042 FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, |
1010 FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, |
1043 FT_SERVICE_ID_CID, &cff_service_cid_info, |
1011 FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, |
1044 FT_SERVICE_ID_PROPERTIES, &cff_service_properties, |
1012 FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET |
1045 FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load |
1013 ) |
1046 ) |
1014 #elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES |
1047 #elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES |
1015 FT_DEFINE_SERVICEDESCREC8( |
1048 FT_DEFINE_SERVICEDESCREC8( |
1016 cff_services, |
1049 cff_services, |
1017 |
1050 |
1018 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
1051 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
1019 FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, |
1052 FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, |
1020 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, |
1053 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, |
1021 FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, |
1054 FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict, |
1022 FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, |
1055 FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, |
1023 FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, |
1056 FT_SERVICE_ID_CID, &cff_service_cid_info, |
1024 FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, |
1057 FT_SERVICE_ID_PROPERTIES, &cff_service_properties, |
1025 FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET |
1058 FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load |
1026 ) |
1059 ) |
1027 #elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT |
1060 #elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT |
1028 FT_DEFINE_SERVICEDESCREC9( |
1061 FT_DEFINE_SERVICEDESCREC9( |
1029 cff_services, |
1062 cff_services, |
1030 |
1063 |
1031 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
1064 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
1032 FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET, |
1065 FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters, |
1033 FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET, |
1066 FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_var, |
1034 FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, |
1067 FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, |
1035 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, |
1068 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, |
1036 FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, |
1069 FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, |
1037 FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, |
1070 FT_SERVICE_ID_CID, &cff_service_cid_info, |
1038 FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, |
1071 FT_SERVICE_ID_PROPERTIES, &cff_service_properties, |
1039 FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET |
1072 FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load |
1040 ) |
1073 ) |
1041 #else |
1074 #else |
1042 FT_DEFINE_SERVICEDESCREC7( |
1075 FT_DEFINE_SERVICEDESCREC7( |
1043 cff_services, |
1076 cff_services, |
1044 |
1077 |
1045 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
1078 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
1046 FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, |
1079 FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, |
1047 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, |
1080 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, |
1048 FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, |
1081 FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, |
1049 FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, |
1082 FT_SERVICE_ID_CID, &cff_service_cid_info, |
1050 FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, |
1083 FT_SERVICE_ID_PROPERTIES, &cff_service_properties, |
1051 FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET |
1084 FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load |
1052 ) |
1085 ) |
1053 #endif |
1086 #endif |
1054 |
1087 |
1055 |
1088 |
1056 FT_CALLBACK_DEF( FT_Module_Interface ) |
1089 FT_CALLBACK_DEF( FT_Module_Interface ) |