From be997becc28dfbf2077cca55dc9a6a090d13e22a Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Wed, 15 Jun 2016 14:10:20 +0200 Subject: [PATCH 3/4] Make subpixel hinting mode configurable --- include/freetype/config/ftoption.h | 2 +- src/truetype/ttobjs.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index 8e58403529f597e5..197e15cdc3cc1e74 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -632,7 +632,7 @@ FT_BEGIN_HEADER /* */ /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */ /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2 */ -/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */ +#define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) /*************************************************************************/ diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index ed3be2dbee79427c..d89f92e94d0e816b 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -36,6 +36,9 @@ #include "ttgxvar.h" #endif +#include +#include + /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ @@ -1286,6 +1289,7 @@ #ifdef TT_USE_BYTECODE_INTERPRETER TT_Driver driver = (TT_Driver)ttdriver; + const char *envval; driver->interpreter_version = TT_INTERPRETER_VERSION_35; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY @@ -1295,6 +1299,39 @@ driver->interpreter_version = TT_INTERPRETER_VERSION_40; #endif + errno = 0; + envval = getenv( "FT2_SUBPIXEL_HINTING" ); + if ( envval ) + { + char *endptr = NULL; + unsigned long value = strtoul( envval, &endptr, 10 ); + + if ( !errno && endptr && !*endptr ) + { + switch( value ) + { + case 0: + driver->interpreter_version = TT_INTERPRETER_VERSION_35; + break; + +#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY + case 1: + driver->interpreter_version = TT_INTERPRETER_VERSION_38; + break; +#endif + +#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL + case 2: + driver->interpreter_version = TT_INTERPRETER_VERSION_40; + break; +#endif + + default: + break; + } + } + } + #else /* !TT_USE_BYTECODE_INTERPRETER */ FT_UNUSED( ttdriver ); -- 2.9.0