diff --git a/app/src/main/java/io/xpipe/app/core/AppBundledFonts.java b/app/src/main/java/io/xpipe/app/core/AppBundledFonts.java new file mode 100644 index 000000000..a3bc58853 --- /dev/null +++ b/app/src/main/java/io/xpipe/app/core/AppBundledFonts.java @@ -0,0 +1,34 @@ +package io.xpipe.app.core; + +import io.xpipe.core.process.OsType; +import io.xpipe.core.util.XPipeInstallation; + +import java.util.concurrent.TimeUnit; + +public class AppBundledFonts { + + public static void init() { + if (OsType.getLocal() != OsType.LINUX) { + return; + } + + if (hasFonts()) { + return; + } + + System.setProperty("prism.fontdir", XPipeInstallation.getBundledFontsPath().toString()); + System.setProperty("prism.embeddedfonts", "true"); + } + + private static boolean hasFonts() { + var fc = new ProcessBuilder("fc-match").redirectError(ProcessBuilder.Redirect.DISCARD); + try { + var proc = fc.start(); + var out = new String(proc.getInputStream().readAllBytes()); + proc.waitFor(1, TimeUnit.SECONDS); + return proc.exitValue() == 0 && !out.isEmpty(); + } catch (Exception e) { + return false; + } + } +} diff --git a/app/src/main/java/io/xpipe/app/core/AppProperties.java b/app/src/main/java/io/xpipe/app/core/AppProperties.java index 62559317a..d498da878 100644 --- a/app/src/main/java/io/xpipe/app/core/AppProperties.java +++ b/app/src/main/java/io/xpipe/app/core/AppProperties.java @@ -68,11 +68,6 @@ public class AppProperties { } } - public static void setDynamicProperties() { - System.setProperty("prism.fontdir", XPipeInstallation.getBundledFontsPath().toString()); - System.setProperty("prism.embeddedfonts", "true"); - } - public static void logArguments(String[] args) { TrackEvent.withInfo("Detected arguments") .tag("list", Arrays.asList(args)) diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index 6995ee9f6..a0cf06d02 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -104,7 +104,6 @@ public abstract class OperationMode { AppProperties.logArguments(args); AppProperties.logSystemProperties(); AppProperties.logPassedProperties(); - AppProperties.setDynamicProperties(); XPipeSystemId.init(); AppFontCheck.check(); TrackEvent.info("mode", "Finished initial setup"); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/SecretFieldComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/SecretFieldComp.java index 29e57e5b4..a5f6d4a58 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/SecretFieldComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/SecretFieldComp.java @@ -1,5 +1,6 @@ package io.xpipe.app.fxcomps.impl; +import atlantafx.base.controls.PasswordTextField; import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.CompStructure; import io.xpipe.app.fxcomps.SimpleCompStructure; @@ -7,7 +8,6 @@ import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.util.SecretHelper; import io.xpipe.core.util.SecretValue; import javafx.beans.property.Property; -import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; import java.util.Objects; @@ -26,7 +26,7 @@ public class SecretFieldComp extends Comp> { @Override public CompStructure createBase() { - var text = new PasswordField(); + var text = new PasswordTextField(); text.getStyleClass().add("secret-field-comp"); text.setText(value.getValue() != null ? value.getValue().getSecretValue() : null); text.textProperty().addListener((c, o, n) -> { diff --git a/app/src/main/java/io/xpipe/app/prefs/SecretField.java b/app/src/main/java/io/xpipe/app/prefs/SecretField.java deleted file mode 100644 index 860ea5d00..000000000 --- a/app/src/main/java/io/xpipe/app/prefs/SecretField.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.xpipe.app.prefs; - -import com.dlsc.formsfx.model.structure.DataField; -import com.dlsc.formsfx.view.controls.SimplePasswordControl; -import io.xpipe.app.util.SecretHelper; -import io.xpipe.core.util.SecretValue; -import javafx.beans.property.Property; - -public class SecretField - extends DataField, SecretValue, com.dlsc.formsfx.model.structure.PasswordField> { - - protected SecretField(Property valueProperty, Property persistentValueProperty) { - super(valueProperty, persistentValueProperty); - - stringConverter = new AbstractStringConverter<>() { - @Override - public SecretValue fromString(String string) { - return SecretHelper.encrypt(string); - } - }; - rendererSupplier = () -> new SimplePasswordControl(); - - userInput.set(stringConverter.toString(value.getValue())); - } -} \ No newline at end of file diff --git a/app/src/main/java/io/xpipe/app/util/PlatformState.java b/app/src/main/java/io/xpipe/app/util/PlatformState.java index 4acd3292e..eac0951e5 100644 --- a/app/src/main/java/io/xpipe/app/util/PlatformState.java +++ b/app/src/main/java/io/xpipe/app/util/PlatformState.java @@ -1,5 +1,6 @@ package io.xpipe.app.util; +import io.xpipe.app.core.AppBundledFonts; import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.issue.TrackEvent; import javafx.application.Platform; @@ -75,6 +76,9 @@ public enum PlatformState { return Optional.of(e); } + // Check if we have no fonts and set properties to load bundled ones + AppBundledFonts.init(); + try { CountDownLatch latch = new CountDownLatch(1); Platform.setImplicitExit(false);