I have an issue with a JavaFX application on a specific Windows 7 machine, were non-English text is incorrectly displayed. The font is set to System everywhere, which as I understand should be Segoe UI on Windows 7 (and this is indeed the default font on this machine). All text in other parts (non-java) of the system is displayed correctly, so the font is there and has the appropriate character sets, which leads me to believe for some reason JavaFX silently fails to load it, and instead uses a different font.
My question is - how can I find out what font JavaFX is actually using on the specific system? I tried Font.getDefault().getName()
but it simply returns "System", which tells me nothing.
Using -Djavafx.verbose=true
and so on also didn't yield anything of value.
Before you ask - Yes, the application is Unicode, and it works on other machines, both windows and linux, without a problem. I would like to try and diagnose the problem so I don't have to resort to reinstalling the machine (which currently is not an option), or something as dramatic.
Edit: It seems that Segoe UI does not in fact contain that specific charset. Nevertheless, the rest of the system is fine with it. So a more accurate question is - why is JavaFX failing to realize this and use a fallback? And how do I debug/diagnose what is going wrong?
There is a Segoe UI as default Font on your Windows 7 system, but the version is 5.01 per default. So you are not able to display Hebrew characters with this font. Windows will substitute the missing Hebrew font characters at runtime by another font which is able to display them.
So if you haven't updated the Font Segoe UI to minimum version 5.13, then it will always be substituted. But JavaFX won't be able to do it, because it gets the system default font (which is in Font Family System). After it got the font, it will not substitute characters on it.
If you go to system preferences and then to fonts you should see with the details view, that Segoe UI isn't supporting Hebrew characters.
If you go to system preferences and then to fonts you should see with the details view, that Segoe UI is supporting Hebrew characters.
Even have a look at the category, if it is not set to Text then it probably won't be the default font.
Set another font that is able to display Hebrew for the whole application. This is described here: https://stackoverflow.com/a/18409438/4170073
I've shown some other one, that you will be able to place the needed font in your project and call it from there: https://stackoverflow.com/a/31291372/4170073
To be sure your language gets displayed correctly, you have to bundle and use your own font. Otherwise you will never be sure that on another system your Text will be shown correctly. This is not a workaround, this is the way (JavaFX, Swing) applications will do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With