[autofit] Fix script selection. * src/autofit/afglobal.c (af_face_globals_get_metrics): Use `AF_SCRIPT_DFLT', not value 0. Simplify code. * src/autofit/afscript.h: Sort by script name.
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
diff --git a/ChangeLog b/ChangeLog
index 9c3693d..232a206 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2013-08-26 Werner Lemberg <wl@gnu.org>
+ [autofit] Fix script selection.
+
+ * src/autofit/afglobal.c (af_face_globals_get_metrics): Use
+ `AF_SCRIPT_DFLT', not value 0.
+ Simplify code.
+
+ * src/autofit/afscript.h: Sort by script name.
+
+2013-08-26 Werner Lemberg <wl@gnu.org>
+
[autofit] Make `dummy' hinter work as expected.
* src/autofit/afdummy.c (af_dummy_hints_init): Properly set scaling
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 1133ffc..e026c1c 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -246,15 +246,12 @@
AF_ScriptMetrics *ametrics )
{
AF_ScriptMetrics metrics = NULL;
- FT_UInt gidx;
+ AF_Script script = options & 15;
AF_WritingSystemClass writing_system_class;
AF_ScriptClass script_class;
- FT_UInt script = options & 15;
- const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
- sizeof ( AF_SCRIPT_CLASSES_GET[0] );
- FT_Error error = FT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( gindex >= (FT_ULong)globals->glyph_count )
@@ -263,17 +260,16 @@
goto Exit;
}
- gidx = script;
- if ( gidx == 0 || gidx + 1 >= script_max )
- gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_NONE;
+ /* if we have a forced script (via `options'), use it, */
+ /* otherwise look into `glyph_scripts' array */
+ if ( script == AF_SCRIPT_DFLT || script + 1 >= AF_SCRIPT_MAX )
+ script = globals->glyph_scripts[gindex] & AF_SCRIPT_NONE;
- script_class = AF_SCRIPT_CLASSES_GET[gidx];
+ script_class = AF_SCRIPT_CLASSES_GET[script];
writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET
[script_class->writing_system];
- if ( script == 0 )
- script = script_class->script;
- metrics = globals->metrics[script_class->script];
+ metrics = globals->metrics[script];
if ( metrics == NULL )
{
/* create the global metrics object if necessary */
@@ -300,7 +296,7 @@
}
}
- globals->metrics[script_class->script] = metrics;
+ globals->metrics[script] = metrics;
}
Exit:
diff --git a/src/autofit/afscript.h b/src/autofit/afscript.h
index e3170ae..4e4567f 100644
--- a/src/autofit/afscript.h
+++ b/src/autofit/afscript.h
@@ -22,10 +22,10 @@
/* Add new scripts here. */
+ SCRIPT( deva, DEVA )
SCRIPT( dflt, DFLT )
- SCRIPT( latn, LATN )
SCRIPT( hani, HANI )
- SCRIPT( deva, DEVA )
+ SCRIPT( latn, LATN )
#ifdef FT_OPTION_AUTOFIT2
SCRIPT( ltn2, LTN2 )
#endif