I'm trying to change the Font Family with FlatLaf for a Java Swing application.
It would be cool to find a way to change it in the customized theme files (mytheme.properties) for FlatLaf. I saw on the FlatLaf docs that its possible to specify font families.
From FlatLaf doc:
family[, family ...] specify one or more font families. If a family is not available, then the next family is used. If none of the families are available, the family of the default/base font is used. If a family name contains spaces, enclose it in " or '.
Example:
defaultFont = 13 "Open Sans", "Noto Sans", Roboto, Arial
I want to download a font family, add the .ttf file to my project, and specify the font family via the .properties file of FlatLaf.
Here's how I set the default font of my Maven project to Poppins Black, based on the comment by Joachim.
I placed my downloaded font file
Poppins-Black.ttfinsideresources/fontfolder. Maven will look for my font inside theresourcesfolder.Then, I loaded my
Poppins-Black.ttffile and then I registered it as a font:Important note:
In my
.propertiesfile, I can now use"Poppins Black"to refer to the new font:Now the default font of my application will be set to Poppins Black.
References