[autofit] More code orthogonality. * src/autofit/aftypes.h (AF_StyleMetrics): Replace `script_class' pointer to an `AF_ScriptClass' structure with `script' index of type `AF_Script'. Move some code around. * src/autofit/afcjk.c: Include `afpic.h'. (af_cjk_metrics_init_widths, af_cjk_metrics_init_blues, af_cjk_hint_edges): Updated. * src/autofit/aflatin.c: Include `afpic.h'. (af_latin_metrics_init_widths, af_latin_metrics_init_blues, af_latin_metrics_scale_dim, af_latin_hint_edges): Updated. * src/autofit/afglobal.c (af_face_globals_get_metrics): Updated. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): 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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
diff --git a/ChangeLog b/ChangeLog
index cce3a49..617bf4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2013-12-18 Werner Lemberg <wl@gnu.org>
+ [autofit] More code orthogonality.
+
+ * src/autofit/aftypes.h (AF_StyleMetrics): Replace `script_class'
+ pointer to an `AF_ScriptClass' structure with `script' index of type
+ `AF_Script'.
+ Move some code around.
+
+ * src/autofit/afcjk.c: Include `afpic.h'.
+ (af_cjk_metrics_init_widths, af_cjk_metrics_init_blues,
+ af_cjk_hint_edges): Updated.
+
+ * src/autofit/aflatin.c: Include `afpic.h'.
+ (af_latin_metrics_init_widths, af_latin_metrics_init_blues,
+ af_latin_metrics_scale_dim, af_latin_hint_edges): Updated.
+
+ * src/autofit/afglobal.c (af_face_globals_get_metrics): Updated.
+
+ * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
+ Updated.
+
+2013-12-18 Werner Lemberg <wl@gnu.org>
+
[autofit] s/ScriptMetrics/StyleMetrics/.
2013-12-18 Werner Lemberg <wl@gnu.org>
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index 0ebd46c..92b1df7 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -27,6 +27,7 @@
#include FT_INTERNAL_DEBUG_H
#include "afglobal.h"
+#include "afpic.h"
#include "aflatin.h"
@@ -77,7 +78,7 @@
"cjk standard widths computation (script `%s')\n"
"===============================================\n"
"\n",
- af_script_names[metrics->root.script_class->script] ));
+ af_script_names[metrics->root.script] ));
af_glyph_hints_init( hints, face->memory );
@@ -91,15 +92,16 @@
AF_CJKMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
+ AF_ScriptClass script_class =
+ AF_SCRIPT_CLASSES_GET[metrics->root.script];
- glyph_index = FT_Get_Char_Index(
- face,
- metrics->root.script_class->standard_char );
+
+ glyph_index = FT_Get_Char_Index( face, script_class->standard_char );
if ( glyph_index == 0 )
goto Exit;
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
- metrics->root.script_class->standard_char, glyph_index ));
+ script_class->standard_char, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
@@ -226,7 +228,9 @@
AF_CJKAxis axis;
FT_Outline outline;
- AF_Blue_Stringset bss = metrics->root.script_class->blue_stringset;
+ AF_ScriptClass sc = AF_SCRIPT_CLASSES_GET[metrics->root.script];
+
+ AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
#ifdef FT_DEBUG_LEVEL_TRACE
@@ -1667,7 +1671,7 @@
FT_TRACE5(( "cjk %s edge hinting (script `%s')\n",
dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
- af_script_names[hints->metrics->script_class->script] ));
+ af_script_names[hints->metrics->script] ));
/* we begin by aligning all stems relative to the blue zone */
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 74a9a1a..4a25f03 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -294,8 +294,8 @@
if ( FT_ALLOC( metrics, writing_system_class->style_metrics_size ) )
goto Exit;
- metrics->script_class = script_class;
- metrics->globals = globals;
+ metrics->script = script;
+ metrics->globals = globals;
if ( writing_system_class->style_metrics_init )
{
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 2c434e5..a01f0d3 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -21,6 +21,7 @@
#include FT_INTERNAL_DEBUG_H
#include "afglobal.h"
+#include "afpic.h"
#include "aflatin.h"
#include "aferrors.h"
@@ -64,7 +65,7 @@
"latin standard widths computation (script `%s')\n"
"=================================================\n"
"\n",
- af_script_names[metrics->root.script_class->script] ));
+ af_script_names[metrics->root.script] ));
af_glyph_hints_init( hints, face->memory );
@@ -78,15 +79,16 @@
AF_LatinMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
+ AF_ScriptClass script_class =
+ AF_SCRIPT_CLASSES_GET[metrics->root.script];
- glyph_index = FT_Get_Char_Index(
- face,
- metrics->root.script_class->standard_char );
+
+ glyph_index = FT_Get_Char_Index( face, script_class->standard_char );
if ( glyph_index == 0 )
goto Exit;
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
- metrics->root.script_class->standard_char, glyph_index ));
+ script_class->standard_char, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
@@ -214,7 +216,9 @@
AF_LatinAxis axis = &metrics->axis[AF_DIMENSION_VERT];
FT_Outline outline;
- AF_Blue_Stringset bss = metrics->root.script_class->blue_stringset;
+ AF_ScriptClass sc = AF_SCRIPT_CLASSES_GET[metrics->root.script];
+
+ AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
@@ -883,7 +887,7 @@
" "
" vertical scaling changed from %.4f to %.4f (by %d%%)\n"
"\n",
- af_script_names[metrics->root.script_class->script],
+ af_script_names[metrics->root.script],
axis->org_scale / 65536.0,
scale / 65536.0,
( fitted - scaled ) * 100 / scaled ));
@@ -908,7 +912,7 @@
FT_TRACE5(( "%s widths (script `%s')\n",
dim == AF_DIMENSION_HORZ ? "horizontal" : "vertical",
- af_script_names[metrics->root.script_class->script] ));
+ af_script_names[metrics->root.script] ));
/* scale the widths */
for ( nn = 0; nn < axis->width_count; nn++ )
@@ -935,13 +939,13 @@
if ( axis->extra_light )
FT_TRACE5(( "`%s' script is extra light (at current resolution)\n"
"\n",
- af_script_names[metrics->root.script_class->script] ));
+ af_script_names[metrics->root.script] ));
#endif
if ( dim == AF_DIMENSION_VERT )
{
FT_TRACE5(( "blue zones (script `%s')\n",
- af_script_names[metrics->root.script_class->script] ));
+ af_script_names[metrics->root.script] ));
/* scale the blue zones */
for ( nn = 0; nn < axis->blue_count; nn++ )
@@ -2150,7 +2154,7 @@
FT_TRACE5(( "latin %s edge hinting (script `%s')\n",
dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
- af_script_names[hints->metrics->script_class->script] ));
+ af_script_names[hints->metrics->script] ));
/* we begin by aligning all stems relative to the blue zone */
/* if needed -- that's only for horizontal edges */
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 68cf857..284664f 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -183,11 +183,12 @@
/* automatic hinting process */
{
#ifdef FT_CONFIG_OPTION_PIC
- AF_FaceGlobals globals = loader->globals;
+ AF_FaceGlobals globals = loader->globals;
#endif
+ AF_ScriptClass script_class =
+ AF_SCRIPT_CLASSES_GET[metrics->script];
AF_WritingSystemClass writing_system_class =
- AF_WRITING_SYSTEM_CLASSES_GET
- [metrics->script_class->writing_system];
+ AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
if ( writing_system_class->style_hints_apply )
@@ -544,11 +545,12 @@
if ( !error )
{
#ifdef FT_CONFIG_OPTION_PIC
- AF_FaceGlobals globals = loader->globals;
+ AF_FaceGlobals globals = loader->globals;
#endif
+ AF_ScriptClass script_class =
+ AF_SCRIPT_CLASSES_GET[metrics->script];
AF_WritingSystemClass writing_system_class =
- AF_WRITING_SYSTEM_CLASSES_GET
- [metrics->script_class->writing_system];
+ AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
loader->metrics = metrics;
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index f2842e8..0a8da0d 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -197,32 +197,7 @@ extern void* _af_debug_hints;
(a)->y_delta == (b)->y_delta )
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** S T Y L E M E T R I C S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct AF_WritingSystemClassRec_ const* AF_WritingSystemClass;
- typedef struct AF_ScriptClassRec_ const* AF_ScriptClass;
- typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
-
- /* This is the main structure that combines everything. Autofit modules */
- /* specific to writing systems derive their structures from it, for */
- /* example `AF_LatinMetrics'. */
-
- typedef struct AF_StyleMetricsRec_
- {
- AF_ScriptClass script_class;
- AF_ScalerRec scaler;
- FT_Bool digits_have_same_width;
-
- AF_FaceGlobals globals; /* to access properties */
-
- } AF_StyleMetricsRec, *AF_StyleMetrics;
-
+ typedef struct AF_StyleMetricsRec_* AF_StyleMetrics;
/* This function parses an FT_Face to compute global metrics for
* a specific script.
@@ -308,6 +283,8 @@ extern void* _af_debug_hints;
} AF_WritingSystemClassRec;
+ typedef const AF_WritingSystemClassRec* AF_WritingSystemClass;
+
/*************************************************************************/
/*************************************************************************/
@@ -363,6 +340,33 @@ extern void* _af_debug_hints;
} AF_ScriptClassRec;
+ typedef const AF_ScriptClassRec* AF_ScriptClass;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** S T Y L E M E T R I C S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
+
+ /* This is the main structure that combines everything. Autofit modules */
+ /* specific to writing systems derive their structures from it, for */
+ /* example `AF_LatinMetrics'. */
+
+ typedef struct AF_StyleMetricsRec_
+ {
+ AF_Script script;
+ AF_ScalerRec scaler;
+ FT_Bool digits_have_same_width;
+
+ AF_FaceGlobals globals; /* to access properties */
+
+ } AF_StyleMetricsRec;
+
/* Declare and define vtables for classes */
#ifndef FT_CONFIG_OPTION_PIC