[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.
This commit is contained in:
Werner Lemberg 2012-09-18 15:23:41 +02:00
parent 273e2b796f
commit 842c4ea258
6 changed files with 41 additions and 19 deletions

View File

@ -1,3 +1,20 @@
2012-09-18 Werner Lemberg <wl@gnu.org>
[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 <wl@gnu.org>
[type1] Fix Savannah bug #37350.

View File

@ -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 )
{

View File

@ -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,

View File

@ -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 =

View File

@ -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 =

View File

@ -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;