Elunius
Elunius

Reputation: 3

SceneBuilder (by gluon) doesn't show imported fonts

im programming an app and facing some issues.

After implementing a new external font like this:

Font WoodStamp = null;
    try {
        WoodStamp = Font.loadFont(new FileInputStream(new File(getClass().getResource("/material/WoodStamp.ttf").getFile())), 10);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

i added a CSS which includes the (for example) following:

.label {
-fx-font-size: 11pt;
-fx-font-family: "WoodStamp";
-fx-text-fill: white;
-fx-opacity: 0.6;

All seems like it's working, look at my running app.

As soon as i open my SceneBuilder it first looks like this.
(above screen - sorry same picture because reputation)
but i figured out myself how to fix this "little" problem: I have to change something.
As doing so everything is showing (kinda) correctly in spite of the fonts.
See yourself in below screen of the picture.

Is there any solution to show my imported font in SceneBuilder?
Organizing labels and other things is very difficult when the wrong font is shown... :(

Greetings
Elunius

Upvotes: 0

Views: 1481

Answers (1)

José Pereda
José Pereda

Reputation: 45476

Scene Builder needs to know about the font as well. Notice that as well as you need to install the font on your application to make it work, you'll need to do it as well on Scene Builder.

Since that's not possible unless you use the source code, the solution is plain simple: install the font on your system, and Scene Builder will know about it.

Once it is installed, you can open Scene Builder and look in the list of available fonts:

List of Fonts

If the font is there, you will be able to open your FXML, or you can just create a new one and use the font:

Use custom font

Upvotes: 1

Related Questions