Merge branch 'master' into 'master'

[Android] Fix startup with CJK Fonts

See merge request core-developers/forge!4113
This commit is contained in:
Anthony Calosa
2021-03-05 22:20:57 +00:00
2 changed files with 8 additions and 11 deletions

View File

@@ -79,6 +79,7 @@ public class Forge implements ApplicationListener {
public static int androidVersion = 0;
public static boolean autoCache = false;
public static int lastButtonIndex = 0;
public static String CJK_Font = "";
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
if (GuiBase.getInterface() == null) {
@@ -140,6 +141,7 @@ public class Forge implements ApplicationListener {
locale = prefs.getPref(FPref.UI_LANGUAGE);
autoCache = prefs.getPrefBoolean(FPref.UI_AUTO_CACHE_SIZE);
disposeTextures = prefs.getPrefBoolean(FPref.UI_ENABLE_DISPOSE_TEXTURES);
CJK_Font = prefs.getPref(FPref.UI_CJK_FONT);
if (autoCache) {
//increase cacheSize for devices with RAM more than 5GB, default is 400. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)

View File

@@ -18,9 +18,7 @@ import com.badlogic.gdx.utils.Array;
import forge.FThreads;
import forge.Forge;
//import forge.model.FModel;
import forge.properties.ForgeConstants;
//import forge.properties.ForgePreferences.FPref;
import forge.util.FileUtil;
import forge.util.LineReader;
import forge.util.TextBounds;
@@ -380,11 +378,10 @@ public class FSkinFont {
return;
}
//String locale = FModel.getPreferences().getPref(FPref.UI_LANGUAGE);
String fontName = "f" + fontSize;
/*if (locale.equals("zh-CN") || locale.equals("ja-JP")) {
fontName += locale;
}*/
if (Forge.locale.equals("zh-CN") || Forge.locale.equals("ja-JP")) {
fontName += Forge.locale;
}
FileHandle fontFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + fontName + ".fnt");
if (fontFile != null && fontFile.exists()) {
final BitmapFontData data = new BitmapFontData(fontFile, false);
@@ -395,17 +392,15 @@ public class FSkinFont {
}
});
} else {
generateFont(FSkin.getSkinFile(TTF_FILE), fontName, fontSize);
/*
if (locale.equals("zh-CN") || locale.equals("ja-JP")) {
String ttfName = FModel.getPreferences().getPref(FPref.UI_CJK_FONT);
if (Forge.locale.equals("zh-CN") || Forge.locale.equals("ja-JP")) {
String ttfName = Forge.CJK_Font;
FileHandle ttfFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + ttfName + ".ttf");
if (ttfFile != null && ttfFile.exists()) {
generateFont(ttfFile, fontName, fontSize);
}
} else {
generateFont(FSkin.getSkinFile(TTF_FILE), fontName, fontSize);
}*/
}
}
}