Commit d0014f2ccbe70ffabae3851dc7c1a1f8fd538b62

Werner Lemberg 2012-09-15T10:33:43

[autofit] Make default script a global property. * src/autofit/afmodule.h (AF_ModuleRec): Add `default_script' field. * src/autofit/afglobal.c (af_face_globals_compute_script_coverage, af_face_globals_new), src/autofit/afloader.c (af_loader_reset), src/autofit/afmodule.c (af_property_get) <glyph-to-script-map>, af_autofitter_init: Handle default script. * src/autofit/afglobal.h: Updated.

diff --git a/ChangeLog b/ChangeLog
index 6d2a0a1..d17bcb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2012-09-15  Werner Lemberg  <wl@gnu.org>
 
+	[autofit] Make default script a global property.
+
+	* src/autofit/afmodule.h (AF_ModuleRec): Add `default_script' field.
+
+	* src/autofit/afglobal.c (af_face_globals_compute_script_coverage,
+	af_face_globals_new), src/autofit/afloader.c (af_loader_reset),
+	src/autofit/afmodule.c (af_property_get) <glyph-to-script-map>,
+	af_autofitter_init:
+	Handle default script.
+
+	* src/autofit/afglobal.h: Updated.
+
+2012-09-15  Werner Lemberg  <wl@gnu.org>
+
 	Use `FT_Module' instead of `FT_Library' argument in property funcs.
 
 	This internal change simplifies access to global module data.
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 1842c86..464e6d5 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -53,7 +53,8 @@
   /* Compute the script index of each glyph within a given face. */
 
   static FT_Error
-  af_face_globals_compute_script_coverage( AF_FaceGlobals  globals )
+  af_face_globals_compute_script_coverage( AF_FaceGlobals  globals,
+                                           FT_UInt         default_script )
   {
     FT_Error    error       = AF_Err_Ok;
     FT_Face     face        = globals->face;
@@ -144,7 +145,7 @@
         if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_NONE )
         {
           gscripts[nn] &= ~AF_SCRIPT_NONE;
-          gscripts[nn] |= AF_SCRIPT_DEFAULT;
+          gscripts[nn] |= default_script;
         }
       }
     }
@@ -156,7 +157,8 @@
 
   FT_LOCAL_DEF( FT_Error )
   af_face_globals_new( FT_Face          face,
-                       AF_FaceGlobals  *aglobals )
+                       AF_FaceGlobals  *aglobals,
+                       FT_UInt          default_script )
   {
     FT_Error        error;
     FT_Memory       memory;
@@ -173,7 +175,8 @@
     globals->glyph_count   = face->num_glyphs;
     globals->glyph_scripts = (FT_Byte*)( globals + 1 );
 
-    error = af_face_globals_compute_script_coverage( globals );
+    error = af_face_globals_compute_script_coverage( globals,
+                                                     default_script );
     if ( error )
     {
       af_face_globals_free( globals );
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index 3bb77d1..3dec6d0 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -69,7 +69,8 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( FT_Error )
   af_face_globals_new( FT_Face          face,
-                       AF_FaceGlobals  *aglobals );
+                       AF_FaceGlobals  *aglobals,
+                       FT_UInt          default_script );
 
   FT_LOCAL( FT_Error )
   af_face_globals_get_metrics( AF_FaceGlobals     globals,
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 8d09866..98824dc 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -59,7 +59,8 @@
 
     if ( loader->globals == NULL )
     {
-      error = af_face_globals_new( face, &loader->globals );
+      error = af_face_globals_new( face, &loader->globals,
+                                   module->default_script );
       if ( !error )
       {
         face->autohint.data =
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 7e6a5dc..2252bc3 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -62,9 +62,8 @@
                    const char*  property_name,
                    void*        value )
   {
-    FT_Error  error = FT_Err_Ok;
-
-    FT_UNUSED( module );
+    FT_Error  error          = FT_Err_Ok;
+    FT_UInt   default_script = ((AF_Module)module)->default_script;
 
 
     if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
@@ -81,7 +80,7 @@
       {
         /* trigger computation of the global script data */
         /* in case it hasn't been done yet               */
-        error = af_face_globals_new( prop->face, &globals );
+        error = af_face_globals_new( prop->face, &globals, default_script );
         if ( !error )
         {
           prop->face->autohint.data =
@@ -139,6 +138,8 @@
   FT_CALLBACK_DEF( FT_Error )
   af_autofitter_init( AF_Module  module )
   {
+    module->default_script = AF_SCRIPT_DEFAULT;
+
     return af_loader_init( module );
   }
 
diff --git a/src/autofit/afmodule.h b/src/autofit/afmodule.h
index b02adf4..8948c1b 100644
--- a/src/autofit/afmodule.h
+++ b/src/autofit/afmodule.h
@@ -40,6 +40,8 @@ FT_BEGIN_HEADER
   {
     FT_ModuleRec  root;
 
+    FT_UInt       default_script;
+
     AF_LoaderRec  loader[1];
 
   } AF_ModuleRec;