summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2016-07-10 07:11:45 +0200
committerWerner Lemberg <wl@gnu.org>2016-07-10 07:11:45 +0200
commitc3beb30a21a8ea9f20f6c557bba7a07106ef2d1b (patch)
treed9d6b6994b41c9eed01f1a5477de7ca813f10071
parent83c877f11c6cbd99cb203447d248748ad45624c3 (diff)
downloadfreetype2-c3beb30a21a8ea9f20f6c557bba7a07106ef2d1b.tar.gz
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.
-rw-r--r--ChangeLog23
-rw-r--r--include/freetype/internal/ftobjs.h6
-rw-r--r--include/freetype/internal/services/svprop.h3
-rw-r--r--src/autofit/afmodule.c63
-rw-r--r--src/base/ftobjs.c34
-rw-r--r--src/cff/cffdrivr.c41
-rw-r--r--src/truetype/ttdriver.c10
7 files changed, 145 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index 9a834c54d..085372581 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index e3fa32083..6b68d91c3 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -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 );
+
/* */
diff --git a/include/freetype/internal/services/svprop.h b/include/freetype/internal/services/svprop.h
index 870e90ed7..75e62446b 100644
--- a/include/freetype/internal/services/svprop.h
+++ b/include/freetype/internal/services/svprop.h
@@ -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,
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 4127382c0..03680beac 100644
--- 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,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,8 +152,13 @@
}
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;
@@ -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,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,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;
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index c2dc6183b..c26585504 100644
--- 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,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 );
+ }
+
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 950a9605c..88bb7e6fc 100644
--- 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,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,8 +705,13 @@
}
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
@@ -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;
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index c9d4081ef..83a804290 100644
--- 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