IDEA-151619 CLion EAP fails to start with missing symbol: FT_Library_setLcdFilter

Skip FT_Library_setLcdFilter call if the symbol is not there
Cache negative FT_Library_setLcdFilter symbol lookup result
Used RTLD_DEFAULT handler for process symbols lookup

(cherry picked from commit e6f0055704)
(cherry picked from commit dfbc7d7cc2)
This commit is contained in:
Alexey Ushakov
2016-04-15 01:14:55 +03:00
committed by jbrbot
parent d87971f91b
commit 5025b63598

View File

@@ -160,6 +160,7 @@ typedef FcPattern* (*FcFontMatchPtrType) (FcConfig *config, FcPattern *p, FcResu
typedef void (*FcPatternDestroyPtrType) (FcPattern *p);
typedef FcResult (*FcPatternGetBoolPtrType) (const FcPattern *p, const char *object, int n, FcBool *b);
typedef FcResult (*FcPatternGetIntegerPtrType) (const FcPattern *p, const char *object, int n, int *i);
typedef FT_Error (*FtLibrarySetLcdFilterPtrType) (FT_Library library, FT_LcdFilter filter);
#endif
static void *libFontConfig = NULL;
@@ -246,6 +247,28 @@ Java_sun_font_FreetypeFontScaler_initIDs(
#endif
}
static FT_Error FT_Library_SetLcdFilter_Proxy(FT_Library library, FT_LcdFilter filter) {
#ifndef DISABLE_FONTCONFIG
static FtLibrarySetLcdFilterPtrType FtLibrarySetLcdFilterPtr = NULL;
static int ftLibrarySetLcdFilterNotChecked = 1;
if (ftLibrarySetLcdFilterNotChecked) {
if (logFC) fprintf(stderr, "FC_LOG: Lookup FT_Library_SetLcdFilter: ");
FtLibrarySetLcdFilterPtr = (FtLibrarySetLcdFilterPtrType) dlsym(RTLD_DEFAULT, "FT_Library_SetLcdFilter");
if (logFC) fprintf(stderr, (FtLibrarySetLcdFilterPtr)? "found\n" : "not found\n");
ftLibrarySetLcdFilterNotChecked = 0;
}
if (FtLibrarySetLcdFilterPtr) {
return (*FtLibrarySetLcdFilterPtr)(library, filter);
} else {
if (logFC) fprintf(stderr, "FC_LOG: Skipping FT_Library_SetLcdFilter\n");
}
return 0;
#else
return FT_Library_SetLcdFilter(library, filter);
#endif
}
static char* getPhysFontName(JNIEnv *env, jobject font2d) {
jstring jstr;
jstr = (*env)->GetObjectField(env, font2d, platNameFID);
@@ -1417,7 +1440,7 @@ static jlong
ftglyph = scalerInfo->face->glyph;
library = ftglyph->library;
FT_Library_SetLcdFilter (library, context->lcdFilter);
FT_Library_SetLcdFilter_Proxy(library, context->lcdFilter);
/* apply styles */
if (context->doBold) { /* if bold style */