Improve font loading check

This commit is contained in:
crschnick 2024-03-23 13:11:05 +00:00
parent 7391310dce
commit 0b8fbfabe0
2 changed files with 3 additions and 19 deletions

View file

@ -1,31 +1,15 @@
package io.xpipe.app.core.check;
import io.xpipe.core.util.XPipeInstallation;
import javafx.scene.text.Font;
public class AppFontLoadingCheck {
public static void init() {
if (canLoadFonts()) {
return;
}
if (System.getProperty("prism.fontdir") != null) {
throw new IllegalStateException("Unable to load bundled fonts");
}
System.setProperty("prism.fontdir", XPipeInstallation.getBundledFontsPath().toString());
System.setProperty("prism.embeddedfonts", "true");
init();
}
private static boolean canLoadFonts() {
public static void check() {
try {
// This can fail if the found system fonts can somehow not be loaded
Font.getDefault();
return true;
} catch (Throwable e) {
return false;
throw new IllegalStateException("Unable to load fonts", e);
}
}
}

View file

@ -111,7 +111,7 @@ public enum PlatformState {
try {
latch.await();
// Check if we have no fonts and set properties to load bundled ones
AppFontLoadingCheck.init();
AppFontLoadingCheck.check();
PlatformState.setCurrent(PlatformState.RUNNING);
return Optional.empty();
} catch (InterruptedException e) {