I know this is old, but it is just not working with me, already checked :
and
How to embed .ttf fonts is JavaFx 2.2?
digital-clock.css :
@font-face {
font-family: 'DINRegular';
src: url('../fonts/DINRegular.tff'); // also tried url('/fonts/DINRegular.tff'); and url('fonts/DINRegular.tff');
}
.label {
-fx-font-family: 'DINRegular';
-fx-font-size: 30;
}
.button .text {
-fx-font-family: 'DINRegular';
}
loading the css with :
getStylesheets().add(getClass().getResource("/style/digital-clock.css").toExternalForm());
loading font programatically doesnt work either :
example :
public static javafx.scene.text.Font loadFont(String name) {
return javafx.scene.text.Font.loadFont(FXMLConstants.class.getResource("/fonts/"+"digital"+".ttf").toExternalForm(), 12);
}