简体   繁体   中英

Automatically install a custom font in javafx

I have developed a javafx application, in which I want to make use of a custom font. I will use the font just once in the following button:

gui.SanswerButton1.setStyle("-fx-font: 80 Symbola;-fx-base: #17499F;");

What I want is to add this custom font automatically in every machine that runs my javafx application. How is this possible to happen?

You better ship the font with your application jar and then you have 2 options:

  • if you use CSS use @font-face { font-family: Symbola; src: url('Symbola.ttf'); } @font-face { font-family: Symbola; src: url('Symbola.ttf'); }
  • if you don't use CSS load the font at application startup with Font.loadFont

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM