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.
This commit is contained in:
Werner Lemberg 2016-07-10 07:11:45 +02:00
parent 83c877f11c
commit c3beb30a21
7 changed files with 145 additions and 35 deletions

View File

@ -1,3 +1,26 @@
2016-07-09 Werner Lemberg <wl@gnu.org>
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 <mpsuzuki@hiroshima-u.ac.jp>
[mac] Fix ftexport.sym target in Jamfile.

View File

@ -532,6 +532,12 @@ FT_BEGIN_HEADER
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 );
/* */

View File

@ -29,7 +29,8 @@ FT_BEGIN_HEADER
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,

View File

@ -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,10 +116,14 @@
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 */
@ -147,19 +152,29 @@
}
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;
}
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,17 +199,23 @@
#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 ||
@ -210,9 +236,14 @@
}
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;
return error;

View File

@ -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,10 +4674,29 @@
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 );
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/

View File

@ -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,17 +668,23 @@
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 ||
@ -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,9 +726,14 @@
}
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;
return error;

View File

@ -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,9 +70,14 @@
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
|| *interpreter_version == TT_INTERPRETER_VERSION_38