Default Font Size of Javafx Under Linux Is Larger as on Windows

Set Font globally in JavaFX

You can skin your application with CSS as described on the Oracle Website.
Using following syntax you may set the general theme for your application:

.root{
-fx-font-size: 16pt;
-fx-font-family: "Courier New";
-fx-base: rgb(132, 145, 47);
-fx-background: rgb(225, 228, 203);
}

You include the css as followed:

scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());

Get system default font

JavaFX makes this a lot easier:

import javafx.scene.text.Font;

then use:

Font defaultFont = Font.getDefault();

or

// Where 14 is the font size
Font defaultFont = new Font(14);

Is the JavaFX default font platform independent?

No, it's not. I toyed around with JavaFX to Android conversion. It turned out that the symbols were missing in the cards.



Related Topics



Leave a reply



Submit