javafx 8 - External font not applied by CSS -


i'm trying create icon buttons. i've downloaded them flaticon.com , had them exported icon font files, includes ttf file.

in css file specify external font as:

@font-face {   font-family: flaticon;   src: url('/flaticon/flaticon.ttf'); } 

i've defined button class should use font follows:

.flaticon-button {    -fx-font-size: 90px;    -fx-font-family: flaticon;    -fx-padding: 10px; } 

my code applies styleclass follows:

button button = new button("\ue000"); button.getstyleclass().add("flaticon-button"); 

but unfortunately doesn't show expected icon. when load font in code , set explicitly correct icon shown:

font font = font.loadfont(this.getclass().getresource("/flaticon/flaticon.ttf").toexternalform() , 90d); button button = new button("\ue000"); button.setfont(font); 

i'm overlooking small, despite how many examples browse on internet, or how long stare @ oracle's css documentation can't see what.

so, wrong css declaration , usage?

thanks comment of rossum, realized it might have url not resolving class, class.getresource() does.

by loading font in main, before references code, seems resolved. guess there no other way, seems bit of hack me.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -