30.4. Fonts

30.4. Fonts

Red Hat Enterprise Linux uses two subsystems to manage and display fonts under X: Fontconfig and xfs.

The newer Fontconfig font subsystem simplifies font management and provides advanced display features, such as anti-aliasing. This system is used automatically for applications programmed using the Qt 3 or GTK+ 2 graphical toolkit.

For compatibility, Red Hat Enterprise Linux includes the original font subsystem, called the core X font subsystem. This system, which is over 15 years old, is based around the X Font Server (xfs).

This section discusses how to configure fonts for X using both systems.

30.4.1. Fontconfig

The Fontconfig font subsystem allows applications to directly access fonts on the system and use Xft or other rendering mechanisms to render Fontconfig fonts with advanced anti-aliasing. Graphical applications can use the Xft library with Fontconfig to draw text to the screen.

Over time, the Fontconfig/Xft font subsystem replaces the core X font subsystem.

Important

The Fontconfig font subsystem does not yet work for OpenOffice.org, which uses its own font rendering technology.

It is important to note that Fontconfig uses the /etc/fonts/fonts.conf configuration file, which should not be edited by hand.

Tip

Due to the transition to the new font system, GTK+ 1.2 applications are not affected by any changes made via the Font Preferences dialog (accessed by selecting System (on the panel) => Preferences => Fonts). For these applications, a font can be configured by adding the following lines to the file ~/.gtkrc.mine:

style "user-font" {  fontset = "<font-specification>"  }  widget_class "*" style "user-font"

Replace <font-specification> with a font specification in the style used by traditional X applications, such as -adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*. A full list of core fonts can be obtained by running xlsfonts or created interactively using the xfontsel command.

30.4.1.1. Adding Fonts to Fontconfig

Adding new fonts to the Fontconfig subsystem is a straightforward process.

  1. To add fonts system-wide, copy the new fonts into the /usr/share/fonts/ directory. It is a good idea to create a new subdirectory, such as local/ or similar, to help distinguish between user-installed and default fonts.

    To add fonts for an individual user, copy the new fonts into the .fonts/ directory in the user's home directory.

  2. Use the fc-cache command to update the font information cache, as in the following example:

    fc-cache <path-to-font-directory>
    

    In this command, replace <path-to-font-directory> with the directory containing the new fonts (either /usr/share/fonts/local/ or /home/<user>/.fonts/).

Tip

Individual users may also install fonts graphically, by typing fonts:/// into the Nautilus address bar, and dragging the new font files there.

Important

If the font file name ends with a .gz extension, it is compressed and cannot be used until uncompressed. To do this, use the gunzip command or double-click the file and drag the font to a directory in Nautilus.

30.4.2. Core X Font System

For compatibility, Red Hat Enterprise Linux provides the core X font subsystem, which uses the X Font Server (xfs) to provide fonts to X client applications.

The X server looks for a font server specified in the FontPath directive within the Files section of the /etc/X11/xorg.conf configuration file. Refer to Section 30.3.1.4, “Files” for more information about the FontPath entry.

The X server connects to the xfs server on a specified port to acquire font information. For this reason, the xfs service must be running for X to start. For more about configuring services for a particular runlevel, refer to Chapter 15, Controlling Access to Services.

30.4.2.1. xfs Configuration

The /etc/rc.d/init.d/xfs script starts the xfs server. Several options can be configured within its configuration file, /etc/X11/fs/config.

The following lists common options:

  • alternate-servers — Specifies a list of alternate font servers to be used if this font server is not available. A comma must separate each font server in a list.

  • catalogue — Specifies an ordered list of font paths to use. A comma must separate each font path in a list.

    Use the string :unscaled immediately after the font path to make the unscaled fonts in that path load first. Then specify the entire path again, so that other scaled fonts are also loaded.

  • client-limit — Specifies the maximum number of clients the font server services. The default is 10.

  • clone-self — Allows the font server to clone a new version of itself when the client-limit is hit. By default, this option is on.

  • default-point-size — Specifies the default point size for any font that does not specify this value. The value for this option is set in decipoints. The default of 120 corresponds to a 12 point font.

  • default-resolutions — Specifies a list of resolutions supported by the X server. Each resolution in the list must be separated by a comma.

  • deferglyphs — Specifies whether to defer loading glyphs (the graphic used to visually represent a font). To disable this feature use none, to enable this feature for all fonts use all, or to turn this feature on only for 16-bit fonts use 16.

  • error-file — Specifies the path and file name of a location where xfs errors are logged.

  • no-listen — Prevents xfs from listening to particular protocols. By default, this option is set to tcp to prevent xfs from listening on TCP ports for security reasons.

    Tip

    If xfs is used to serve fonts over the network, remove this line.

  • port — Specifies the TCP port that xfs listens on if no-listen does not exist or is commented out.

  • use-syslog — Specifies whether to use the system error log.

30.4.2.2. Adding Fonts to xfs

To add fonts to the core X font subsystem (xfs), follow these steps:

  1. If it does not already exist, create a directory called /usr/share/fonts/local/ using the following command as root:

    mkdir /usr/share/fonts/local/
    

    If creating the /usr/share/fonts/local/ directory is necessary, it must be added to the xfs path using the following command as root:

    chkfontpath --add /usr/share/fonts/local/ 
    
  2. Copy the new font file into the /usr/share/fonts/local/ directory

  3. Update the font information by issuing the following command as root:

    ttmkfdir -d /usr/share/fonts/local/ -o /usr/share/fonts/local/fonts.scale
    
  4. Reload the xfs font server configuration file by issuing the following command as root:

    service xfs reload
    

Note: This documentation is provided {and copyrighted} by Red Hat®, Inc. and is released via the Open Publication License. The copyright holder has added the further requirement that Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. The CentOS project redistributes these original works (in their unmodified form) as a reference for CentOS-5 because CentOS-5 is built from publicly available, open source SRPMS. The documentation is unmodified to be compliant with upstream distribution policy. Neither CentOS-5 nor the CentOS Project are in any way affiliated with or sponsored by Red Hat®, Inc.