mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Improve font loading check
This commit is contained in:
parent
7391310dce
commit
0b8fbfabe0
2 changed files with 3 additions and 19 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue