shithub: freetype+ttf2subf

Download patch

ref: 842c4ea2580a28133daea84bfd884f749e762da7
parent: 273e2b796f206282836496e57fa7093dc7c82ae0
author: Werner Lemberg <[email protected]>
date: Tue Sep 18 11:23:41 EDT 2012

[autofit] Add hierarchical property access to some structures.

* src/autofit/afglobal.h: Include `afmodule.h'.
(AF_FaceGlobalsRec): Add `module' member.
(AF_FaceGlobals): Typedef moved to...
* src/autofit/aftypes.h: Here.
(AF_ScriptMetricsRec): Add `globals' member.

* src/autofit/afglobal.c (af_face_globals_new,
af_face_globals_compute_script_coverage,
af_face_globals_get_metrics): Updated.

* src/autofit/afloader.c (af_loader_reset), src/autofit/afmodule.c
(af_property_get): Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2012-09-18  Werner Lemberg  <[email protected]>
+
+	[autofit] Add hierarchical property access to some structures.
+
+	* src/autofit/afglobal.h: Include `afmodule.h'.
+	(AF_FaceGlobalsRec): Add `module' member.
+	(AF_FaceGlobals): Typedef moved to...
+	* src/autofit/aftypes.h: Here.
+	(AF_ScriptMetricsRec): Add `globals' member.
+
+	* src/autofit/afglobal.c (af_face_globals_new,
+	af_face_globals_compute_script_coverage,
+	af_face_globals_get_metrics): Updated.
+
+	* src/autofit/afloader.c (af_loader_reset), src/autofit/afmodule.c
+	(af_property_get): Updated.
+
 2012-09-17  Werner Lemberg  <[email protected]>
 
 	[type1] Fix Savannah bug #37350.
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -53,8 +53,7 @@
   /* Compute the script index of each glyph within a given face. */
 
   static FT_Error
-  af_face_globals_compute_script_coverage( AF_FaceGlobals  globals,
-                                           FT_UInt         fallback_script )
+  af_face_globals_compute_script_coverage( AF_FaceGlobals  globals )
   {
     FT_Error    error       = AF_Err_Ok;
     FT_Face     face        = globals->face;
@@ -145,7 +144,7 @@
         if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_NONE )
         {
           gscripts[nn] &= ~AF_SCRIPT_NONE;
-          gscripts[nn] |= fallback_script;
+          gscripts[nn] |= globals->module->fallback_script;
         }
       }
     }
@@ -158,7 +157,7 @@
   FT_LOCAL_DEF( FT_Error )
   af_face_globals_new( FT_Face          face,
                        AF_FaceGlobals  *aglobals,
-                       FT_UInt          fallback_script )
+                       AF_Module        module )
   {
     FT_Error        error;
     FT_Memory       memory;
@@ -174,9 +173,9 @@
     globals->face          = face;
     globals->glyph_count   = face->num_glyphs;
     globals->glyph_scripts = (FT_Byte*)( globals + 1 );
+    globals->module        = module;
 
-    error = af_face_globals_compute_script_coverage( globals,
-                                                     fallback_script );
+    error = af_face_globals_compute_script_coverage( globals );
     if ( error )
     {
       af_face_globals_free( globals );
@@ -262,7 +261,8 @@
       if ( FT_ALLOC( metrics, clazz->script_metrics_size ) )
         goto Exit;
 
-      metrics->clazz = clazz;
+      metrics->clazz   = clazz;
+      metrics->globals = globals;
 
       if ( clazz->script_metrics_init )
       {
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -22,6 +22,7 @@
 
 
 #include "aftypes.h"
+#include "afmodule.h"
 
 
 FT_BEGIN_HEADER
@@ -57,6 +58,8 @@
 
     AF_ScriptMetrics  metrics[AF_SCRIPT_MAX];
 
+    AF_Module         module;         /* to access global properties */
+
   } AF_FaceGlobalsRec;
 
 
@@ -64,13 +67,11 @@
    *  model the global hints data for a given face, decomposed into
    *  script-specific items
    */
-  typedef struct AF_FaceGlobalsRec_*  AF_FaceGlobals;
 
-
   FT_LOCAL( FT_Error )
   af_face_globals_new( FT_Face          face,
                        AF_FaceGlobals  *aglobals,
-                       FT_UInt          fallback_script );
+                       AF_Module        module );
 
   FT_LOCAL( FT_Error )
   af_face_globals_get_metrics( AF_FaceGlobals     globals,
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -59,8 +59,7 @@
 
     if ( loader->globals == NULL )
     {
-      error = af_face_globals_new( face, &loader->globals,
-                                   module->fallback_script );
+      error = af_face_globals_new( face, &loader->globals, module );
       if ( !error )
       {
         face->autohint.data =
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -44,11 +44,12 @@
 
 
   FT_Error
-  af_property_set( FT_Module    module,
+  af_property_set( FT_Module    ft_module,
                    const char*  property_name,
                    const void*  value )
   {
-    FT_Error  error = AF_Err_Ok;
+    FT_Error   error  = AF_Err_Ok;
+    AF_Module  module = (AF_Module)ft_module;
 
 
     if ( !ft_strcmp( property_name, "fallback-script" ) )
@@ -56,7 +57,7 @@
       FT_UInt*  fallback_script = (FT_UInt*)value;
 
 
-      ((AF_Module)module)->fallback_script = *fallback_script;
+      module->fallback_script = *fallback_script;
 
       return error;
     }
@@ -68,12 +69,13 @@
 
 
   FT_Error
-  af_property_get( FT_Module    module,
+  af_property_get( FT_Module    ft_module,
                    const char*  property_name,
                    void*        value )
   {
-    FT_Error  error           = AF_Err_Ok;
-    FT_UInt   fallback_script = ((AF_Module)module)->fallback_script;
+    FT_Error   error           = AF_Err_Ok;
+    AF_Module  module          = (AF_Module)ft_module;
+    FT_UInt    fallback_script = module->fallback_script;
 
 
     if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
@@ -90,7 +92,7 @@
       {
         /* trigger computation of the global script data */
         /* in case it hasn't been done yet               */
-        error = af_face_globals_new( prop->face, &globals, fallback_script );
+        error = af_face_globals_new( prop->face, &globals, module );
         if ( !error )
         {
           prop->face->autohint.data =
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -246,6 +246,7 @@
 
 
   typedef struct AF_ScriptClassRec_ const*  AF_ScriptClass;
+  typedef struct AF_FaceGlobalsRec_*        AF_FaceGlobals;
 
   typedef struct  AF_ScriptMetricsRec_
   {
@@ -252,6 +253,8 @@
     AF_ScriptClass  clazz;
     AF_ScalerRec    scaler;
     FT_Bool         digits_have_same_width;
+
+    AF_FaceGlobals  globals;    /* to access properties */
 
   } AF_ScriptMetricsRec, *AF_ScriptMetrics;