I'm trying to load a .ttf font in my JavaFx application. This is my project structure:
main
- java
- - Application.java
- resources
- - fonts
- - - static
- - - - Raleway-Thin.ttf
- - - - Ralewy-Regular.ttf
- - - - ...
- - - Raleway-VairableFont_wght.ttf
- - main.css
On linux, everything worked fine when loading the static fonts in start(Stage stage) like this:
Font.loadFont(getClass.getResourceAsStream("fonts/static/Raleway-Thin.ttf"), 12);
... //Here I load all types I need
and referencing them in main.css just like this:
.button {
-fx-font-family: 'Raleway Thin', sans-serif;
}
On windows, the font looks bad:
It does load the font, it is indeed Raleway Bold, but it looks very ugly.
I have tried the following and will gladly elaborate on everything in more detail if necessary:
Load VariableFont_wgth with
Font.loadFonts(...). This would be the best way, but it only loadsRaleway Thinwhen doing this. I guess I would need a.ttcfile for doing this. Furthermore, it is still pixelated.I tried using the css tag
@font-face. This didn't solve the pixelated text.I tried to change the second argument
sizeofFont.loadFont(), I don't really understand the purpose of it, even after reading the documentations.
What might cause this and how can I solve it? I can't rely on the user having the font installed on the system.
