Specifying external font in JavaFX CSS

后端 未结 5 650
天涯浪人
天涯浪人 2020-12-08 15:52

Is it possible to specify a font using CSS in JavaFX application? I have an FXML scene and the corresponding CSS file. In Java code, it\'s possible to specify a font using t

5条回答
  •  广开言路
    2020-12-08 16:42

    You were close to the solution:

    -fx-font-family: 'Helvetica', Arial, sans-serif;
    

    Try this, it should work fine.


    Maybe this could help? (I'm not an expert in JavaFX)

    https://forums.oracle.com/forums/thread.jspa?messageID=10107625


    EDIT:

    Load your font:

    @font-face {
        font-family: Delicious;
        src: url('Delicious-Roman.otf');
    }
    

    Use your font with -fx-:

    -fx-font-family: 'Delicious';
    

提交回复
热议问题