8217731: Font rendering and glyph spacing changed from jdk-8 to jdk-11

Reviewed-by: serb, neugens
This commit is contained in:
Phil Race 2019-06-11 10:34:42 -07:00
parent 09efbc41ee
commit f9d8df7253

View File

@ -29,7 +29,10 @@
#include "sunfontids.h"
#include "sun_font_FreetypeFontScaler.h"
#include<stdlib.h>
#include <stdlib.h>
#if !defined(_WIN32) && !defined(__APPLE_)
#include <dlfcn.h>
#endif
#include <math.h>
#include "ft2build.h"
#include FT_FREETYPE_H
@ -39,6 +42,7 @@
#include FT_OUTLINE_H
#include FT_SYNTHESIS_H
#include FT_LCD_FILTER_H
#include FT_MODULE_H
#include "fontscaler.h"
@ -204,6 +208,52 @@ static unsigned long ReadTTFontFileFunc(FT_Stream stream,
}
}
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 @@ Java_sun_font_FreetypeFontScaler_initNativeScaler(
free(scalerInfo);
return 0;
}
setInterpreterVersion(scalerInfo->library);
#define TYPE1_FROM_JAVA 2