Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Side by Side Diff: src/autofit/afmodule.c

Issue 89753003: Update freetype to latest version of ASOP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/autofit/afmodule.h ('k') | src/autofit/afpic.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /***************************************************************************/ 1 /***************************************************************************/
2 /* */ 2 /* */
3 /* afmodule.c */ 3 /* afmodule.c */
4 /* */ 4 /* */
5 /* Auto-fitter module implementation (body). */ 5 /* Auto-fitter module implementation (body). */
6 /* */ 6 /* */
7 /* Copyright 2003-2006, 2009, 2011 by */ 7 /* Copyright 2003-2006, 2009, 2011-2013 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 "afglobal.h"
19 #include "afmodule.h" 20 #include "afmodule.h"
20 #include "afloader.h" 21 #include "afloader.h"
22 #include "aferrors.h"
21 #include "afpic.h" 23 #include "afpic.h"
22 24
23 #ifdef FT_DEBUG_AUTOFIT 25 #ifdef FT_DEBUG_AUTOFIT
24 int _af_debug_disable_horz_hints; 26 int _af_debug_disable_horz_hints;
25 int _af_debug_disable_vert_hints; 27 int _af_debug_disable_vert_hints;
26 int _af_debug_disable_blue_hints; 28 int _af_debug_disable_blue_hints;
27 void* _af_debug_hints; 29 void* _af_debug_hints;
28 #endif 30 #endif
29 31
30 #include FT_INTERNAL_OBJECTS_H 32 #include FT_INTERNAL_OBJECTS_H
31 33 #include FT_INTERNAL_DEBUG_H
32 34 #include FT_AUTOHINTER_H
33 typedef struct FT_AutofitterRec_ 35 #include FT_SERVICE_PROPERTIES_H
34 { 36
35 FT_ModuleRec root; 37
36 AF_LoaderRec loader[1]; 38 /*************************************************************************/
37 39 /* */
38 } FT_AutofitterRec, *FT_Autofitter; 40 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
41 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
42 /* messages during execution. */
43 /* */
44 #undef FT_COMPONENT
45 #define FT_COMPONENT trace_afmodule
46
47
48 FT_Error
49 af_property_get_face_globals( FT_Face face,
50 AF_FaceGlobals* aglobals,
51 AF_Module module )
52 {
53 FT_Error error = FT_Err_Ok;
54 AF_FaceGlobals globals;
55
56
57 if ( !face )
58 return FT_THROW( Invalid_Argument );
59
60 globals = (AF_FaceGlobals)face->autohint.data;
61 if ( !globals )
62 {
63 /* trigger computation of the global script data */
64 /* in case it hasn't been done yet */
65 error = af_face_globals_new( face, &globals, module );
66 if ( !error )
67 {
68 face->autohint.data =
69 (FT_Pointer)globals;
70 face->autohint.finalizer =
71 (FT_Generic_Finalizer)af_face_globals_free;
72 }
73 }
74
75 if ( !error )
76 *aglobals = globals;
77
78 return error;
79 }
80
81
82 FT_Error
83 af_property_set( FT_Module ft_module,
84 const char* property_name,
85 const void* value )
86 {
87 FT_Error error = FT_Err_Ok;
88 AF_Module module = (AF_Module)ft_module;
89
90
91 if ( !ft_strcmp( property_name, "fallback-script" ) )
92 {
93 FT_UInt* fallback_script = (FT_UInt*)value;
94
95
96 module->fallback_script = *fallback_script;
97
98 return error;
99 }
100 else if ( !ft_strcmp( property_name, "increase-x-height" ) )
101 {
102 FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
103 AF_FaceGlobals globals;
104
105
106 error = af_property_get_face_globals( prop->face, &globals, module );
107 if ( !error )
108 globals->increase_x_height = prop->limit;
109
110 return error;
111 }
112
113 FT_TRACE0(( "af_property_set: missing property `%s'\n",
114 property_name ));
115 return FT_THROW( Missing_Property );
116 }
117
118
119 FT_Error
120 af_property_get( FT_Module ft_module,
121 const char* property_name,
122 void* value )
123 {
124 FT_Error error = FT_Err_Ok;
125 AF_Module module = (AF_Module)ft_module;
126 FT_UInt fallback_script = module->fallback_script;
127
128
129 if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
130 {
131 FT_Prop_GlyphToScriptMap* prop = (FT_Prop_GlyphToScriptMap*)value;
132 AF_FaceGlobals globals;
133
134
135 error = af_property_get_face_globals( prop->face, &globals, module );
136 if ( !error )
137 prop->map = globals->glyph_scripts;
138
139 return error;
140 }
141 else if ( !ft_strcmp( property_name, "fallback-script" ) )
142 {
143 FT_UInt* val = (FT_UInt*)value;
144
145
146 *val = fallback_script;
147
148 return error;
149 }
150 else if ( !ft_strcmp( property_name, "increase-x-height" ) )
151 {
152 FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
153 AF_FaceGlobals globals;
154
155
156 error = af_property_get_face_globals( prop->face, &globals, module );
157 if ( !error )
158 prop->limit = globals->increase_x_height;
159
160 return error;
161 }
162
163
164 FT_TRACE0(( "af_property_get: missing property `%s'\n",
165 property_name ));
166 return FT_THROW( Missing_Property );
167 }
168
169
170 FT_DEFINE_SERVICE_PROPERTIESREC(
171 af_service_properties,
172 (FT_Properties_SetFunc)af_property_set,
173 (FT_Properties_GetFunc)af_property_get )
174
175
176 FT_DEFINE_SERVICEDESCREC1(
177 af_services,
178 FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET )
179
180
181 FT_CALLBACK_DEF( FT_Module_Interface )
182 af_get_interface( FT_Module module,
183 const char* module_interface )
184 {
185 /* AF_SERVICES_GET derefers `library' in PIC mode */
186 #ifdef FT_CONFIG_OPTION_PIC
187 FT_Library library;
188
189
190 if ( !module )
191 return NULL;
192 library = module->library;
193 if ( !library )
194 return NULL;
195 #else
196 FT_UNUSED( module );
197 #endif
198
199 return ft_service_list_lookup( AF_SERVICES_GET, module_interface );
200 }
39 201
40 202
41 FT_CALLBACK_DEF( FT_Error ) 203 FT_CALLBACK_DEF( FT_Error )
42 af_autofitter_init( FT_Autofitter module ) 204 af_autofitter_init( FT_Module ft_module ) /* AF_Module */
43 { 205 {
44 return af_loader_init( module->loader, module->root.library->memory ); 206 AF_Module module = (AF_Module)ft_module;
207
208
209 module->fallback_script = AF_SCRIPT_FALLBACK;
210
211 return af_loader_init( module );
45 } 212 }
46 213
47 214
48 FT_CALLBACK_DEF( void ) 215 FT_CALLBACK_DEF( void )
49 af_autofitter_done( FT_Autofitter module ) 216 af_autofitter_done( FT_Module ft_module ) /* AF_Module */
50 { 217 {
51 af_loader_done( module->loader ); 218 AF_Module module = (AF_Module)ft_module;
219
220
221 af_loader_done( module );
52 } 222 }
53 223
54 224
55 FT_CALLBACK_DEF( FT_Error ) 225 FT_CALLBACK_DEF( FT_Error )
56 af_autofitter_load_glyph( FT_Autofitter module, 226 af_autofitter_load_glyph( AF_Module module,
57 FT_GlyphSlot slot, 227 FT_GlyphSlot slot,
58 FT_Size size, 228 FT_Size size,
59 FT_UInt glyph_index, 229 FT_UInt glyph_index,
60 FT_Int32 load_flags ) 230 FT_Int32 load_flags )
61 { 231 {
62 FT_UNUSED( size ); 232 FT_UNUSED( size );
63 233
64 return af_loader_load_glyph( module->loader, slot->face, 234 return af_loader_load_glyph( module, slot->face,
65 glyph_index, load_flags ); 235 glyph_index, load_flags );
66 } 236 }
67 237
68 238
69 FT_DEFINE_AUTOHINTER_SERVICE( 239 FT_DEFINE_AUTOHINTER_INTERFACE(
70 af_autofitter_service, 240 af_autofitter_interface,
71 NULL, 241 NULL, /* reset_face */
72 NULL, 242 NULL, /* get_global_hints */
73 NULL, 243 NULL, /* done_global_hints */
74 (FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph ) 244 (FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph ) /* load_glyph */
245
75 246
76 FT_DEFINE_MODULE( 247 FT_DEFINE_MODULE(
77 autofit_module_class, 248 autofit_module_class,
78 249
79 FT_MODULE_HINTER, 250 FT_MODULE_HINTER,
80 sizeof ( FT_AutofitterRec ), 251 sizeof ( AF_ModuleRec ),
81 252
82 "autofitter", 253 "autofitter",
83 0x10000L, /* version 1.0 of the autofitter */ 254 0x10000L, /* version 1.0 of the autofitter */
84 0x20000L, /* requires FreeType 2.0 or above */ 255 0x20000L, /* requires FreeType 2.0 or above */
85 256
86 (const void*)&AF_AF_AUTOFITTER_SERVICE_GET, 257 (const void*)&AF_INTERFACE_GET,
87 258
88 (FT_Module_Constructor)af_autofitter_init, 259 (FT_Module_Constructor)af_autofitter_init,
89 (FT_Module_Destructor) af_autofitter_done, 260 (FT_Module_Destructor) af_autofitter_done,
90 (FT_Module_Requester) NULL ) 261 (FT_Module_Requester) af_get_interface )
91 262
92 263
93 /* END */ 264 /* END */
OLDNEW
« no previous file with comments | « src/autofit/afmodule.h ('k') | src/autofit/afpic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698