Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Java FX Application not loading Font

I was trying to load a downloaded font in my Java FX application but it wasn't working. So I tried to see if it was being loaded. I did this:

Font font = Font.loadFont(getClass().getResource("/fonts/Montserrat-Regular.ttf").toExternalForm(), 10);
Parent root = FXMLLoader.load(getClass().getResource("/fxml/home.fxml"));
System.out.println(font);

and it printed null.

Im applying the font to everything in my CSS but it doesn't get applied.

* {
    -fx-font-family: 'Montserrat';
    -fx-alignment: center;
    -fx-text-fill: #fff;
}

Am I missing something?

Faced Same Problem, This course was going Flawlessly till now, BraainStormed, then remembered i faced the similar problem while doing some CSS work while back.

SOLUTION: just put Family name in single inverted comma like 'Arial' or 'Papyrus' or 'Comin Sans MS'.

Papyrus may not work in windows as it does not come pre-installed on windows.