Commit 9bfbf79c9f7b1212a4ac244cbf1ae370e8c00882

David Turner 2004-02-23T21:08:37

adding support for dummy script, i.e. no-hinting for non latin glyphs

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"