Advanced Font System

The Problems

X Windows' lack of TrueType Font Engine
X Windows originally supported only bitmap fonts, i.e. fonts for which a physical representation for how a font should appear at a particular point size is pre-computed and stored. The problem with this model is when the X server requests a font size which is not precalculated, the font system shrinks or reduces one of the existing bitmaps until it achieves the proper point size. The result is blocky when enlarged, and often illegible when reduced.

Various proprietary scalable font engines were added by proprietary Unix vendors in an effort to combat the bitmap font problem. Scalable fonts contain only an outline, or description, of how the font should be drawn, as well as some hints on how to handle very small point sizes. Theoretically, scalable fonts can be displayed at any size without any of the "blockiness" inherent to their bitmapped siblings. Several of these engines were even donated back to the X Consortium, who maintained the core X Window System, as Free Software. IBM donated a PostScript Type1 font renderer, and BitStream a renderer for their proprietary Speedo type format. Unfortunately, the Type1 engine does a rather poor job with small font sizes, and the Speedo font format has largely been supplanted by other formats. As Apple and Microsoft made TrueType font technology the de-facto standard in the 1990's, Linux users were largely left out in the cold.

X Windows' Cryptic Font Configuration Model
In addition to lack of support for modern fonts, X makes adding and removing fonts difficult. In addition to modifying the system's /etc/X11/XF86Config to add or remove a directory containing to new fonts, if X is currently running, the user must also use the cryptic xset command to modify their runtime font path. When fonts are installed into an existing font directory (which is typical), the mkfontdir must be employed, which isn't much better. Even worse, it does not support Type1 fonts, the only reasonable scalable font technology that comes standard with the X Window System.

Printing System Didn't Share Fonts
Most Linux systems use GhostScript as the foundation of the printing sub-system, as it is a very good PostScript interpreter supporting a wide range of printers. Red Hat Linux is no exception. Until recently, GhostScript made use of bitmap fonts which were similar, but incompatible with X Windows. The German font foundry URW++ Design and Development Inc. graciously donated a set of high quality PostScript Type1 fonts to the public domain, which GhostScript quickly adopted, enabling higher quality printed output. While these fonts were compatible with the X Type1 font engine, they were stored in a different location and were not configured to be easily used with X.

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

The Future

While font support isn't perfect, it is much better now than it has been. Some of the projects Red Hat will be working on in the future to improve things even further will be a graphical configuration tool for adding and removing fonts and font directories, and further development of the X Font Server. During the course of Red Hat Linux 6.0's development, we became aware of a number of large security holes in xfs's network code, and for this reason we were forced to temporarily disable support for TCP connections. We understand that there are some environments which rely on xfs to act in a more traditional, network font serving fashion, and we will be providing an update to X which provides an unmodified binary for such purposes shortly. As a longer term solution, we hope to remove all such vulnerabilities in the font server and bring the code into the modern era, as it has been neglected for several years while the rest of X has seen more attention.

X still does not support font smoothing, also known as anti-aliasing. Font smoothing makes small curves in a character appear less jagged by filling in gaps with gray colors, instead of simply drawing the character in black and white. This is a physical limitation of the current X font model, but people are actively pursuing solutions to overcome this hurdle.