ref: 753e1131eeadcfec4bf2c24fdaf67bf9d3005b6e
parent: ca1486c32a374b80ae665610dc86f2fa39221d6f
author: Werner Lemberg <[email protected]>
date: Mon Feb 20 04:01:14 EST 2017
[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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2017-02-20 Werner Lemberg <[email protected]>
+ [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 <[email protected]>
+
[cff] Introduce `random-seed' property (1/2).
We need this for support of the `random' operator.
--- 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,
@@ -3649,6 +3652,20 @@
error = FT_THROW( Unimplemented_Feature );
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
{
--- 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 ));