0

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 the font family and add the ttf files to the project and specify the font family via the .properties file of FlatLaf.

Can someone please tell me how to add fonts that need to be added to the project first like Rubik from Google?

Liso
  • 195
  • 5
  • 15
  • What do you mean by "need to be added to the project first"? Do you want to have the font files themselves coming with your app? So that the users don't have to download them? – GhostCat Apr 26 '22 at 07:38
  • @GhostCat yes, I want to download the font family and add the ttf files to the project and specify the font family via the .properties file of FlatLaf. – Liso Apr 26 '22 at 07:43
  • Please dont add more information in comments, always edit your question instead. Dont expect your readers to dig through comments to get a clear understanding of your request. – GhostCat Apr 26 '22 at 07:47
  • You can use [`GraphicsEnvironment.registerFont`](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/GraphicsEnvironment.html#registerFont(java.awt.Font)) to make any font loaded via `Font.createFont` available to your UI. So as long as you load it (however you want) before the PlaF tries to use it, that should be sufficient. – Joachim Sauer Apr 26 '22 at 08:14

0 Answers0