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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
diff --git a/ChangeLog b/ChangeLog
index 9a834c5..0853725 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 e3fa320..6b68d91 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 870e90e..75e6244 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 4127382..03680be 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 c2dc618..c265855 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 950a960..88bb7e6 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 c9d4081..83a8042 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