[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
diff --git a/ChangeLog b/ChangeLog
index 69a1584..a4f4a12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 6a1d286..383bb11 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 27c9251..74b179d 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 975947e..29a2aed 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 d4347f0..79f6257 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 24113b5..2c938fc 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;