Java Runtime Environment fonts
Some users may find the default Java fonts or the display mode of fonts in Java applications to be unpleasant. Several methods to improve the font display in the Oracle Java Runtime Environment (JRE) are available. These methods may be used separately, but many users will find they achieve better results by combining them.
TrueType fonts appear to be the best supported format for use with Java.
Anti-aliasing of fonts is available with Oracle Java 1.6 and OpenJDK on Linux. To do this system-wide, add the following line to
setting is one of the values:
||Use the font's built-in hinting instructions|
||Anti-aliasing tuned for many popular LCD monitors|
||Alternative LCD monitor setting|
lcd settings work well in many instances.
To optionally to use GTK look and feel, add the following line instead:
Specify the variable on the command line before the executable to try the new configuration:
Re-login for the changes to take effect.
Some java applications are subject to system font hinting changes. Consider choosing one of the following environment variables before launching a java app:
export FT2_SUBPIXEL_HINTING=0 # Classic mode export FT2_SUBPIXEL_HINTING=1 # Infinality mode export FT2_SUBPIXEL_HINTING=2 # Default mode
For example, the value of 0 makes freetype use non-bold fonts (at least for some apps).
Even with anti-aliasing enforced through Java options, the resulting anti-aliasing may be inferior to native applications. This can be remedied with a patch to OpenJDK, available in the AUR:
- Patched OpenJDK7 is available as AUR (--enable-infinality=yes)
- Patched OpenJDK8 is available as AUR
The patched version obtains the per-family FreeType rendering/loading flags from fontconfig instead of using OpenJDK heuristics. Although this is an Infinality package, the patches themselves don't actually depend on AUR since only vanilla APIs are used.
Some Java applications may specify use of a particular TrueType font; these applications must be made aware of the directory path to the desired font. TrueType fonts are installed in the directory
/usr/share/fonts/TTF. Add the following line to
/etc/environment to enable these fonts.
Relogin for the change to take effect.
Fixing Mojibake (For JRE8)
Place font files under the directory below. Create the directory if it does not exist.