adding support for dummy script, i.e. no-hinting for non latin glyphs
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
diff --git a/ChangeLog b/ChangeLog
index 75ac247..d3fe975 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-23 David Turner <david@freetype.org>
+
+ * 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 <wl@gnu.org>
* src/pshinter/pshalgo.c (PSH_STRONG_THRESHOLD): Changed to hold
diff --git a/src/autofit/Jamfile b/src/autofit/Jamfile
index 3253c82..3063f23 100644
--- a/src/autofit/Jamfile
+++ b/src/autofit/Jamfile
@@ -5,7 +5,7 @@ SubDir FT2_TOP src autofit ;
if $(FT2_MULTI)
{
- _sources = afangles afglobal afhints aflatin afloader afmodule ;
+ _sources = afangles afglobal afhints aflatin afloader afmodule afdummy ;
}
else
{
diff --git a/src/autofit/afdummy.c b/src/autofit/afdummy.c
new file mode 100644
index 0000000..ec6a70e
--- /dev/null
+++ b/src/autofit/afdummy.c
@@ -0,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
+ };
diff --git a/src/autofit/afdummy.h b/src/autofit/afdummy.h
new file mode 100644
index 0000000..6d3ab44
--- /dev/null
+++ b/src/autofit/afdummy.h
@@ -0,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__ */
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 6362036..cadc803 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -1,10 +1,12 @@
#include "afglobal.h"
+#include "afdummy.h"
#include "aflatin.h"
/* populate this list when you add new scripts
*/
static AF_ScriptClass const af_script_classes[] =
{
+ & af_dummy_script_class,
& af_latin_script_class,
NULL /* do not remove */
@@ -66,6 +68,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
*/
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 131bff6..00fb7b6 100644
--- 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.
diff --git a/src/autofit/aflatin.h b/src/autofit/aflatin.h
index da51cad..a52e421 100644
--- a/src/autofit/aflatin.h
+++ b/src/autofit/aflatin.h
@@ -92,7 +92,6 @@ FT_BEGIN_HEADER
AF_ScriptMetricsRec root;
FT_UInt units_per_em;
AF_LatinAxisRec axis[ AF_DIMENSION_MAX ];
- AF_ScalerRec scaler;
} AF_LatinMetricsRec, *AF_LatinMetrics;
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 023b251..f7f1b8b 100644
--- 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;
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index 7985390..5b2afd4 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -195,7 +195,8 @@ FT_BEGIN_HEADER
*/
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 @@ FT_BEGIN_HEADER
typedef struct AF_ScriptMetricsRec_
{
AF_ScriptClass clazz;
+ AF_ScalerRec scaler;
} AF_ScriptMetricsRec, *AF_ScriptMetrics;
diff --git a/src/autofit/autofit.c b/src/autofit/autofit.c
index 91e4db3..c258e0d 100644
--- 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"