load bundled font for "Cryptomator" title

This commit is contained in:
Sebastian Stenzel
2019-08-14 17:11:18 +02:00
parent ded43f7e7b
commit 0a132351a8
2 changed files with 18 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import javafx.beans.binding.BooleanBinding;
import javafx.fxml.FXML;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.fxapp.FxApplication;
@@ -13,10 +14,13 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.IOException;
import java.io.InputStream;
@MainWindowScoped
public class MainWindowController implements FxController {
private static final String TITLE_FONT = "/css/dosis-bold.ttf";
private static final Logger LOG = LoggerFactory.getLogger(MainWindowController.class);
private final Stage window;
@@ -41,6 +45,7 @@ public class MainWindowController implements FxController {
@FXML
public void initialize() {
LOG.debug("init MainWindowController");
loadFont(TITLE_FONT);
titleBar.setOnMousePressed(event -> {
xOffset = event.getSceneX();
yOffset = event.getSceneY();
@@ -57,6 +62,19 @@ public class MainWindowController implements FxController {
updateChecker.automaticallyCheckForUpdatesIfEnabled();
}
private void loadFont(String resourcePath) {
try (InputStream in = getClass().getResourceAsStream(resourcePath)) {
Font font = Font.loadFont(in, 12.0);
if (font == null) {
LOG.warn("Error loading font from path: " + resourcePath);
} else {
LOG.debug("Loaded font {}", font.getFamily());
}
} catch (IOException e) {
LOG.warn("Error loading font from path: " + resourcePath, e);
}
}
@FXML
public void close() {
if (minimizeToSysTray) {

Binary file not shown.