尝试从 HMCL.jar 所在文件夹加载默认字体 (#3899)

This commit is contained in:
Glavo 2025-05-08 22:36:33 +08:00 committed by GitHub
parent 4eee79da17
commit 06a89dd6a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -29,6 +29,7 @@ import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.util.Lazy; import org.jackhuang.hmcl.util.Lazy;
import org.jackhuang.hmcl.util.Pair; import org.jackhuang.hmcl.util.Pair;
import org.jackhuang.hmcl.util.io.FileUtils; import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.io.JarUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -88,7 +89,15 @@ public class Theme {
if (font != null) if (font != null)
return font; return font;
return tryLoadDefaultFont(Metadata.HMCL_GLOBAL_DIRECTORY); font = tryLoadDefaultFont(Metadata.HMCL_GLOBAL_DIRECTORY);
if (font != null)
return font;
Path thisJar = JarUtils.thisJarPath();
if (thisJar != null && thisJar.getParent() != null)
return tryLoadDefaultFont(thisJar.getParent());
return null;
}); });
public static Theme getTheme() { public static Theme getTheme() {