mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-04-28 00:10:48 -07:00
Fixed Japanese font being displayed incorrectly
This commit is contained in:
parent
0215cabda8
commit
65e4a22c84
4 changed files with 28 additions and 3 deletions
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.net.*;
|
||||
import mindustry.service.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
|
@ -301,7 +302,6 @@ public class Vars implements Loadable{
|
|||
Groups.init();
|
||||
|
||||
if(loadLocales){
|
||||
//load locales
|
||||
String[] stra = Core.files.internal("locales").readString().split("\n");
|
||||
locales = new Locale[stra.length];
|
||||
for(int i = 0; i < locales.length; i++){
|
||||
|
|
@ -551,5 +551,9 @@ public class Vars implements Loadable{
|
|||
StringMap globalBundle = new StringMap();
|
||||
PropertiesUtils.load(globalBundle, files.internal("bundles/global.properties").reader("UTF-8"));
|
||||
bundle.getProperties().putAll(globalBundle);
|
||||
|
||||
if(!headless){
|
||||
app.post(Fonts::loadExtraFonts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import mindustry.game.*;
|
|||
import mindustry.gen.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Fonts{
|
||||
private static final String mainFont = "fonts/font.woff";
|
||||
|
|
@ -99,6 +100,26 @@ public class Fonts{
|
|||
}})).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){
|
||||
return unicodeToName.get(unicode, () -> Iconc.codeToName.get(unicode));
|
||||
}
|
||||
|
|
@ -226,7 +247,7 @@ public class Fonts{
|
|||
|
||||
@Override
|
||||
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.spaceX -= parameter.fontParameters.borderWidth;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,4 @@ org.gradle.caching=true
|
|||
org.gradle.internal.http.socketTimeout=100000
|
||||
org.gradle.internal.http.connectionTimeout=100000
|
||||
android.enableR8.fullMode=false
|
||||
archash=962a97d8b6
|
||||
archash=cd9b89ef19
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue