ref: 9bfbf79c9f7b1212a4ac244cbf1ae370e8c00882
parent: 1029ed26af608db8cf03d38ea2e269d16b17d029
author: David Turner <[email protected]>
date: Mon Feb 23 16:08:37 EST 2004
adding support for dummy script, i.e. no-hinting for non latin glyphs
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-23 David Turner <[email protected]>
+
+ * src/autofit/afhints.c, src/autofit/afhints.h, src/autofit/aflatin.c,
+ src/autofit/afloader.c, src/types.h: grave bugs were fixed. The
+ auto-fitter works, doesn't crashes, but still produces unexpected
+ results !!
+
2004-02-21 Werner Lemberg <[email protected]>
* src/pshinter/pshalgo.c (PSH_STRONG_THRESHOLD): Changed to hold
--- a/src/autofit/Jamfile
+++ b/src/autofit/Jamfile
@@ -5,7 +5,7 @@
if $(FT2_MULTI)
{
- _sources = afangles afglobal afhints aflatin afloader afmodule ;
+ _sources = afangles afglobal afhints aflatin afloader afmodule afdummy ;
}
else
{
--- /dev/null
+++ b/src/autofit/afdummy.c
@@ -1,0 +1,35 @@
+#include "afdummy.h"
+
+
+ static FT_Error
+ af_dummy_hints_init( AF_GlyphHints hints,
+ FT_Outline* outline,
+ AF_ScriptMetrics metrics )
+ {
+ return af_glyph_hints_reset( hints,
+ &metrics->scaler,
+ metrics,
+ outline );
+ }
+
+ static FT_Error
+ af_dummy_hints_apply( AF_GlyphHints hints,
+ FT_Outline* outline )
+ {
+ af_glyph_hints_save( hints, outline );
+ }
+
+
+ FT_LOCAL_DEF( const AF_ScriptClassRec ) af_dummy_script_class =
+ {
+ AF_SCRIPT_NONE,
+ NULL,
+
+ sizeof( AF_ScriptMetricsRec ),
+ (AF_Script_InitMetricsFunc) NULL,
+ (AF_Script_ScaleMetricsFunc) NULL,
+ (AF_Script_DoneMetricsFunc) NULL,
+
+ (AF_Script_InitHintsFunc) af_dummy_hints_init,
+ (AF_Script_ApplyHintsFunc) af_dummy_hints_apply
+ };
--- /dev/null
+++ b/src/autofit/afdummy.h
@@ -1,0 +1,18 @@
+#ifndef __AFDUMMY_H__
+#define __AFDUMMY_H__
+
+#include "aftypes.h"
+
+FT_BEGIN_HEADER
+
+ /* a dummy script metrics class used when no hinting should
+ * be performed. This is the default for non-latin glyphs !
+ */
+
+ FT_LOCAL( const AF_ScriptClassRec ) af_dummy_script_class;
+
+/* */
+
+FT_END_HEADER
+
+#endif /* __AFDUMMY_H__ */
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -1,4 +1,5 @@
#include "afglobal.h"
+#include "afdummy.h"
#include "aflatin.h"
/* populate this list when you add new scripts
@@ -5,6 +6,7 @@
*/
static AF_ScriptClass const af_script_classes[] =
{
+ & af_dummy_script_class,
& af_latin_script_class,
NULL /* do not remove */
@@ -65,6 +67,9 @@
{
AF_ScriptClass clazz = af_script_classes[ss];
AF_Script_UniRange range;
+
+ if ( clazz->script_uni_ranges == NULL )
+ continue;
/* scan all unicode points in the range, and set the corresponding
* glyph script index
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -389,13 +389,13 @@
if ( dim == AF_DIMENSION_HORZ )
{
- metrics->scaler.x_scale = scale;
- metrics->scaler.x_delta = delta;
+ metrics->root.scaler.x_scale = scale;
+ metrics->root.scaler.x_delta = delta;
}
else
{
- metrics->scaler.y_scale = scale;
- metrics->scaler.y_delta = delta;
+ metrics->root.scaler.y_scale = scale;
+ metrics->root.scaler.y_delta = delta;
}
/* scale the standard widths
@@ -437,8 +437,6 @@
af_latin_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler )
{
- metrics->scaler = scaler[0];
-
af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
}
@@ -1146,7 +1144,7 @@
FT_Error error;
FT_Render_Mode mode;
- error = af_glyph_hints_reset( hints, &metrics->scaler,
+ error = af_glyph_hints_reset( hints, &metrics->root.scaler,
(AF_ScriptMetrics) metrics,
outline );
if (error)
@@ -1156,7 +1154,7 @@
/* compute flags depending on render mode, etc...
*/
- mode = metrics->scaler.render_mode;
+ mode = metrics->root.scaler.render_mode;
/* we snap the width of vertical stems for the monochrome and
* horizontal LCD rendering targets only.
--- a/src/autofit/aflatin.h
+++ b/src/autofit/aflatin.h
@@ -92,7 +92,6 @@
AF_ScriptMetricsRec root;
FT_UInt units_per_em;
AF_LatinAxisRec axis[ AF_DIMENSION_MAX ];
- AF_ScalerRec scaler;
} AF_LatinMetricsRec, *AF_LatinMetrics;
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -426,7 +426,10 @@
{
loader->metrics = metrics;
- metrics->clazz->script_metrics_scale( metrics, &scaler );
+ metrics->scaler = scaler;
+
+ if ( metrics->clazz->script_metrics_scale )
+ metrics->clazz->script_metrics_scale( metrics, &scaler );
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
load_flags &= ~FT_LOAD_RENDER;
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -195,7 +195,8 @@
*/
typedef enum
{
- AF_SCRIPT_LATIN = 0,
+ AF_SCRIPT_NONE = 0,
+ AF_SCRIPT_LATIN = 1,
/* add new scripts here. don't forget to update the list in "afglobal.c" */
AF_SCRIPT_MAX /* do not remove */
@@ -209,6 +210,7 @@
typedef struct AF_ScriptMetricsRec_
{
AF_ScriptClass clazz;
+ AF_ScalerRec scaler;
} AF_ScriptMetricsRec, *AF_ScriptMetrics;
--- a/src/autofit/autofit.c
+++ b/src/autofit/autofit.c
@@ -3,6 +3,7 @@
#include "afangles.c"
#include "afglobal.c"
#include "afhints.c"
+#include "afdummy.c"
#include "aflatin.c"
#include "afloader.c"
#include "afmodule.c"