samedi 2 juillet 2016

JavaFX loading fonts using CSS

I know this is old, but it is just not working with me, already checked :

JavaFX custom Fonts

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());

resources

Aucun commentaire:

Enregistrer un commentaire