diff --git a/ChangeLog b/ChangeLog index 69a15841f..a4f4a124d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2012-09-18 Werner Lemberg + + [autofit] Add hierarchical property access to some structures. + + * src/autofit/afglobal.h: Include `afmodule.h'. + (AF_FaceGlobalsRec): Add `module' member. + (AF_FaceGlobals): Typedef moved to... + * src/autofit/aftypes.h: Here. + (AF_ScriptMetricsRec): Add `globals' member. + + * src/autofit/afglobal.c (af_face_globals_new, + af_face_globals_compute_script_coverage, + af_face_globals_get_metrics): Updated. + + * src/autofit/afloader.c (af_loader_reset), src/autofit/afmodule.c + (af_property_get): Updated. + 2012-09-17 Werner Lemberg [type1] Fix Savannah bug #37350. diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c index 6a1d2868b..383bb1196 100644 --- a/src/autofit/afglobal.c +++ b/src/autofit/afglobal.c @@ -53,8 +53,7 @@ /* Compute the script index of each glyph within a given face. */ static FT_Error - af_face_globals_compute_script_coverage( AF_FaceGlobals globals, - FT_UInt fallback_script ) + af_face_globals_compute_script_coverage( AF_FaceGlobals globals ) { FT_Error error = AF_Err_Ok; FT_Face face = globals->face; @@ -145,7 +144,7 @@ if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_NONE ) { gscripts[nn] &= ~AF_SCRIPT_NONE; - gscripts[nn] |= fallback_script; + gscripts[nn] |= globals->module->fallback_script; } } } @@ -158,7 +157,7 @@ FT_LOCAL_DEF( FT_Error ) af_face_globals_new( FT_Face face, AF_FaceGlobals *aglobals, - FT_UInt fallback_script ) + AF_Module module ) { FT_Error error; FT_Memory memory; @@ -174,9 +173,9 @@ globals->face = face; globals->glyph_count = face->num_glyphs; globals->glyph_scripts = (FT_Byte*)( globals + 1 ); + globals->module = module; - error = af_face_globals_compute_script_coverage( globals, - fallback_script ); + error = af_face_globals_compute_script_coverage( globals ); if ( error ) { af_face_globals_free( globals ); @@ -262,7 +261,8 @@ if ( FT_ALLOC( metrics, clazz->script_metrics_size ) ) goto Exit; - metrics->clazz = clazz; + metrics->clazz = clazz; + metrics->globals = globals; if ( clazz->script_metrics_init ) { diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h index 27c92513c..74b179d90 100644 --- a/src/autofit/afglobal.h +++ b/src/autofit/afglobal.h @@ -22,6 +22,7 @@ #include "aftypes.h" +#include "afmodule.h" FT_BEGIN_HEADER @@ -57,6 +58,8 @@ FT_BEGIN_HEADER AF_ScriptMetrics metrics[AF_SCRIPT_MAX]; + AF_Module module; /* to access global properties */ + } AF_FaceGlobalsRec; @@ -64,13 +67,11 @@ FT_BEGIN_HEADER * model the global hints data for a given face, decomposed into * script-specific items */ - typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals; - FT_LOCAL( FT_Error ) af_face_globals_new( FT_Face face, AF_FaceGlobals *aglobals, - FT_UInt fallback_script ); + AF_Module module ); FT_LOCAL( FT_Error ) af_face_globals_get_metrics( AF_FaceGlobals globals, diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c index 975947e5a..29a2aed48 100644 --- a/src/autofit/afloader.c +++ b/src/autofit/afloader.c @@ -59,8 +59,7 @@ if ( loader->globals == NULL ) { - error = af_face_globals_new( face, &loader->globals, - module->fallback_script ); + error = af_face_globals_new( face, &loader->globals, module ); if ( !error ) { face->autohint.data = diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c index d4347f0f8..79f62572c 100644 --- a/src/autofit/afmodule.c +++ b/src/autofit/afmodule.c @@ -44,11 +44,12 @@ FT_Error - af_property_set( FT_Module module, + af_property_set( FT_Module ft_module, const char* property_name, const void* value ) { - FT_Error error = AF_Err_Ok; + FT_Error error = AF_Err_Ok; + AF_Module module = (AF_Module)ft_module; if ( !ft_strcmp( property_name, "fallback-script" ) ) @@ -56,7 +57,7 @@ FT_UInt* fallback_script = (FT_UInt*)value; - ((AF_Module)module)->fallback_script = *fallback_script; + module->fallback_script = *fallback_script; return error; } @@ -68,12 +69,13 @@ FT_Error - af_property_get( FT_Module module, + af_property_get( FT_Module ft_module, const char* property_name, void* value ) { - FT_Error error = AF_Err_Ok; - FT_UInt fallback_script = ((AF_Module)module)->fallback_script; + FT_Error error = AF_Err_Ok; + AF_Module module = (AF_Module)ft_module; + FT_UInt fallback_script = module->fallback_script; if ( !ft_strcmp( property_name, "glyph-to-script-map" ) ) @@ -90,7 +92,7 @@ { /* trigger computation of the global script data */ /* in case it hasn't been done yet */ - error = af_face_globals_new( prop->face, &globals, fallback_script ); + error = af_face_globals_new( prop->face, &globals, module ); if ( !error ) { prop->face->autohint.data = diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h index 24113b515..2c938fc29 100644 --- a/src/autofit/aftypes.h +++ b/src/autofit/aftypes.h @@ -246,6 +246,7 @@ extern void* _af_debug_hints; typedef struct AF_ScriptClassRec_ const* AF_ScriptClass; + typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals; typedef struct AF_ScriptMetricsRec_ { @@ -253,6 +254,8 @@ extern void* _af_debug_hints; AF_ScalerRec scaler; FT_Bool digits_have_same_width; + AF_FaceGlobals globals; /* to access properties */ + } AF_ScriptMetricsRec, *AF_ScriptMetrics;