Loading custom font using JavaFX 8 and css -


the problem

i'm creating super mario themed css style sheet application, , want change font of buttons custom font called press start 2p, pixelated font used in nes mario games. however, application's not loading font odd reason.

css code:

.text {     -fx-font-family: "press-start-2p"; }  .button {     -fx-background-color: transparent;     //-fx-text-fill: rgb(255, 255, 255); }  @font-face {     font-family: press-start-2p;     src: url("pressstart2p.ttf"); } 

when run application, gives me message:

apr 25, 2015 8:22:32 com.sun.javafx.css.stylemanager loadstylesheetunprivileged info: not load @font-face font [file:/c:/users/ahmad%20el-baher/documents/programming/java/integrative%20project%20semester%204/trunk/build/classes/res/styles/pressstart2p.ttf]

how make application load font properly?

note below work java versions >= 1.8u60

i having same issues. way load css in javafx 8 setting font face file , using font name reference can found previewing font.

the font file relative css. have root set font, can remove , leave per node based.

css code

@font-face {     src: url("freeuniverse2.ttf"), }  .root {     -fx-background-color: gray;     -fx-font-family: "free universe 2"; }  #window {     -fx-border-image-source: url("images/windowfill.png");     -fx-border-image-slice: 17 6 13 6 fill;     -fx-border-image-width: 17 6 13 6 ;     -fx-background-color: gray; }  .text {     -fx-text-fill: white;     -fx-font-size: 16px;     -fx-font-family: "free universe 2";     -fx-background-color: transparent; }  .pane {     -fx-border-image-source: url("images/windowfill.png");     -fx-border-image-slice: 17 6 13 6 fill;     -fx-border-image-width: 17 6 13 6 ;     -fx-background-color: gray; }  .vbox {         -fx-border-image-source: url("images/windowfill.png");     -fx-border-image-slice: 17 6 13 6 fill;     -fx-border-image-width: 17 6 13 6 ;     -fx-background-color: gray; }  #title-text {     -fx-text-fill: white;     -fx-font-size: 36px;     -fx-font-family: "free universe 2"; }  .label {     -fx-text-fill: white;     -fx-font-size: 16px;     -fx-font-family: "free universe 2";     -fx-background-color: transparent; } 

font file preview(below can see real font name)

font file preview


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -