5 Supported Fonts

Different OS platforms may provide fonts that are implemented using different font technologies. To support cross-platform use, the Java SE API defines five families of "logical" fonts that can safely be used by an application using any Java SE implementation. The names of these families are defined in the Font class description.

Additionally a Java SE implementation may expose the platform fonts to be used directly by name. These fonts are called "physical" fonts.

For more information on the terminology used here, see the Font class description.

Support for Physical Fonts

The JDK supports TrueType, OpenType, and PostScript Type 1 fonts.

Physical fonts need to be installed in locations known to the Java runtime environment. The JDK locates fonts in the standard font locations defined by the host operating system.

You can add physical fonts that use a supported font technology by installing them in a way supported by the host operating system. The recommended location to add per-user fonts on Linux is the $HOME/.fonts directory which is searched by the platform's libfontconfig, and which is in turn used by the JDK.

Support for Logical Fonts

Typically one logical font maps to several physical fonts in order to cover a larger range of code points than is possible with a single font. Logical fonts are mapped to physical fonts in implementation-dependent ways, and can vary from platform to platform and from release to release.

Font configuration files are used by some implementations to handle the mapping, see Font Configuration Files:

  • Current releases for Windows always use font configuration files.
  • The macOS implementation always ignores font configuration files.
  • Releases for Linux use font configuration files only if there is an exact match for the OS version, otherwise font configuration files are ignored and platform APIs are used to populate the logical fonts.