Difference between revisions of "Java Runtime Environment fonts"

From ArchWiki
Jump to: navigation, search
m (moved Java Fonts - Sun JRE to Java Runtime Environment Fonts: it isn't Sun anymore, and "Java JRE" is redundant)
m (Bot: Removing from Category:HOWTOs (English))
Line 1: Line 1:
[[Category:Fonts (English)]] [[Category:HOWTOs (English)]]
[[Category:Fonts (English)]]  
{{Article summary start}}
{{Article summary start}}
{{Article summary text|Instructions are given to improve the display of fonts in Java applications when using Sun Microsystem's Java Runtime Environment}}
{{Article summary text|Instructions are given to improve the display of fonts in Java applications when using Sun Microsystem's Java Runtime Environment}}

Revision as of 17:46, 10 June 2011

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki: Information on adding fonts and font recommendations Template:Article summary wiki: Font setup and beautification Template:Article summary wiki: Adding Microsoft fonts and mimicking Windows' font settings Template:Article summary end

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 Sun 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 Sun Java 1.6 on Linux. To do this on a per user basis, add the following line to the user's Template:Filename.

export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=setting'


Replace Template:Codeline with one of the following seven values:

The Template:Codeline and Template:Codeline settings work well in many instances.

Optionally to use GTK look and feel, add the following line to .bashrc instead. Note that the Java options described above and this one 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.

export _JAVA_OPTIONS='-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel' 

For the above change to take effect, Template:Filename must be sourced as the normal user.

$ source ~/.bashrc

Open a new instance of a Java application to test the changes made.

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 Template:Filename. Add the following line to Template:Filename to enable these fonts.

export JAVA_FONTS=/usr/share/fonts/TTF

Source Template:Filename as the normal user for the change to take effect.

$ source ~/.bashrc

Default fonts

The Lucida fonts distributed with the Sun JRE are the default for Java applications that do not specify a different font's use. The Lucida fonts were designed for low resolution displays and printers; many users will wish to use other fonts. The default Java fonts can be changed on a system-wide basis by the creation or editing of a file named Template:Filename.

As root, change directory to Template:Filename. Copy Template:Filename to Template:Filename. Then, as root, open the new Template:Filename in an editor.

# cd /opt/java/jre/lib
# cp fontconfig.properties.src fontconfig.properties
# nano fontconfig.properties
Note: Encodings other than Latin-1, or ISO-8859-1, are shown in other Template:Filename files in Template:Filename. Some users will find these files to be better sources to use for editing. In all cases the edited file should be saved as Template:Filename.

The Java font names in the configuration file are in the form of Template:Codeline, for example, Template:Codeline. These generic fonts are mapped to the installed fonts using X logical font description (XLFD) names. The Template:Codeline, in the example below, is used as a placeholder in the XLFD name for the point size. The Java application replaces Template:Codeline at runtime.

Tip: The utility, xfontsel, may be used to display fonts and to discover their XLFD names. Xfontsel is part of the Template:Package Official package.

Change the Lucida fonts named in the Template:Filename file to your selected fonts using the XLFD names. Below is an excerpt of a Template:Filename file after modifications have been made. The Lucida fonts have been replaced by DejaVu fonts.

# Version -- a version number is required.
# IMPORTANT -- Do not delete the next line. Ever.

# Component Font Mappings
# gen_name.style.subset=
#       -fndry-fmly-wght-slant-sWdth-adstyle-pxlsz-ptSz-resx-resy-spc-avgWdth-rgstry-encdng

serif.plain.latin-1=-misc-dejavu serif-medium-r-normal-*-*-%d-*-*-p-*-iso8859-1
serif.bold.latin-1=-misc-dejavu serif-bold-r-normal-*-*-%d-*-*-p-*-iso8859-1
serif.italic.latin-1=-misc-dejavu serif-medium-o-normal-*-*-%d-*-*-p-*-iso8859-1

After the changes have been saved to Template:Filename, the editor may be closed and the user should drop root privileges. Open a new instance of a Java application to test the changes.