Erel
Erel

Reputation: 1802

JavaFX WebView font issue on Mac

Some sites show gibberish characters instead of the correct text. It only happens on Macs.

For example with GMapsFX: enter image description here

Online site: enter image description here

Might be related to OS X 10.11 or 10.12. I tested it with Java 1.8.0_121.

Is there any fix or workaround for this issue?

Upvotes: 8

Views: 1919

Answers (3)

Ian Hong
Ian Hong

Reputation: 1

There is a specific build of OpenJDK that doesn't seem to have these problems. If you are among the affected Mac users, please switch to that version of OpenJDK by following the instructions below.

Download and install the Azul build of OpenJDK 11 version found here (scroll to the bottom of the page) Remember to choose the JDK FX version (not any other versions).

Recommended: Remove the other versions of OpenJDK so that you do not accidentally launch the JAR using the wrong version (this video shows how)

After installation, the command java --version should give the following output:

openjdk 11.0.12 2021-07-20 LTS
OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)
And `whereis java` should output `/usr/bin/java`

Recommended: Set the JAVA_HOME/JDK_HOME system variables to point to /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home

Upvotes: 0

Tom Marvolo Riddle
Tom Marvolo Riddle

Reputation: 223

please load all font in system when java application launched. but is not best answer...sorry

List<String> fontFamilies = Font.getFamilies();
for (String fontFamily: fontFamilies) {
   Font.font(fontFamily);
}

Upvotes: 1

Dũng Trần Trung
Dũng Trần Trung

Reputation: 6276

The error, in my case, was not related to system font. I solved the problem by setting the user agent for the web engine. Here is the string I used (Firefox on Windows x64):

Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0

Upvotes: 4

Related Questions