Fixed Japanese font being displayed incorrectly
This commit is contained in:
BIN
core/assets/fonts/font_jp.woff
Normal file
BIN
core/assets/fonts/font_jp.woff
Normal file
Binary file not shown.
@@ -28,6 +28,7 @@ import mindustry.maps.*;
|
|||||||
import mindustry.mod.*;
|
import mindustry.mod.*;
|
||||||
import mindustry.net.*;
|
import mindustry.net.*;
|
||||||
import mindustry.service.*;
|
import mindustry.service.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
@@ -301,7 +302,6 @@ public class Vars implements Loadable{
|
|||||||
Groups.init();
|
Groups.init();
|
||||||
|
|
||||||
if(loadLocales){
|
if(loadLocales){
|
||||||
//load locales
|
|
||||||
String[] stra = Core.files.internal("locales").readString().split("\n");
|
String[] stra = Core.files.internal("locales").readString().split("\n");
|
||||||
locales = new Locale[stra.length];
|
locales = new Locale[stra.length];
|
||||||
for(int i = 0; i < locales.length; i++){
|
for(int i = 0; i < locales.length; i++){
|
||||||
@@ -551,5 +551,9 @@ public class Vars implements Loadable{
|
|||||||
StringMap globalBundle = new StringMap();
|
StringMap globalBundle = new StringMap();
|
||||||
PropertiesUtils.load(globalBundle, files.internal("bundles/global.properties").reader("UTF-8"));
|
PropertiesUtils.load(globalBundle, files.internal("bundles/global.properties").reader("UTF-8"));
|
||||||
bundle.getProperties().putAll(globalBundle);
|
bundle.getProperties().putAll(globalBundle);
|
||||||
|
|
||||||
|
if(!headless){
|
||||||
|
app.post(Fonts::loadExtraFonts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import mindustry.game.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class Fonts{
|
public class Fonts{
|
||||||
private static final String mainFont = "fonts/font.woff";
|
private static final String mainFont = "fonts/font.woff";
|
||||||
@@ -99,6 +100,26 @@ public class Fonts{
|
|||||||
}})).loaded = f -> Fonts.logic = f;
|
}})).loaded = f -> Fonts.logic = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void loadExtraFonts(){
|
||||||
|
//Japanese needs to override the default font with its own characters - see https://heistak.github.io/your-code-displays-japanese-wrong/
|
||||||
|
if(Locale.getDefault().getLanguage().equals("ja")){
|
||||||
|
Core.assets.load("font_jp", Font.class, new FreeTypeFontLoaderParameter("fonts/font_jp.woff", new FreeTypeFontParameter(){{
|
||||||
|
size = 18;
|
||||||
|
incremental = true;
|
||||||
|
shadowColor = Color.darkGray;
|
||||||
|
shadowOffsetY = 2;
|
||||||
|
characters = "\u0000 ";
|
||||||
|
}})).loaded = f -> Fonts.def.data.setOverride(f.data);
|
||||||
|
|
||||||
|
Core.assets.load("font_jp_outline", Font.class, new FreeTypeFontLoaderParameter("fonts/font_jp.woff", new FreeTypeFontParameter(){{
|
||||||
|
size = 18;
|
||||||
|
incremental = true;
|
||||||
|
borderColor = Color.darkGray;
|
||||||
|
characters = "\u0000 ";
|
||||||
|
}})).loaded = f -> Fonts.outline.data.setOverride(f.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static @Nullable String unicodeToName(int unicode){
|
public static @Nullable String unicodeToName(int unicode){
|
||||||
return unicodeToName.get(unicode, () -> Iconc.codeToName.get(unicode));
|
return unicodeToName.get(unicode, () -> Iconc.codeToName.get(unicode));
|
||||||
}
|
}
|
||||||
@@ -226,7 +247,7 @@ public class Fonts{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Font loadSync(AssetManager manager, String fileName, Fi file, FreeTypeFontLoaderParameter parameter){
|
public Font loadSync(AssetManager manager, String fileName, Fi file, FreeTypeFontLoaderParameter parameter){
|
||||||
if(fileName.equals("outline")){
|
if(fileName.endsWith("outline")){
|
||||||
parameter.fontParameters.borderWidth = Scl.scl(2f);
|
parameter.fontParameters.borderWidth = Scl.scl(2f);
|
||||||
parameter.fontParameters.spaceX -= parameter.fontParameters.borderWidth;
|
parameter.fontParameters.spaceX -= parameter.fontParameters.borderWidth;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ org.gradle.caching=true
|
|||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
android.enableR8.fullMode=false
|
android.enableR8.fullMode=false
|
||||||
archash=962a97d8b6
|
archash=cd9b89ef19
|
||||||
|
|||||||
Reference in New Issue
Block a user