Difference between revisions of "Java Runtime Environment fonts"

From ArchWiki
Jump to: navigation, search
m (Basic settings: fix table)
(fix ja link)
 
(20 intermediate revisions by 13 users not shown)
Line 1: Line 1:
 
[[Category:Fonts]]
 
[[Category:Fonts]]
[[ja:Java Runtime Environment Fonts]]
+
[[ja:Java 実行環境のフォント]]
 +
[[ru:Java Runtime Environment fonts]]
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|Fonts}}
 
{{Related|Fonts}}
Line 14: Line 15:
 
=== Basic settings ===
 
=== Basic settings ===
  
[http://en.wikipedia.org/wiki/Antialiased_font 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 {{ic|/etc/environment}}:
+
[[wikipedia:Font rasterization|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 {{ic|/etc/environment}}:
  
 
  _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=''setting'''
 
  _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=''setting'''
Line 53: Line 54:
 
Specify the variable on the command line before the executable to try the new configuration:
 
Specify the variable on the command line before the executable to try the new configuration:
  
  _JAVA_OPTIONS=''options'' ''exectuable''  
+
  _JAVA_OPTIONS=''options'' ''executable''  
  
 
Re-login for the changes to take effect.
 
Re-login for the changes to take effect.
  
===OpenJDK patch===
+
=== OpenJDK patch ===
Even when anti-aliasing is enforced through Java options, the resulting anti-aliasing may look noticably poorer than the ones used in native applications and may result in blurry fonts or in the LCD hinting not being applied, manifesting in jaggy fonts. This may be remedied through a patch to OpenJDK, available in the [[Arch User Repository|AUR]] as {{AUR|jre7-openjdk-headless-infinality}}. The patched version may yield much improved results and plays nice in conjunction with the [[Infinality]] patches to fontconfig and freetype.
+
 
 +
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|jre7-openjdk-infinality}} (<tt>--enable-infinality=yes</tt>)
 +
* Patched '''OpenJDK8''' is available as {{AUR|jre8-openjdk-infinality}}
 +
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|fontconfig-infinality}} since only vanilla {{Pkg|fontconfig}} APIs are used.
  
 
==Font selection==
 
==Font selection==
  
 
===TrueType fonts===
 
===TrueType fonts===
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 {{ic|/usr/share/fonts/TTF}}. Add the following line to {{ic|~/.bashrc}} to enable these fonts.
 
export JAVA_FONTS=/usr/share/fonts/TTF
 
  
''Source'' {{ic|~/.bashrc}} as the normal user for the change to take effect.
+
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 {{ic|/usr/share/fonts/TTF}}. Add the following line to {{ic|/etc/environment}} to enable these fonts.
  $ source ~/.bashrc
+
 
 +
JAVA_FONTS=/usr/share/fonts/TTF
 +
 
 +
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.
 +
 
 +
  /usr/lib/jvm/java-8-openjdk/jre/lib/fonts/fallback/

Latest revision as of 12:38, 8 March 2018

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

Basic settings

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 /etc/environment:

_JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=setting'

Where setting is one of the values:

Setting Description
off, false, default No anti-aliasing
on Full anti-aliasing
gasp Use the font's built-in hinting instructions
lcd, lcd_hrgb Anti-aliasing tuned for many popular LCD monitors
lcd_hbgr, lcd_vrgb, lcd_vbgr Alternative LCD monitor setting

The gasp and lcd settings work well in many instances.

To optionally to use GTK look and feel, add the following line instead:

_JAVA_OPTIONS='-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel' 
Note:
  • The described Java options only work for applications that draw their GUI in Java, like Jdownloader, and not for applications which utilize Java as backend only, like Openoffice.org and Matlab.
  • TrueType fonts contain a grid-fitting and scan-conversion procedure (GASP) table with the designer's recommendations for the font's display at different point sizes. Some sizes are recommended to be fully anti-aliased, others are to be hinted, and some are to be displayed as bitmaps. Combinations are sometimes used for certain point sizes.

Specify the variable on the command line before the executable to try the new configuration:

_JAVA_OPTIONS=options executable 

Re-login for the changes to take effect.

OpenJDK patch

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:

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 fontconfig-infinalityAUR since only vanilla fontconfig APIs are used.

Font selection

TrueType fonts

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.

JAVA_FONTS=/usr/share/fonts/TTF

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.

/usr/lib/jvm/java-8-openjdk/jre/lib/fonts/fallback/