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 trialBenjamin Keller
20,763 Pointsfont is not changing to "Papyrus"
Whether I use a root selector in the stylesheet or as an inline style in the "GridPane" element, my text is not changing to "Papyrus"
Below code has the declaration on a style sheet. The other styles are working.
.root {
-fx-font-family: Papyrus;
-fx-alignment: center;
-fx-hgap: 10;
-fx-vgap: 10;
}
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.text.Text?>
<?import javafx.scene.control.TextField?>
<GridPane fx:controller="sample.Controller"
stylesheets="/css/sample.css"
xmlns:fx="http://javafx.com/fxml">
2 Answers
hchris
Courses Plus Student 11,116 PointsI've found that on Windows you need use the EXACT font name that Windows uses, a lot of the fonts I saw in my word processor had extra letters or notations added to their name, like MS or Std. Also, I had to put quotes around any fonts with multiple words.
For example, on my computer,
-fx-font-family: Comic Sans;
wouldn't work, but
-fx-font-family: "Comic Sans MS";
magically did.
Craig Dennis
Treehouse TeacherHey Benjamin!
Sorry for the delay, I've been out of town at a conference. Are you on Windows by any chance? You might need to choose a different font like "Comic Sans" to see the silly font I was attempting to make happen.
Let me know and I will update the notes.
Thanks!
Benjamin Keller
20,763 PointsHello Craig!
I am running Windows. I tried Comic Sans and a few others, even Helvetica which works on the text field, but the font has not changed from the default. Adjusting the other properties does have an effect on the application.
Thank You for the Help!
Manas Vijaywargiya
12,598 Pointsits still not working working on windows 10 pc
Manish Giri
16,266 PointsNot working on Linux (Ubuntu 16.04) as well.
Craig Dennis
Treehouse TeacherYou probably don't have that font. Try a different one. One that you do have.