Commit 753e1131eeadcfec4bf2c24fdaf67bf9d3005b6e

Werner Lemberg 2017-02-20T09:01:14

[cff] Introduce `random-seed' property (2/2). * src/base/ftobjs.c: Include `FT_CFF_DRIVER_H'. (open_face): Initialize `face->internal->random_seed'. (FT_Face_Properties): Handle `FT_PARAM_TAG_RANDOM_SEED'. * src/cff/cffdrivr.c (cff_property_set): Handle `random-seed' property.

diff --git a/ChangeLog b/ChangeLog
index 9ec0b1f..98f58cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2017-02-20  Werner Lemberg  <wl@gnu.org>
 
+	[cff] Introduce `random-seed' property (2/2).
+
+	* src/base/ftobjs.c: Include `FT_CFF_DRIVER_H'.
+	(open_face): Initialize `face->internal->random_seed'.
+	(FT_Face_Properties): Handle `FT_PARAM_TAG_RANDOM_SEED'.
+
+	* src/cff/cffdrivr.c (cff_property_set): Handle `random-seed'
+	property.
+
+2017-02-20  Werner Lemberg  <wl@gnu.org>
+
 	[cff] Introduce `random-seed' property (1/2).
 
 	We need this for support of the `random' operator.
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index d9ce466..f86369e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -38,6 +38,7 @@
 #include FT_SERVICE_TRUETYPE_ENGINE_H
 
 #include FT_AUTOHINTER_H
+#include FT_CFF_DRIVER_H
 
 #ifdef FT_CONFIG_OPTION_MAC_FONTS
 #include "ftbase.h"
@@ -1188,6 +1189,8 @@
     }
 #endif
 
+    face->internal->random_seed = -1;
+
     if ( clazz->init_face )
       error = clazz->init_face( *astream,
                                 face,
@@ -3650,6 +3653,20 @@
         goto Exit;
 #endif
       }
+      else if ( properties->tag == FT_PARAM_TAG_RANDOM_SEED )
+      {
+        if ( properties->data )
+        {
+          face->internal->random_seed = *( (FT_Int32*)properties->data );
+          if ( face->internal->random_seed < 0 )
+            face->internal->random_seed = 0;
+        }
+        else
+        {
+          /* use module default */
+          face->internal->random_seed = -1;
+        }
+      }
       else
       {
         error = FT_THROW( Invalid_Argument );
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index fe28574..38bfc2c 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -871,6 +871,30 @@
 
       return error;
     }
+    else if ( !ft_strcmp( property_name, "random-seed" ) )
+    {
+      FT_Int32  random_seed;
+
+
+#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+      if ( value_is_string )
+      {
+        const char*  s = (const char*)value;
+
+
+        random_seed = (FT_Int32)ft_strtol( s, NULL, 10 );
+      }
+      else
+#endif
+        random_seed = *(FT_Int32*)value;
+
+      if ( random_seed < 0 )
+        random_seed = 0;
+
+      driver->random_seed = random_seed;
+
+      return error;
+    }
 
     FT_TRACE0(( "cff_property_set: missing property `%s'\n",
                 property_name ));