ref: 73f319810115f4c51793fe4efb9d65be670b6d75
parent: 115de7131dff02896c1429574bb87464ff855d86
author: Werner Lemberg <[email protected]>
date: Thu Dec 19 10:24:17 EST 2013
[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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2013-12-18 Werner Lemberg <[email protected]>
+ [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 <[email protected]>
+
[autofit] s/ScriptMetrics/StyleMetrics/.
2013-12-18 Werner Lemberg <[email protected]>
--- 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 */
--- 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 )
{
--- 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 */
--- 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;
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -197,33 +197,8 @@
(a)->y_delta == (b)->y_delta )
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** S T Y L E M E T R I C S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
+ typedef struct AF_StyleMetricsRec_* AF_StyleMetrics;
- 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;
-
-
/* This function parses an FT_Face to compute global metrics for
* a specific script.
*/
@@ -308,7 +283,9 @@
} AF_WritingSystemClassRec;
+ typedef const AF_WritingSystemClassRec* AF_WritingSystemClass;
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -362,6 +339,33 @@
FT_UInt32 standard_char; /* for default width and height */
} 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 */