--- old/src/share/native/sun/font/freetypeScaler.c 2019-08-28 01:11:50.155142785 +0000 +++ new/src/share/native/sun/font/freetypeScaler.c 2019-08-28 01:11:50.075142296 +0000 @@ -29,7 +29,10 @@ #include "sunfontids.h" #include "sun_font_FreetypeFontScaler.h" -#include +#include +#if !defined(_WIN32) && !defined(__APPLE_) +#include +#endif #include #include "ft2build.h" #include FT_FREETYPE_H @@ -38,6 +41,7 @@ #include FT_SIZES_H #include FT_OUTLINE_H #include FT_SYNTHESIS_H +#include FT_MODULE_H #include "fontscaler.h" @@ -204,6 +208,52 @@ } } +typedef FT_Error (*FT_Prop_Set_Func)(FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + const void* value ); + +/** + * Prefer the older v35 freetype byte code interpreter. + */ +static void setInterpreterVersion(FT_Library library) { + + char* props = getenv("FREETYPE_PROPERTIES"); + int version = 35; + const char* module = "truetype"; + const char* property = "interpreter-version"; + + /* If some one is setting this, don't override it */ + if (props != NULL && strstr(property, props)) { + return; + } + /* + * FT_Property_Set was introduced in 2.4.11. + * Some older supported Linux OSes may not include it so look + * this up dynamically. + * And if its not available it doesn't matter, since the reason + * we need it dates from 2.7. + * On Windows & Mac the library is always bundled so it is safe + * to use directly in those cases. + */ +#if defined(_WIN32) || defined(__APPLE__) + FT_Property_Set(library, module, property, (void*)(&version)); +#else + void *lib = dlopen("libfreetype.so", RTLD_LOCAL|RTLD_LAZY); + if (lib == NULL) { + lib = dlopen("libfreetype.so.6", RTLD_LOCAL|RTLD_LAZY); + if (lib == NULL) { + return; + } + } + FT_Prop_Set_Func func = (FT_Prop_Set_Func)dlsym(lib, "FT_Property_Set"); + if (func != NULL) { + func(library, module, property, (void*)(&version)); + } + dlclose(lib); +#endif +} + /* * Class: sun_font_FreetypeFontScaler * Method: initNativeScaler @@ -243,6 +293,7 @@ free(scalerInfo); return 0; } + setInterpreterVersion(scalerInfo->library); #define TYPE1_FROM_JAVA 2