White Paper: Advanced Font System


< Prev Contents Next >

The Solutions

Red Hat Linux 6.0 goes a long way towards solving the aforementioned problems in an easy, "hands-off" fashion. Most of the time users will never need to know anything about how to add fonts to their system; they will be able to simply install an RPM which will take care of all the dirty work for them. When they are interested in getting under the hood a bit more, some new tools have been provided to make the job more pleasant. Additionally, support for the industry-standard TrueType font format has been included.

The first problem was addressed by integrating an excellent Open Source TrueType font rendering engine called FreeType. FreeType is a comprehensive library for accessing and manipulating TrueType fonts; it is not particular to X Windows. There are a number of different solutions for integrating FreeType into X, and Red Hat decided to use the xfsft system written by Juliusz Chroboczek. It maintains the most compatibility with the legacy font system, removing none of those features. Xfsft was added directly into our build of the X Window System, making it available both through the X server and xfs, an independent daemon for providing fonts.

To solve the X font performance problems, Red Hat decided to make more extensive use of the X Font Server (xfs) than in the past. While originally designed as a solution for providing fonts to other X servers in a network-transparent fashion, xfs provides a number of benefits when used directly on the local host computer instead of having the X server provide fonts. First of all, when X requests fonts that have not previously been displayed, the font server can render them in parallel to the X server's own tasks, such as painting windows on the screen. Previously, while the X server was computing a font, all window system activity stopped and even the mouse became slow and jerky. The effect was especially noticeable on lower-end equipment. Xfs has solved these problems.

Xfs also solves most of the X font configuration issues as well. Configuration information for the font server is stored in /etc/X11/fs/config. The most important section deals with the set of directories forming the path to search for fonts. While it is good that this buys us a location separate from the X display configuration file for font configuration, it is even better when this is updated. The server can automatically inform a running X server that fonts have been added or subtracted, transparently to the user. There is no need to muck around with xset, and the entire font path in /etc/X11/XF86Config can be a single entry pointing at a local Unix domain socket where the font server will be listening. It will never need updating.

To automatically manipulate the font server's search path, Red Hat developed a utility named chkfontpath. It is very easy to use, and its behaviour is modeled after the chkconfig program, which many people are already familiar with. Chkfontpath enables a user to interactively query what directories are present in the font server's path, as well as add and remove them from the command line. Even better, it makes it easy to add

%pre
and
%postun

sections to RPMs containing fonts which will automate everything for the user, leaving them with nothing that they personally have to take care of.

The URW Type1 fonts originally used only with GhostScript are now installed in /usr/share/fonts/default/Type1, where they are shared between X and the printing system. If you view a web page which uses the standard PostScript Type1 fonts such as Times and Helvetica in Netscape, the printed output should appear very similar to what you see on the screen.

Using Chkfontpath
Chkfontpath is an easy program to use. It can take a number of command line arguments, but the three which are most common are list, --add, and --remove. Let's explore how each of these work.

The results of running chkfontpath --list on a typical Red Hat Linux 6.0 system look something like this:

Current directories in font path:
1: /usr/X11R6/lib/X11/fonts/misc:unscaled
2: /usr/X11R6/lib/X11/fonts/75dpi:unscaled
3: /usr/X11R6/lib/X11/fonts/100dpi:unscaled
4: /usr/share/fonts/default/Type1
5: /usr/X11R6/lib/X11/fonts/misc
6: /usr/X11R6/lib/X11/fonts/75dpi
7: /usr/X11R6/lib/X11/fonts/Type1
8: /usr/X11R6/lib/X11/fonts/Speedo 
    

If for some reason you wanted to remove the URW Type1 fonts from the system, you would execute chkfontpath --remove /usr/share/fonts/default/Type1 The system will inform you of any errors that occur while processing your instructions.

Similarly, if you wished to add a directory containing fonts from FooFont Inc., you might do the following after physically installing the fonts on the system: chkfontpath --add /usr/share/fonts/default/FooFonts

When using chkfontpath inside the %pre and %postun sections of an RPM spec file, packagers are encouraged to use the -q flag, which will instruct the program to suppress all non-fatal information output, such as the case where you attempt to add a directory to the font path which xfs is already managing.

Please note that at this time, xfs still requires the fonts.scale file describing the characteristics of each font to be present in a font directory. The FreeType package has been shipped with a utility called ttmkfdir which generates output suitable for including in fonts.scale for the specified TrueType fonts. Distributors and individuals making font RPMs are encouraged to use this utility or something similar beforehand and include the file in the RPM, so that the end user is not burdened with the chore.


< Prev Contents Next >