[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.
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
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 ));