Using Fonts with OpenJDK, Azul Platform Core and Azul Platform Prime

Azul Zulu Builds of OpenJDK, Azul Zulu Prime Builds of OpenJDK and other OpenJDK installation packages do not include any font files by default. But all automatically use available fonts provided by the Operating System as high quality TTF files.

Operating System Fonts

On headless servers or small Linux installations like containers or embedded systems those operating system font packages are usually not installed by default. Here the commands to install a standard set of them:

RHEL / Centos:

sudo yum install fontconfig dejavu-sans-fonts dejavu-serif-fonts

Ubuntu / Debian:

sudo apt install fonts-dejavu fontconfig 

SLES:

sudo zypper install dejavu-fonts fontconfig

Desktop Operating Systems like Windows and macOS usually already have many fonts in TTF format already installed by default and don't require additional installations.

After installation of those font packages, Azul Zulu Builds of OpenJDK and Azul Zulu Prime Builds of OpenJDK will automatically use the TTF files provided by the packages. If an application asks for specific font names, like for example Lucida, the fontconfig package installed with the commands above provides a similar replacement font without the need for a change in the application code.

Some applications require certain language-specific fonts. Those are usually also available by most operating systems, either by other font package names or language packs. Here a few starting points, for further details please refer to your Operating System documentation:

  • Language Packs for Windows
    Make sure not to enable "Set as my display language" as that would change your desktop language and could lock you out with unreadable text.
  • Ubuntu Linux, command to search for other font packages:
    apt search ^fonts-
  • RHEL/CentOS 7, command to install a larger group of international fonts:
    sudo yum groupinstall Fonts

Below you see an example error message shown by Java applications when fonts are missing in your operating system. Another indicator that fonts are missing are rectangle symbols shown instead of normal text. Both problems can usually be solved by installing the font packages as described above. 

Exception in thread "main" java.lang.Error: Probable fatal error:No fonts found.
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1236)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)

If you don't see such an error message but the font rendering appears to be low quality, please also follow the instructions listed above as some TTF files might be missing on the system. If after the installation the font rendering appears to be still unexpected, take a look at Font rendering changes after upgrading Azul Zulu Builds of OpenJDK.

JVM Custom Font Directory

If accessing fonts provided by the Operating System is not an option for your use case, you can point the JVM to any directory containing TTF font files to use those. Add the following java command line option:

-Dsun.java2d.fontpath=MYFONTDIR

Alternatively, without adding the command line option above, creating the following directory and placing TTF font files there is also possible:

  • JDK 8: $JAVA_HOME/jre/lib/fonts
  • JRE 8: $JAVA_HOME/lib/fonts
  • JDK 11 and newer: $JAVA_HOME/lib/fonts

Azul Commercial Compatibility Kit

An alternative or addition to using the Operating System Fonts is the separate Azul Commercial Compatibility Kit which contains Lucida font files. It is available for for Azul Zulu Builds of OpenJDK versions 6, 7 and 8. Please refer for download and its terms of use on the following page: https://www.azul.com/products/components/commercial-compatibility-kit/

 

Add Comment

Comments

0 comments

Please sign in to leave a comment.

Was this article helpful?
0 out of 0 found this helpful