Fighting Font Frustration
X Compatibility Fonts

By Steve Coile

As a heavy user of Netscape Navigator under Red Hat Linux, I find myself frequently frustrated with the problems experienced visiting overly-fancy Web page designs and Web pages designed only for Microsoft Windows users related, often because of problems rendering fonts. Unfortunately, these problems occur frequently. On the up-side, I've managed to find ways to alleviate them to an acceptable level. This article discusses several steps that can be taken to improve the Web browsing experience using Netscape Navaigator and Communicator under Red Hat Linux. Much of this material may also be applied to other variants of Linux and UNIX.

In part one of this article, I discussed the basic steps that users of Netscape Navigator and Communicator for Red Hat Linux and other UNIX and Linux variants can take to improve the browsing experience. In part two, I discussed steps for more advanced Red Hat Linux users and systems administrators to alleviate remaining font sizing issues. Here, I discuss how to create compatability fonts for Red Hat Linux systems to handle Web pages that reference fonts only available on Microsoft platforms. All of the steps discussed in part three require root access.

Identity Problems

As the Web has evolved, Web page developers have been given greater and greater control over the formatting of the rendered Web page. Among other things, Web page authors have the ability to select the font appearance, not just its size. Fonts are identified by name. Common font names include Helvetica, Courier, and Times. Unfortunately, not all systems provide every conceivable font. In fact, there are no guarantees that any given computer platform will provide any fonts, let alone common fonts.

The standard fonts provided by Microsoft Windows and UNIX variants (including Linux) are, happily, similar in appearnace. Unfortunately, the do not have the same names. Consequently, Web pages that identify fonts only by their Microsoft Windows names render improperly when viewed from UNIX. For those of us that use Linux on the desktop exclusively, this aggrevates the Web browsing experience.

Historically, there was no way to resolve this issue. UNIX-based Web users simply accepted the poor renderings and made do. Recently, support for TrueType fonts (the font type used by Windows) has been made available to the UNIX world. The downside is that the TrueType fonts included with Windows are licensed property and cannot be distributed with Linux distributions without the payment of a licensing fee. Consequently, the only way to use TrueType fonts without paying the license fee is to copy them from a Windows system, a cumbersome and legally questionable solution at best.

Identity Solutions

The X windowing system has the ability to associate font name aliases with proper font names. By making use of this ability, we can obtain at least a semblance of support for fonts we don't otherwise have access to. And since many of the fonts available under Windows are similar in appearance to those available under UNIX and Linux, we can obtain a very closely approximation of the fonts by simply creating appropriate aliases. The remainder of this document describes the procedure for adding these "compatability" aliases.

Create the Font Directory

Fonts exist within subdirectories of the /usr/X11R6/lib/X11/fonts directory. To help distinguish the compatability fonts from the formal fonts, create a new subdirectory, compat, for them:

Create Alias Font Specifications

Creating alias font specifications by hand is extremely tedious, time consuming, and error-prone. Trust me, I've tried it. Far easier is to use a simple command that uses existing font specifications. A script to create the alias font specifications is available at http://patriot.net/~scoile/fonts/mkaliasfont. The steps it takes are described below.

A listing of all existing font specifications is obtained using the xlsfonts command. From the listing, only those specifications for the target of our alias font are culled. For instance, a font commonly referenced by Web pages is the Arial font, found on Microsoft Windows but not in Linux. Arial is very similar to Helvetica, which is available under Linux. The command below culls the specifications for the Helvetica font:

The format for font aliases is:

For our purposes, alias and target will be nearly identical, replacing only the first two components of target (the font foundry and family) with a suitable alias. To distinguish our compatability aliases, we will use the pseudo-foundry, "compat". The family name of the alias will be the name of the font we're attempting to mimic (e.g. "arial"). This transformation can be performed by sending the output from the xlsfonts command given above to the following:

The resulting output should be directed into the file, fonts.alias, in the compatability font directory, /usr/X11R6/lib/X11/fonts/compat. If you're using the mkaliasfont script, this can be done using the following command:

These steps may be repeated as desired to add any number of alias fonts.

Serve the Font

With the font specifications in place, the font server must be made aware of the new fonts in order to make them available to applications. To do so, issue the following commands:

The chkfontpath command adds the new font directory to the font server's "catalogue" listing in /etc/X11/fs/config and restarts the font server.

Applications running when these commands are issued will not have access to the new fonts until the applications themselves are also restarted. The difference in font appearance in Netscape is dramatic:

Font appearance and alias fonts
Before aliased fontsBefore aliased fonts
BeforeAfter


Copyright 2000 by Red Hat, Inc. and Steve Coile.