ref: c3beb30a21a8ea9f20f6c557bba7a07106ef2d1b
parent: 83c877f11c6cbd99cb203447d248748ad45624c3
author: Werner Lemberg <[email protected]>
date: Sun Jul 10 03:11:45 EDT 2016
Add function `ft_property_string_set'. This is a preparation for handling an `FREETYPE_PROPERTIES' environment variable to control (some) driver properties. No change in functionality. * src/base/ftobjs.c (ft_property_do): Add `value_is_string' parameter. (ft_property_string_set): New function. (FT_Property_Set, FT_Property_Get): Updated. * include/freetype/internal/ftobjs.h: Updated. * include/freetype/internal/services/svprop.h (FT_Properties_SetFunc): Add `value_is_string' parameter. * src/autofit/afmodule.c (af_property_set), src/cff/cffdrivr.c (cff_property_set), src/truetype/ttdriver.c (tt_property_set): Updated, emitting an error currently if `value_is_string' is set.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2016-07-09 Werner Lemberg <[email protected]>
+
+ Add function `ft_property_string_set'.
+
+ This is a preparation for handling an `FREETYPE_PROPERTIES'
+ environment variable to control (some) driver properties.
+
+ No change in functionality.
+
+ * src/base/ftobjs.c (ft_property_do): Add `value_is_string'
+ parameter.
+ (ft_property_string_set): New function.
+ (FT_Property_Set, FT_Property_Get): Updated.
+
+ * include/freetype/internal/ftobjs.h: Updated.
+
+ * include/freetype/internal/services/svprop.h
+ (FT_Properties_SetFunc): Add `value_is_string' parameter.
+
+ * src/autofit/afmodule.c (af_property_set), src/cff/cffdrivr.c
+ (cff_property_set), src/truetype/ttdriver.c (tt_property_set):
+ Updated, emitting an error currently if `value_is_string' is set.
+
2016-07-09 suzuki toshiya <[email protected]>
[mac] Fix ftexport.sym target in Jamfile.
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -532,6 +532,12 @@
ft_module_get_service( FT_Module module,
const char* service_id );
+ FT_BASE( FT_Error )
+ ft_property_string_set( FT_Library library,
+ const FT_String* module_name,
+ const FT_String* property_name,
+ FT_String* value );
+
/* */
--- a/include/freetype/internal/services/svprop.h
+++ b/include/freetype/internal/services/svprop.h
@@ -29,7 +29,8 @@
typedef FT_Error
(*FT_Properties_SetFunc)( FT_Module module,
const char* property_name,
- const void* value );
+ const void* value,
+ FT_Bool value_is_string );
typedef FT_Error
(*FT_Properties_GetFunc)( FT_Module module,
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -107,7 +107,8 @@
static FT_Error
af_property_set( FT_Module ft_module,
const char* property_name,
- const void* value )
+ const void* value,
+ FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
AF_Module module = (AF_Module)ft_module;
@@ -115,11 +116,15 @@
if ( !ft_strcmp( property_name, "fallback-script" ) )
{
- FT_UInt* fallback_script = (FT_UInt*)value;
+ FT_UInt* fallback_script;
+ FT_UInt ss;
- FT_UInt ss;
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+ fallback_script = (FT_UInt*)value;
+
/* We translate the fallback script to a fallback style that uses */
/* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */
/* coverage value. */
@@ -147,9 +152,14 @@
}
else if ( !ft_strcmp( property_name, "default-script" ) )
{
- FT_UInt* default_script = (FT_UInt*)value;
+ FT_UInt* default_script;
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+
+ default_script = (FT_UInt*)value;
+
module->default_script = *default_script;
return error;
@@ -156,10 +166,15 @@
}
else if ( !ft_strcmp( property_name, "increase-x-height" ) )
{
- FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
+ FT_Prop_IncreaseXHeight* prop;
AF_FaceGlobals globals;
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+
+ prop = (FT_Prop_IncreaseXHeight*)value;
+
error = af_property_get_face_globals( prop->face, &globals, module );
if ( !error )
globals->increase_x_height = prop->limit;
@@ -169,9 +184,14 @@
#ifdef AF_CONFIG_OPTION_USE_WARPER
else if ( !ft_strcmp( property_name, "warping" ) )
{
- FT_Bool* warping = (FT_Bool*)value;
+ FT_Bool* warping;
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+
+ warping = (FT_Bool*)value;
+
module->warping = *warping;
return error;
@@ -179,18 +199,24 @@
#endif /* AF_CONFIG_OPTION_USE_WARPER */
else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
- FT_Int* darken_params = (FT_Int*)value;
+ FT_Int* darken_params;
+ FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
- FT_Int x1 = darken_params[0];
- FT_Int y1 = darken_params[1];
- FT_Int x2 = darken_params[2];
- FT_Int y2 = darken_params[3];
- FT_Int x3 = darken_params[4];
- FT_Int y3 = darken_params[5];
- FT_Int x4 = darken_params[6];
- FT_Int y4 = darken_params[7];
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+ darken_params = (FT_Int*)value;
+
+ x1 = darken_params[0];
+ y1 = darken_params[1];
+ x2 = darken_params[2];
+ y2 = darken_params[3];
+ x3 = darken_params[4];
+ y3 = darken_params[5];
+ x4 = darken_params[6];
+ y4 = darken_params[7];
+
if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
x1 > x2 || x2 > x3 || x3 > x4 ||
@@ -210,8 +236,13 @@
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
{
- FT_Bool* no_stem_darkening = (FT_Bool*)value;
+ FT_Bool* no_stem_darkening;
+
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+
+ no_stem_darkening = (FT_Bool*)value;
module->no_stem_darkening = *no_stem_darkening;
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4564,7 +4564,8 @@
const FT_String* module_name,
const FT_String* property_name,
void* value,
- FT_Bool set )
+ FT_Bool set,
+ FT_Bool value_is_string )
{
FT_Module* cur;
FT_Module* limit;
@@ -4634,8 +4635,13 @@
return FT_THROW( Unimplemented_Feature );
}
- return set ? service->set_property( cur[0], property_name, value )
- : service->get_property( cur[0], property_name, value );
+ return set ? service->set_property( cur[0],
+ property_name,
+ value,
+ value_is_string )
+ : service->get_property( cur[0],
+ property_name,
+ value );
}
@@ -4651,7 +4657,8 @@
module_name,
property_name,
(void*)value,
- TRUE );
+ TRUE,
+ FALSE );
}
@@ -4667,7 +4674,26 @@
module_name,
property_name,
value,
+ FALSE,
FALSE );
+ }
+
+
+ /* this variant is used for handling the FREETYPE_PROPERTIES */
+ /* environment variable */
+
+ FT_BASE_DEF( FT_Error )
+ ft_property_string_set( FT_Library library,
+ const FT_String* module_name,
+ const FT_String* property_name,
+ FT_String* value )
+ {
+ return ft_property_do( library,
+ module_name,
+ property_name,
+ (void*)value,
+ TRUE,
+ TRUE );
}
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -659,7 +659,8 @@
static FT_Error
cff_property_set( FT_Module module, /* CFF_Driver */
const char* property_name,
- const void* value )
+ const void* value,
+ FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
CFF_Driver driver = (CFF_Driver)module;
@@ -667,18 +668,24 @@
if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
- FT_Int* darken_params = (FT_Int*)value;
+ FT_Int* darken_params;
+ FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
- FT_Int x1 = darken_params[0];
- FT_Int y1 = darken_params[1];
- FT_Int x2 = darken_params[2];
- FT_Int y2 = darken_params[3];
- FT_Int x3 = darken_params[4];
- FT_Int y3 = darken_params[5];
- FT_Int x4 = darken_params[6];
- FT_Int y4 = darken_params[7];
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+ darken_params = (FT_Int*)value;
+
+ x1 = darken_params[0];
+ y1 = darken_params[1];
+ x2 = darken_params[2];
+ y2 = darken_params[3];
+ x3 = darken_params[4];
+ y3 = darken_params[5];
+ x4 = darken_params[6];
+ y4 = darken_params[7];
+
if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
x1 > x2 || x2 > x3 || x3 > x4 ||
@@ -698,9 +705,14 @@
}
else if ( !ft_strcmp( property_name, "hinting-engine" ) )
{
- FT_UInt* hinting_engine = (FT_UInt*)value;
+ FT_UInt* hinting_engine;
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+
+ hinting_engine = (FT_UInt*)value;
+
if ( *hinting_engine == FT_CFF_HINTING_ADOBE
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
|| *hinting_engine == FT_CFF_HINTING_FREETYPE
@@ -714,8 +726,13 @@
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
{
- FT_Bool* no_stem_darkening = (FT_Bool*)value;
+ FT_Bool* no_stem_darkening;
+
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+
+ no_stem_darkening = (FT_Bool*)value;
driver->no_stem_darkening = *no_stem_darkening;
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -61,7 +61,8 @@
static FT_Error
tt_property_set( FT_Module module, /* TT_Driver */
const char* property_name,
- const void* value )
+ const void* value,
+ FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
TT_Driver driver = (TT_Driver)module;
@@ -69,8 +70,13 @@
if ( !ft_strcmp( property_name, "interpreter-version" ) )
{
- FT_UInt* interpreter_version = (FT_UInt*)value;
+ FT_UInt* interpreter_version;
+
+ if ( value_is_string )
+ return FT_THROW( Invalid_Argument );
+
+ interpreter_version = (FT_UInt*)value;
if ( *interpreter_version == TT_INTERPRETER_VERSION_35
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY