24#ifdef FT_DEBUG_AUTOFIT
26#ifndef FT_MAKE_OPTION_SINGLE_OBJECT
32 af_glyph_hints_dump_segments( AF_GlyphHints hints,
35 af_glyph_hints_dump_points( AF_GlyphHints hints,
38 af_glyph_hints_dump_edges( AF_GlyphHints hints,
46 int af_debug_disable_horz_hints_;
47 int af_debug_disable_vert_hints_;
48 int af_debug_disable_blue_hints_;
51 static AF_GlyphHintsRec af_debug_hints_rec_[1];
53 void* af_debug_hints_ = af_debug_hints_rec_;
69#define FT_COMPONENT afmodule
73 af_property_get_face_globals( FT_Face face,
74 AF_FaceGlobals* aglobals,
77 FT_Error error = FT_Err_Ok;
78 AF_FaceGlobals globals;
82 return FT_THROW( Invalid_Face_Handle );
84 globals = (AF_FaceGlobals)face->autohint.data;
89 error = af_face_globals_new( face, &globals, module );
92 face->autohint.data = (FT_Pointer)globals;
93 face->autohint.finalizer = af_face_globals_free;
105 af_property_set( FT_Module ft_module,
106 const char* property_name,
108 FT_Bool value_is_string )
110 FT_Error error = FT_Err_Ok;
111 AF_Module module = (AF_Module)ft_module;
113#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
114 FT_UNUSED( value_is_string );
118 if ( !ft_strcmp( property_name,
"fallback-script" ) )
120 AF_Script* fallback_script;
124#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
125 if ( value_is_string )
126 return FT_THROW( Invalid_Argument );
129 fallback_script = (AF_Script*)value;
134 for ( ss = 0; af_style_classes[ss]; ss++ )
136 AF_StyleClass style_class = af_style_classes[ss];
139 if ( style_class->script == *fallback_script &&
140 style_class->coverage == AF_COVERAGE_DEFAULT )
142 module->fallback_style = ss;
147 if ( !af_style_classes[ss] )
149 FT_TRACE2((
"af_property_set: Invalid value %u for property `%s'\n",
150 *fallback_script, property_name ));
151 return FT_THROW( Invalid_Argument );
156 else if ( !ft_strcmp( property_name,
"default-script" ) )
158 AF_Script* default_script;
161#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
162 if ( value_is_string )
163 return FT_THROW( Invalid_Argument );
166 default_script = (AF_Script*)value;
168 module->default_script = *default_script;
172 else if ( !ft_strcmp( property_name,
"increase-x-height" ) )
174 FT_Prop_IncreaseXHeight* prop;
175 AF_FaceGlobals globals;
178#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
179 if ( value_is_string )
180 return FT_THROW( Invalid_Argument );
183 prop = (FT_Prop_IncreaseXHeight*)value;
185 error = af_property_get_face_globals( prop->face, &globals, module );
187 globals->increase_x_height = prop->limit;
191 else if ( !ft_strcmp( property_name,
"darkening-parameters" ) )
193 FT_Int* darken_params;
194 FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
196#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
200 if ( value_is_string )
202 const char* s = (
const char*)value;
208 for ( i = 0; i < 7; i++ )
210 dp[i] = (FT_Int)ft_strtol( s, &ep, 10 );
211 if ( *ep !=
',' || s == ep )
212 return FT_THROW( Invalid_Argument );
217 dp[7] = (FT_Int)ft_strtol( s, &ep, 10 );
218 if ( !( *ep ==
'\0' || *ep ==
' ' ) || s == ep )
219 return FT_THROW( Invalid_Argument );
225 darken_params = (FT_Int*)value;
227 x1 = darken_params[0];
228 y1 = darken_params[1];
229 x2 = darken_params[2];
230 y2 = darken_params[3];
231 x3 = darken_params[4];
232 y3 = darken_params[5];
233 x4 = darken_params[6];
234 y4 = darken_params[7];
236 if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
237 y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
238 x1 > x2 || x2 > x3 || x3 > x4 ||
239 y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
240 return FT_THROW( Invalid_Argument );
242 module->darken_params[0] = x1;
243 module->darken_params[1] = y1;
244 module->darken_params[2] = x2;
245 module->darken_params[3] = y2;
246 module->darken_params[4] = x3;
247 module->darken_params[5] = y3;
248 module->darken_params[6] = x4;
249 module->darken_params[7] = y4;
253 else if ( !ft_strcmp( property_name,
"no-stem-darkening" ) )
255#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
256 if ( value_is_string )
258 const char* s = (
const char*)value;
259 long nsd = ft_strtol( s, NULL, 10 );
263 module->no_stem_darkening = FALSE;
265 module->no_stem_darkening = TRUE;
270 FT_Bool* no_stem_darkening = (FT_Bool*)value;
273 module->no_stem_darkening = *no_stem_darkening;
279 FT_TRACE2((
"af_property_set: missing property `%s'\n",
281 return FT_THROW( Missing_Property );
286 af_property_get( FT_Module ft_module,
287 const char* property_name,
290 FT_Error error = FT_Err_Ok;
291 AF_Module module = (AF_Module)ft_module;
294 if ( !ft_strcmp( property_name,
"glyph-to-script-map" ) )
296 FT_Prop_GlyphToScriptMap* prop = (FT_Prop_GlyphToScriptMap*)value;
297 AF_FaceGlobals globals;
300 error = af_property_get_face_globals( prop->face, &globals, module );
302 prop->map = globals->glyph_styles;
306 else if ( !ft_strcmp( property_name,
"fallback-script" ) )
308 AF_Script* val = (AF_Script*)value;
310 AF_StyleClass style_class = af_style_classes[module->fallback_style];
313 *val = style_class->script;
317 else if ( !ft_strcmp( property_name,
"default-script" ) )
319 AF_Script* val = (AF_Script*)value;
322 *val =
module->default_script;
326 else if ( !ft_strcmp( property_name,
"increase-x-height" ) )
328 FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
329 AF_FaceGlobals globals;
332 error = af_property_get_face_globals( prop->face, &globals, module );
334 prop->limit = globals->increase_x_height;
338 else if ( !ft_strcmp( property_name,
"darkening-parameters" ) )
340 FT_Int* darken_params =
module->darken_params;
341 FT_Int* val = (FT_Int*)value;
344 val[0] = darken_params[0];
345 val[1] = darken_params[1];
346 val[2] = darken_params[2];
347 val[3] = darken_params[3];
348 val[4] = darken_params[4];
349 val[5] = darken_params[5];
350 val[6] = darken_params[6];
351 val[7] = darken_params[7];
355 else if ( !ft_strcmp( property_name,
"no-stem-darkening" ) )
357 FT_Bool no_stem_darkening =
module->no_stem_darkening;
358 FT_Bool* val = (FT_Bool*)value;
361 *val = no_stem_darkening;
366 FT_TRACE2((
"af_property_get: missing property `%s'\n",
368 return FT_THROW( Missing_Property );
372 FT_DEFINE_SERVICE_PROPERTIESREC(
373 af_service_properties,
380 FT_DEFINE_SERVICEDESCREC1(
383 FT_SERVICE_ID_PROPERTIES, &af_service_properties )
386 FT_CALLBACK_DEF( FT_Module_Interface )
387 af_get_interface( FT_Module module,
388 const char* module_interface )
392 return ft_service_list_lookup( af_services, module_interface );
396 FT_CALLBACK_DEF( FT_Error )
397 af_autofitter_init( FT_Module ft_module )
399 AF_Module module = (AF_Module)ft_module;
402 module->fallback_style = AF_STYLE_FALLBACK;
403 module->default_script = AF_SCRIPT_DEFAULT;
404 module->no_stem_darkening = TRUE;
406 module->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
407 module->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
408 module->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
409 module->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
410 module->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
411 module->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
412 module->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
413 module->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
415#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ ) && \
416 defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC )
417 ft_hb_funcs_init( module );
424 FT_CALLBACK_DEF(
void )
425 af_autofitter_done( FT_Module ft_module )
427 FT_UNUSED( ft_module );
429#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ ) && \
430 defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC )
431 ft_hb_funcs_done( (AF_Module)ft_module );
434#ifdef FT_DEBUG_AUTOFIT
435 if ( af_debug_hints_rec_->memory )
436 af_glyph_hints_done( af_debug_hints_rec_ );
441 FT_CALLBACK_DEF( FT_Error )
442 af_autofitter_load_glyph( FT_AutoHinter module_,
446 FT_Int32 load_flags )
448 AF_Module module = (AF_Module)module_;
450 FT_Error error = FT_Err_Ok;
451 FT_Memory memory =
module->root.memory;
453#ifdef FT_DEBUG_AUTOFIT
457 AF_GlyphHints hints = af_debug_hints_rec_;
458 AF_LoaderRec loader[1];
464 af_glyph_hints_done( hints );
466 af_glyph_hints_init( hints, memory );
467 af_loader_init( loader, hints );
469 error = af_loader_load_glyph( loader, module, slot->face,
470 glyph_index, load_flags );
472#ifdef FT_DEBUG_LEVEL_TRACE
473 if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] )
476 af_glyph_hints_dump_points( hints, 0 );
477 af_glyph_hints_dump_segments( hints, 0 );
478 af_glyph_hints_dump_edges( hints, 0 );
479#ifdef FT_DEBUG_LEVEL_TRACE
483 af_loader_done( loader );
489 AF_GlyphHintsRec hints[1];
490 AF_LoaderRec loader[1];
495 af_glyph_hints_init( hints, memory );
496 af_loader_init( loader, hints );
498 error = af_loader_load_glyph( loader, module, slot->face,
499 glyph_index, load_flags );
501 af_loader_done( loader );
502 af_glyph_hints_done( hints );
510 FT_DEFINE_AUTOHINTER_INTERFACE(
511 af_autofitter_interface,
516 af_autofitter_load_glyph
520 autofit_module_class,
523 sizeof ( AF_ModuleRec ),
529 (
const void*)&af_autofitter_interface,