[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.
This commit is contained in:
Werner Lemberg 2017-02-20 09:01:14 +01:00
parent ca1486c32a
commit 753e1131ee
3 changed files with 52 additions and 0 deletions

View File

@ -1,3 +1,14 @@
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).

View File

@ -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 );

View File

@ -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 ));