mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-5844: fix case with non-scalable face
(cherry picked from commit 490080a315)
This commit is contained in:
@@ -84,6 +84,7 @@ static char *fullAixFontPath[] = {
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef FcConfig* (*FcInitLoadConfigFuncType)();
|
||||
typedef FcPattern* (*FcPatternBuildFuncType)(FcPattern *orig, ...);
|
||||
@@ -253,6 +254,10 @@ void openFontConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
static bool usingFontConfig() {
|
||||
return (libfontconfig != NULL) ? true : false;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNI_OnUnload(JavaVM *vm, void *reserved) {
|
||||
closeFontConfig();
|
||||
@@ -260,6 +265,10 @@ JNI_OnUnload(JavaVM *vm, void *reserved) {
|
||||
|
||||
JNIEXPORT char **getFontConfigLocations() {
|
||||
|
||||
if (usingFontConfig() == false) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char **fontdirs;
|
||||
int numdirs = 0;
|
||||
|
||||
@@ -383,6 +392,10 @@ JNIEXPORT jint JNICALL
|
||||
Java_sun_font_FontConfigManager_getFontConfigVersion
|
||||
(JNIEnv *env, jclass obj) {
|
||||
|
||||
if (usingFontConfig() == false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (*fcGetVersion)();
|
||||
}
|
||||
|
||||
@@ -391,6 +404,10 @@ Java_sun_font_FontConfigManager_setupFontConfigFonts
|
||||
(JNIEnv *env, jclass obj, jstring localeStr, jobject fcInfoObj,
|
||||
jobjectArray fcCompFontArray, jboolean includeFallbacks) {
|
||||
|
||||
if (usingFontConfig() == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i, arrlen;
|
||||
jobject fcCompFontObj;
|
||||
jstring fcNameStr, jstr;
|
||||
@@ -408,14 +425,9 @@ Java_sun_font_FontConfigManager_setupFontConfigFonts
|
||||
CHECK_NULL(fcInfoObj);
|
||||
CHECK_NULL(fcCompFontArray);
|
||||
|
||||
fcInfoClass = (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigInfo");
|
||||
CHECK_NULL(fcInfoClass);
|
||||
fcCompFontClass = (*env)->FindClass(env, "sun/font/FontConfigManager$FcCompFont");
|
||||
CHECK_NULL(fcCompFontClass);
|
||||
fcFontClass = (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigFont");
|
||||
CHECK_NULL(fcFontClass);
|
||||
|
||||
|
||||
CHECK_NULL(fcInfoClass = (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigInfo"));
|
||||
CHECK_NULL(fcCompFontClass = (*env)->FindClass(env, "sun/font/FontConfigManager$FcCompFont"));
|
||||
CHECK_NULL(fcFontClass = (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigFont"));
|
||||
CHECK_NULL(fcVersionID = (*env)->GetFieldID(env, fcInfoClass, "fcVersion", "I"));
|
||||
CHECK_NULL(fcCacheDirsID = (*env)->GetFieldID(env, fcInfoClass, "cacheDirs", "[Ljava/lang/String;"));
|
||||
CHECK_NULL(fcNameID = (*env)->GetFieldID(env, fcCompFontClass, "fcName", "Ljava/lang/String;"));
|
||||
@@ -727,6 +739,10 @@ JNIEXPORT jint JNICALL
|
||||
Java_sun_font_FontConfigManager_getFontConfigAASettings
|
||||
(JNIEnv *env, jclass obj, jstring fcNameStr, jstring localeStr) {
|
||||
|
||||
if (usingFontConfig() == false) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rgba = 0;
|
||||
const char *locale=NULL, *fcName=NULL;
|
||||
|
||||
@@ -774,6 +790,10 @@ JNIEXPORT jstring JNICALL
|
||||
Java_sun_font_FontConfigManager_getFontProperty
|
||||
(JNIEnv *env, jclass obj, jstring query, jstring property) {
|
||||
|
||||
if (usingFontConfig() == false) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *queryPtr = NULL;
|
||||
const char *propertyPtr = NULL;
|
||||
FcChar8 *fontFamily = NULL;
|
||||
|
||||
@@ -823,6 +823,7 @@ static int setupFTContext(JNIEnv *env, jobject font2D, FTScalerInfo *scalerInfo,
|
||||
|
||||
if (FT_IS_SCALABLE(scalerInfo->face)) { // Standard scalable face
|
||||
context->fixedSizeIndex = -1;
|
||||
errCode = FT_Set_Char_Size(scalerInfo->face, 0, context->ptsz, 72, 72);
|
||||
} else { // Non-scalable face (that should only be bitmap faces)
|
||||
const int ptsz = context->ptsz;
|
||||
// Best size is smallest, but not smaller than requested
|
||||
@@ -839,9 +840,9 @@ static int setupFTContext(JNIEnv *env, jobject font2D, FTScalerInfo *scalerInfo,
|
||||
}
|
||||
}
|
||||
context->fixedSizeIndex = bestSizeIndex;
|
||||
errCode = FT_Set_Char_Size(scalerInfo->face, 0, bestSize, 72, 72);
|
||||
}
|
||||
|
||||
errCode = FT_Set_Char_Size(scalerInfo->face, 0, context->ptsz, 72, 72);
|
||||
if (errCode) return errCode;
|
||||
|
||||
errCode = FT_Activate_Size(scalerInfo->face->size);
|
||||
@@ -852,7 +853,10 @@ static int setupFTContext(JNIEnv *env, jobject font2D, FTScalerInfo *scalerInfo,
|
||||
context->lcdFilter = FT_LCD_FILTER_NONE;
|
||||
context->loadFlags = FT_LOAD_DEFAULT;
|
||||
|
||||
#ifndef DISABLE_FONTCONFIG
|
||||
#ifdef DISABLE_FONTCONFIG
|
||||
setDefaultScalerSettings(context);
|
||||
return 0;
|
||||
#else
|
||||
jfontFamilyName = (*env)->GetObjectField(env, font2D, familyNameFID);
|
||||
cfontFamilyName = (*env)->GetStringUTFChars(env, jfontFamilyName, NULL);
|
||||
jfontPath = (*env)->GetObjectField(env, font2D, platNameFID);
|
||||
|
||||
Reference in New Issue
Block a user