2

JavaFX's SceneBuilder is very useful, but I want to add a custom font to it. In the past, this has worked, though I have no idea how. Screenshot:

enter image description here

Minecraftia is not in SceneBuilder as a default font, but it worked when I defined the Minecraftia font in CSS. I tried doing the same with the new font i want (Roboto), but it doesn't show up in SceneBuilder. I know that i could style the labels in CSS, but I liked it better when the font popped up in SceneBuilder. Does anyone know why/how custom fonts show up in SceneBuilder?

Community
  • 1
  • 1
tarunbod
  • 67
  • 1
  • 2
  • 9

2 Answers2

1

updated

Since Java 8 JavaFX supports the @font-face rule that can be used to add fonts. As a first step the font file must be added to the application.

Once this is done the font can be defined in CSS by using the @font-face rule: in your case

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

.text {
    -fx-font-family: "Roboto";
}

check this blog and a answer for more information.

Community
  • 1
  • 1
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
  • This answer has nothing to do with the question. – Nitram Jun 23 '15 at 12:43
  • If this is not useful than i have mentioned one link down. @Nitram rather doing this you can answer question , if you know. Otherwise let others to try atleast. – Amit Vaghela Jun 23 '15 at 12:48
  • 2
    I don't know the answer to the question. But the question is to get the SceneBuilder to show a specific font in the selection. This answer provides a way to set a font in the code. That is something entirely different compared to the question. In addition the one asking the question also said that he is a aware that it is possible to set a custom font in the css. Making this answer even less useful. – Nitram Jun 23 '15 at 12:51
  • This above code is similar is to show how to set font and all , if we want to use it in schenebuilder. you can set fonts and its properties in schenebuilder as shown in screenshot of question. – Amit Vaghela Jun 23 '15 at 13:04
-1

Install the font to your system

In windows 7 you can just double click the true type font file and it will ask if you want to install it...

jdub1581
  • 659
  • 5
  • 10