java - JavaFX Embed Custom Font Not Working -


i'm using javafx version 8.0.40-b27 , trying embed custom/external font via css. i've tried programmatic approaches, of have failed. system.out.print of "font" returns null, suspect cause.

java:

font font = font.loadfont( main.class.getclassloader().getresourceasstream( "application/stratum.ttf"), 10);  system.out.println(font); // prints "null"  nowplayingtitle.setfont(font);

css:

@font-face {      font-family: stratum;      src: url('stratum.ttf');  }    .text{   	-fx-font-family: "stratum", "segoe ui light";      -fx-font-weight: 100;      -fx-text-fill: white;  }

directory: http://i.stack.imgur.com/c92ii.png

edit: system.out.println(font); prints font[name=stratumno1-thin, family=stratumno1, style=thin, size=10.0], file being accessed correctly. font still not being rendered on screen: http://i.stack.imgur.com/bueuk.png

for url in java code, try either

// relative classpath, leading / font font = font.loadfont( main.class.getclassloader().getresourceasstream( "/application/stratum.ttf"), 10); 

or

// relative class: font font = font.loadfont( main.class.getclassloader().getresourceasstream( "stratum.ttf"), 10); 

the css looks right me... sure ttf file being deployed along compiled code css, etc?


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -