JavaFX: Custom font displays commas and periods as question marks

37 Views Asked by At

I am trying to use custom fonts in my application. However, when I run the application, it displays commas and periods as this question mark icon. In LibreOffice, the font has no trouble properly displaying them. They are mapped to ascii values, so I don't think it's a utf-8 problem.

My code:

Text headerText = new Text(this.player.getName() + ", will you...");
headerText.setFont(Font.loadFont("file:fonts/pokerinoctober.otf", 37));

Application screenshot

1

LibreOffice example

2

1

There are 1 best solutions below

0
ajkelsey On

It appears I have fallen victim to Font Fallback.

https://learn.microsoft.com/en-us/globalization/input/font-technology#font-fallback

Windows has a fallback font for glyphs that are not present in the font. I even found the period and comma in character map and when I opened the font file in Windows. It seems some applications will use this fallback font and others won't.