Reputation: 89
So I have multiple '.ttf' fonts in a folder buy I'm failing to use them in scene builder using fxml and CSS.
Here's what I've tried with a label called 'serial connection' attached to a CSS file with theses lines:
.serialConn {
-fx-font-family:URL("fonts/capsuula.ttf");
}
That's similar to what I'm using to set backgrounds but obviously doesn't work for fonts.
Upvotes: 0
Views: 1956
Reputation: 47091
This should work for Java versions < 1.8u60 :
@font-face {
font-family: 'Capsuula';
src: url('fonts/capsuula.ttf');
}
.serialConn {
-fx-font-family: 'Capsuula';
}
Note :
Make sure that the value of -fx-font-family
(Capsuula
in my code example) is the actual name of the font as it is found inside capsuula.ttf
.
For more info, you can go to How to integrate custom fonts in your JavaFX application by using CSS
Upvotes: 3