How to set custom fonts in JavaFX Scene Builder using CSS -
i'm making gui in javafx scene builder , text (labels, text fields, comboboxes) use same font. problem it's custom font won't on every client's computer.
i've tried css:
@font-face { font-family: din; src: url(din.tff); } .text { -fx-font-family: din; -fx-font-style: bold; }
saved above code file font.css , tried applying each gui element through scene builder's javafx css fields, it's not working.
have made mistake in css? or there better way go this? i'd prefer not have load font , set every element in java code if don't have to.
make sure use font.loadfont
load font on application startup. should able use font css. careful use font's name, not font file's name. that's common mistake.
i have used following before load , use custom font:
font.loadfont(getclass().getresourceasstream("/resources/fonts/marck.ttf"), 14);
and:
-fx-font-family: "marck script";
fyi: quotes needed if name contains space.
Comments
Post a Comment