The Problem
I'm creating a Super Mario themed css style sheet for my application, and I want to change the font of my buttons to a custom font called Press Start 2P, which is the pixelated font used in the NES Mario games. However, my application's not loading the font for some odd reason.
CSS code:
.text
{
-fx-font-family: "Press-Start-2P";
}
.button
{
-fx-background-color: transparent;
//-fx-text-fill: rgb(255, 255, 255);
}
@font-face
{
font-family: Press-Start-2P;
src: url("PressStart2P.ttf");
}
When I run the application, it gives me this message:
Apr 25, 2015 8:22:32 AM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged INFO: Could not load @font-face font [file:/C:/Users/Ahmad%20El-Baher/Documents/Programming/Java/Integrative%20Project%20Semester%204/trunk/build/classes/res/styles/PressStart2P.ttf]
How do I make my application load my font properly?
I was having the same issues. The way to load
CSS
inJavaFX
8 is by setting the font face file and then using the Font Name as reference which can be found by previewing the font.The font file is relative to the
CSS
. I have the root set with the font, but you can remove that and leave it per node based.See if your CSS file and the TTF file are in same directory. According to your code,
src: url("PressStart2P.ttf");
they should be in same directory.Also, try replacing
with
I know it's kinda late . But for those people who still in need, I think the problem here is that you have spaces in your project name. Try to rename your project with IntegrativeProjectSemester4