This chapter describes what you need to know in order to select display fonts for the various client applications. After acquainting you with some of the basic characteristics of a font, this chapter describes the rather complex font naming conventions and how to simplify font specification. This chapter also describes how to use the xlsfonts, xfd, and xfontsel clients to list, display, and select available screen fonts.
In This Chapter:
Many clients allow you to specify the font used to display text in the window, in menus and labels, or in any other text fields. For example, you can choose the font used for the text in twm menus or in xterm windows.
Unfortunately, for the most part, there are no simple “font menus” like there are on systems such as the Macintosh.* Instead, X has a fairly complex font naming system (which, like most things about X, is designed for maximum flexibility rather than for simplicity or ease of use). Of course, there will no doubt soon be many applications such as word processors and publishing packages that provide a simple interface for selecting fonts. However, for the clients in the X distribution, you are generally limited to selecting fonts via command line options or resource specifications.
This wouldn’t be so bad if a typical font name wasn’t mind-bending at first glance. Imagine typing this command line to create an xterm window whose text is to be displayed in 14-point Courier bold:
% xterm -fn -adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1
Fortunately, you can use asterisks as wildcards to simplify this name to a somewhat more reasonable one:
% xterm -fn '*courier-bold-r*140*'
and you can define even simpler aliases, so that you could end up typing a command line like this:
% xterm -fn courierB14
In this chapter, we’re going to try to make sense out of the sometimes bewildering jungle of information about fonts under X. First, we’ll explain the font naming convention in detail. Along the way, we’ll acquaint you with the appearance of some of the basic font families (groups of related fonts), and the various permutations (such as weight, slant, and point size) within each family.
Then, we’ll talk about how to use font name wildcards to simplify font specification. We’ll also talk about the font search path (the directories where the font files are stored), and how to define aliases for font names.
Finally, we’ll talk about some of the utilities X provides for dealing with fonts:
• xlsfonts, which lists the names of the fonts available on your server, as well as any aliases.
• xfd (font displayer), which allows you to display the character set for any individual font you specify on the command line.
• xfontsel (font selector), which allows you to preview fonts and select the name of the one you want. (This name can then be pasted onto a command line, into a resource file, etc.)
In Release 2 and earlier, fonts were simply identified by the name of the file in which they were stored, minus the .snf (“server natural format”) extension. For example, the file 8x13.snf contained a font named 8x13.
However, starting with Release 3, a new logical font naming convention was adopted. As we’ll see in a moment, these logical font names allow for complete specification of all of the characteristics of each font. Unfortunately, this completeness makes them somewhat difficult to work with, at least until you learn what all the parts of the names mean, and get a handle on which parts you need to remember, and which you can safely ignore. (By the end of this chapter, you should have that knowledge.)
The xlsfonts client can be used to display the names of all the fonts available on your server. When you run xlsfonts, you’ll get an intimidating list of names similar to the name in Figure 5-1.
Upon close examination, this rather verbose name contains a great deal of useful information: the font’s developer, or foundry (Adobe), the font family (Courier), weight (bold), slant (oblique), set width (normal), size of the font in pixels (10), size of the font in tenths of a point (100 tenths of a point, thus 10 points), horizontal resolution (75-dpi), vertical resolution (75-dpi), spacing (m, for monospace), average width (60—measured in tenths of a pixel, thus 6 pixels), and character set (iso8859-1).
As mentioned earlier, font name wildcarding can eliminate a lot of the unnecessary detail. If you are already familiar with font characteristics, skip ahead to the section “Font Name Wildcarding” later in this Chapter for some tips and tricks. If you need a refresher on fonts, read on, as we illustrate and explain each of the elements that make up the font name.
It has been several years since the advent of desktop publishing, and by now, it is unlikely that anyone in the computer industry is unaware that text can be displayed on the screen and printed on the page using different fonts.
However, the term font is used somewhat ambiguously. Does it refer to a family of typefaces (such as Times® Roman or Helvetica®), which comes in different sizes, weights, and orientations? Or should each distinct set of character glyphs be considered a separate font?
X takes the latter approach. When the documentation says that Release 3 includes 157 fonts, and Release 4 more than 400, this sounds either intimidating or impressive, depending on your mood. But, in fact, the R3 X distribution includes only six font families (Courier, Helvetica, New Century Schoolbook®, Symbol, and Times), plus several miscellaneous fonts that are found only in individual sizes and orientations.* R4 includes two more font families, Lucida® and the Clean family of fixed width fonts, plus many more special purpose fonts.
When you think about it this way, you can quickly reduce the clutter. Figure 5-2 shows the major families of commercial fonts that are available under X. To illustrate the fonts, we’ve used the simple expedient of printing each font name in the font itself. Font names are truncated to fit on the page.† (For those of you who don’t read the Greek alphabet, the fourth line down reads “-adobe-symbol-medium-r-normal--18 …” This font is used for mathematical equations and so forth, rather than for normal display purposes.)
You’ll notice that with the exception of Courier and Lucidatypewriter, all of the fonts in the figure are proportionally-spaced. That is, each character has a separate width. This makes them look good on a printed page, but makes them less appropriate for screen display in terminal windows (especially for program editing), since text will not line up properly unless all characters arc the same width.
You will most likely use these proportional fonts for labels or menu items, rather than for running text. (Word processing or publishing programs will, of course, use them to represent proportional type destined for the printed page.)
Courier and Lucidatyperwriter are monospaced fonts. Every character has the same width. Monospaced fonts can be used effectively for the text font in xterm windows. There are also some special monospaced fonts originally designed for computer displays. You can think of these as character cell fonts. They too are monospaced, but the spacing relates to the size of a cell that contains each character, rather than (necessarily) to the character itself. Some of these fonts were originally available in Release 2, and even in R3 they don’t have the same complex names as the proportional fonts. Instead, they have simple names expressing their size in pixels. For example, in the font named 8×13, each character occupies a box 8 pixels wide by 13 pixels high.
In R4, they were renamed to use the logical font naming conventions, with a foundry name of “misc”, and a font-family of “fixed.” There are also one or two larger fixed fonts donated by Sony for use with their extra-high resolution monitor, with a foundry name of “sony.” Figure 5-3 shows the character cell fonts, using their R3 names, which still exist as aliases in R4. (Not all of these fonts were available in R3.)
Table 5-1 shows the correspondence between these aliases and full font names. Note that the 6×13 font also has an alias called “fixed” defined for it. The “fixed” alias is used as the default font for xterm windows. (Twelve-point Helvetica bold roman has the alias “variable” and is used by default for labels such as those in the titlebar twm puts on windows.)
R4 also includes the Clean family of fixed-width fonts from Schumaker, and DEC’s terminal fonts, both of which are illustrated in Appendix E, Release 3 and 4 Standard Fonts.
There are also many other special purpose fonts, such as the Greek Symbol font that we already saw, the cursor font, the OPEN LOOK™ cursor and glyph fonts, and Kana and Kanji Japanese fonts. (The Kana and Kanji fonts can only be displayed with special hardware.) See Appendix E for comprehensive lists of the these fonts, as well as pictures of the character set in some representative fonts.
The characters in a given font family can be given a radically different appearance by changing the stroke weight or the slant, or both.
The most common weights are medium and bold. The most common slants are roman (upright), italic, or oblique. (Both italic and oblique are slanted; however, italic versions of a font generally have had the character shape changed to make a more pleasing effect when slanted, while oblique fonts are simply a slanted version of the upright font. In general, serif fonts (those with little decorations on the ends and corners of the characters) are slanted via italics, while sans-serif fonts are made oblique.)
Figure 5-4 compares the medium and bold weights, and the roman and italic or oblique slants in the Charter® and Helvetica font families.
Release 4 also includes one font that has an in-between weight called demibold. Weight names are somewhat arbitrary, since a demibold weight in one family may be almost as dark as a bold weight in another.
The font naming convention also defines two counter-clockwise slants, called reverse italic (ri) and reverse oblique (ro), as well as a catch-all called other (ot).
Font sizes are often given in a traditional printer’s measure known as a point. A point is approximately one seventy-second of an inch.
Most of the font families are provided in the six point sizes shown in Figure 5-5.
However, the size story doesn’t end there. Note that some servers (such as Sun’s combined X11/NeWS™ server) support scalable outline fonts, which are device-independent, and thus true to size regardless of the output device. But the standard X fonts arc simply bitmaps. Because of the different resolution of computer monitors, a font with a given nominal point size might actually appear larger or smaller on the screen.
Most monitors on the market today have a resolution between 75 dots per inch and 100 dots per inch (dpi). Accordingly, there are both 75-dpi and 100-dpi versions of a few of the fonts in R3, and of most of them in R4. These separate versions of each font are stored in different directories. By setting the font search path so that the appropriate directory comes first, you can arrange to get the correct versions without having to specify them in the font name.* But how do you tell which kind of monitor you have?
If you have the manufacturer’s specs on your monitor, they might give you this figure. But more likely, they’ll give you the overall resolution in rows and columns. After measuring the physical screen, you can do some rough calculations to arrive at the equivalent in dots per inch. For example, the 16-inch monitor on the Sony NEWS workstation has an advertised resolution of 1280 × 1024 pixels. The actual viewing area is approximately 13 inches wide by 10 inches high. Dividing the resolution by the size, you come up with a vertical resolution of 102.4 dpi and a horizontal resolution of 98.5 dpi.
The Sun 19-inch monitor, by contrast, has an advertised resolution of 1152 × 900. The horizontal and vertical dimensions of the viewing area are approximately 13.75 × 10.75 inches. This yields a resolution of about 84 dpi.
What happens if you select the wrong resolution for your monitor? Given the difference in the pixel size, the same size font will appear larger or smaller than the nominal point size.
For example, consider the 75- and 100-dpi versions of the 24-point charter medium italic font:
If you look at the pixel size field, you will notice that the height of the 75-dpi version is 25 pixels, while the height of the 100-dpi version is 33 pixels. If you use the 75-dpi version on the Sun, you actually get something closer to 21.5 points (75/84*24); on a 100-dpi monitor, you will actually get something closer to 18 points (75/100*24). We noticed this right away when we first began using the Sony workstation. Because of its higher resolution, the font size we had been using on the Sun appeared much smaller.
If you are working on a lower-resolution monitor, you can take advantage of this artifact to display type as large as 32 points (the size that a 24-point 100-dpi font will appear on a 75-dpi monitor.) Figure 5-6 shows the 75- and 100-dpi versions of the same 24-point font, as displayed on a Sun workstation with a 19-inch monochrome monitor. As shown, neither is actually 24 points. The 75-dpi version is actually 21.5 points, as discussed above; the 100-dpi version is about 28.5 points.*
Note that the logical font naming convention allows for different horizontal and vertical resolution values. This would allow server manufacturers to support fonts that were “tuned” for their precise screen resolution. However, the fonts that are shipped with the generic X11 distribution all use the same horizontal and vertical resolution.
As suggested above, this resolution may not exactly match the actual resolution of any particular screen, resulting in characters that are not true to their nominal point size. In the case of the Sony monitors, the actual resolution is quite close to the design of the 100-dpi fonts. However, on the Sun monitor, neither the 75- nor 100-dpi fonts will be right. (Of course, if you are using the X11/NeWS server rather than the MIT sample server, you won’t be using bitmapped fonts at all, but scalable outline fonts, so this isn’t a problem.)
What we’ve already shown summarizes the most important information in the font name. The remaining fields are explained below:
Font manufacturers are still referred to as foundries, from the days when type was cast from lead. The X font naming convention specifies that the foundry is the company that digitized or last modified the font, rather than its original creator.
For the fonts contained in the standard X distribution, the foundry is not terribly significant, since there are no cases where the same font family is available from different foundries. However, there are numerous commercial font families available from more than one foundry. In general, the appearance of the fonts should be quite similar, since the font family defines the design of the typeface. However, there may be some small differences in the quality of some of the characters, and there may be more significant differences in the font metrics (the vertical or horizontal measurements of the characters). This might be significant for a publishing application that was using the bitmapped font for a wysiwyg screen display that needed to match the fonts in a particular laser printer or typesetter.
A value describing a font’s proportionate width, according to the foundry. Typical set widths include: normal, condensed, semicondensed, narrow, double width. All of the Release 3 fonts and most of the Release 4 fonts have the set width normal. A few of the Release 4 fonts have the set width semi condensed.
All standard Release 3 fonts are either m (monospace, i.e., fixed-width) or p (proportional, i.e., variable-width). In Release 4, fonts may also have the spacing characteristic c (character cell, a fixed-width font based on the traditional typewriter model, in which each character can be thought to take up the space of a “box” of the same height and width). As mentioned earlier, the original R2 fonts were of this type.
Mean width of all characters in the font, measured in tenths of a pixel. You’ll notice, if you look back at Figure 5-2, that two fonts with the same point size (such as New Century Schoolbook and Times) can have a very different average character width. This field can sometimes be useful if you are looking for a font that is especially wide or especially narrow. The Clean family of fonts from Schumacher offers several fonts in the same point size, but with different average widths.*
In the initial illustration of the font naming convention (Figure 5-1), we identified the character set as a single field. If you look more closely, you’ll realize it is actually two fields, the first of which identifies the organization or standard registering the character set, the second of which identifies the actual character set.
Most fonts in the standard X distribution contain the string “iso8859-1” in their names, which represents the ISO Latin-1 character set. The ISO Latin-1 character set is a superset of the standard ASCII character set, which includes various special characters used in European languages other than English. See Appendix H of Volume Two, Xlib Reference Manual, for a complete listing of the characters in the ISO Latin-1 character set.
Note, however, that the symbol font contains the strings “adobe-fontspecific” in this position. This means that Adobe Systems defined the character set in this font, and that it is font-specific. You can see from this example that the usage of these fields is somewhat arbitrary.
Not represented in the example or in most R3 or R4 font names. However, according to the logical font convention, the style of a font may be specified in the field between set width and pixels. Some of the possible styles are i (informal), r (roman), serif and sans (serif). Note that the r for roman may also be used in the slant field.
For a complete technical description of the font naming conventions, see the X Consortium Standard, X Logical Font Description Conventions. This document is available as part of the standard MIT X distribution, and is reprinted as Appendix M in the second edition of Volume 0, X Protocol Reference Manual.
Prior to Release 3, the use of wildcards within font names was restricted to specifying fonts to list with xlsfonts. If you are running Release 3 or Release 4, wildcarded font names can also be used to specify the display font for a client, either on the command line or in a resource specification.
An asterisk (*) can be used to represent any part of the font name string; a question mark (?) can be used to represent any single character. You can usually get the font you want by specifying only the font family, the weight, the slant, and the point size, and wildcarding the rest. For example, to get Courier bold at 14 points, you could use the command line option:
However, there are a number of “gotchas.”
• First, since the UNIX shell also has a special meaning for the * and ? wildcard characters, wildcarded font names must be quoted. This can be done by enclosing the entire font name in quotes (as in the previous example), or by “quoting” each wildcard character by typing a backslash before it. (If you don’t do this, the shell will try to expand the * to match any filenames in the current directory, and will give the message “No match.”) Wildcards need not be quoted in resource files.
• Second, if the wildcarded font name matches more than one font, the server will use the first one that matches. And unfortunately, because the names are sorted in simple alphabetical order, the bold weight comes before medium, and italic and oblique slants before roman. As a result, a specification like:
will give you Courier bold oblique, rather than the Courier medium roman you might intuitively expect.
If you aren’t sure whether your wildcarded name is specific enough, try using it as an argument to xlsfonts. If you get more than one font name as output, you may not get what you want. Try again with a more specific name string.
The exception to this rule has to do with the 75dpi and 100dpi directories. If a wildcard matches otherwise identical fonts in these two directories, the server will actually use the one in the directory that comes first in the font path. This means that you should put the appropriate directory first in the font path. (We’ll tell you how to do this in the next section.) Thereafter, you can generally wildcard the resolution fields (unless you specifically want a font from the directory later in the path).*
• Third, the * wildcard expansion is resolved by a simple string comparison. So, for example, if you were to type:
(the difference being the asterisk instead of the hyphen before the “r” in the slant field), the “r” would also match the “r” in the string “normal” in the set width field. The result is that you would select all slants. Since o (oblique) comes before r (roman), and you always get the first font that matches, you’d end up with Courier oblique.
Even though a wildcarded name such as:
should get you 14-point Courier bold roman, we think it is good practice to spell out the font family and the weight, and to use hyphens between adjacent fields. As usual, there are exceptions: the Lucida family really has three subfamilies; you can get all three by specifying the family as “Lucida*” rather than “Lucida-”; and you might certainly want to abbreviate “New Century Schoolbook” to “New Century*” or “*Schoolbook.”
• Font names are case-insensitive. “Courier” is the same as “courier.”
Table 5-2 summarizes the values you can use to specify a unique font name (assuming only the standard fonts are loaded). Choose one element from each column. Don’t forget to include the leading and trailing asterisks, and the hyphen before the slant.
In both Release 3 and Release 4, fonts are stored in three directories, as shown in Table 5-3.
Release 3: Six fixed-width fonts (also available in Release 2), plus the cursor font.
Release 4: Sixty fixed-width fonts, including the six available in Release 3, the cursor font, several Clean family fonts provided by Schumacher, a Kanji font, Kana fonts, and OPEN LOOK cursor and glyph fonts.
Fixed- and variable-width fonts, 75 dots per inch.
Release 3: The Adobe Charter font family, 100 dots per inch.
Release 4: Fixed- and variable-width fonts, 100 dots per inch (all font families).
These three directories (in this order) comprise X’s default font path.
Other directories can be added to the font search path, or its order can be rearranged, using xset with the
fp option. To completely replace the font path, simply specify a comma-separated list of directories. For example, to put the 100dpi directory before the 75dpi directory, you might enter:
% xset fp= /usr/lib/X11/fonts/misc,/usr/lib/X11/fonts/100dpi,\
(Note that a space must follow the equal sign, and that the example above is broken onto two lines escaped with a backslash only so that it can be printed within the page margins.) To restore the default font path, type:
% xset fp default
fp+ option to add a directory or list of directories to the end of the font path, or
+fp to add them at the start. Use
fp- to delete directories from the beginning or end of the font path.
For a complete listing of the fonts in each directory and samples of each font, refer to Appendix E, Release 3 and 4 Standard Fonts.
In addition to font files, each font directory contains a file called fonts.dir. The fonts.dir files serve, in effect, as databases for the X server. When the X server searches the directories in the default font path, it uses the fonts.dir files to locate the font(s) it needs.
Each fonts.dir file contains a list of all the font files in the directory with their associated font names, in two-column form. (The first column lists the font file name and the second column lists the actual font name associated with the file.) The first line infonts.dir lists the number of entries in the file (i.e., the number of fonts in the directory).
Example 5-1 shows a portion of the fonts.dir file from the Release 4 /usr/lib/X11/fonts/100dpi directory. As the first line indicates, the directory contains 200 fonts. The first group of fonts listed below (up to the second ellipse) are available as of Release 4. They arc all Courier family fonts. (These fonts are 100-dpi equivalents of fonts that in Release 3 were only available in 75-dpi.) The second group of fonts shown in the list below (a few sizes from the Charter family) are also available in the Release 3 100dpi directory.
The fonts.dir files are created by the mkfontdir client when X is installed. mkfontdir reads the font files in directories in the font path, extracts the font names, and creates a fonts.dir file in each directory. If fonts.dir files are present on your system, you probably won’t have to deal with them, or with mkfontdir at all. If the files are not present, or if you have to load new fonts or remove existing ones, you will have to create files with mkfontdir. Refer to Appendix A, System Management, for details.
Another way to abbreviate font names is by aliasing (that is, by associating fonts with alternative names of your own choosing). You can edit or create a file called fonts.alias, in any directory (or multiple directories) in the font search path, to set aliases for existing fonts. The X server uses both fonts.dir files and fonts.alias files to locate fonts in the font path.
If you are running Release 3, there should already be an alias file in the misc directory. Release 4 provides a default fonts.alias file for each of the three font directories. Take the time to look at the contents of each of these files, since many of the existing aliases may be easier to type than even wildcarded font names. You can also add aliases to the file, change existing aliases, or even replace the entire file. However, this should be done with caution. To play it safe, it’s probably a good idea merely to add to existing fonts.alias files. If you’re working in a multi-user environment, the system administrator should definitely be consulted before aliases are added or changed. Note that when you create or edit a fonts.alias file, the server does not automatically recognize the aliases in question. You must make the server aware of newly created or edited alias files by resetting the font path with xset.
The fonts.alias file has a two-column format similar to the fonts.dir file: the first column contains aliases, the second contains the actual font names. If you want to specify an alias that contains spaces, enclose the alias in double quotes. If you want to include double quotes or other special characters as part of an alias, precede each special symbol with a backslash.
When you use an alias to specify a font in a command line, the server searches for the font associated with that alias in every directory in the font path. Therefore, a fonts.alias file in one directory can set aliases for fonts in other directories as well. You might choose to create a single aliases file in one directory of the font path to set aliases for the most commonly used fonts in all the directories. Example 5-2 shows three sample entries that could be added to an existing fonts.alias file (or comprise a new one).
As the names of the aliases suggest, these sample entries provide aliases for three fonts (of different point sizes) that are easily readable in xterm windows. (We also recommend the fixed-width font stored in the file 9x15.snf,* in the misc directory.) You can also use wildcards within the font names in the right-hand column of an alias file. For instance, the alias file entries above might also be written:
In Release 2 of X, a font name is equivalent to the name of the file in which it is stored, without the .snf extension. In the previous edition of this book (which dealt primarily with Release 3 of X), we recommended a method for emulating this convention. This involved creating a fonts.alias file containing the following line in every directory in the font path:
You could then use a filename (without the .snf extension) to specify a font. Due to changes implemented in the Release 4 server, X Window System developers are now discouraging this practice.
If you would still like to emulate Release 2 conventions in Release 3 or Release 4, you must explicitly assign every font name an alias corresponding to the name of the file in which it is stored, without the .snf extension. This could actually be done rather easily by editing a copy of each fonts.dir file and appending the copy to the fonts.alias file in the same directory. (If you are running Release 3, remember that neither the 75dpi nor the 100dpi directory has a default fonts.alias file. You may need to create one, rather than append to an existing one. These aliases could also be appended to the fonts.alias file in the misc directory, since the server searches all directories in the font path.)
Once the server is made aware of aliases, you can specify an alias on the command line. For example, you can use a font name alias as an argument to xfd. If you’ve used an alias file or files to emulate the Release 2 font naming conventions, you can display the font stored in the file courR12.snf using the command:
% xfd -fn courR12
A special note about the misc directory: when X was configured for your system, a fonts.alias file should have been created in this directory. The first two entries in this file are shown below.
The default file contains an additional 56 entries, but the entries pictured above are particularly important. The aliases called “fixed” and “variable” are invoked as the default fonts for many clients. The “fixed” font can be thought of as a system-wide default. The “variable” font, described in the right-hand column as a 12-point bold Helvetica font, is used as the default font by bitmap, as well as by other clients. If this file is removed or replaced, when you run bitmap, you’ll get an error message that the server cannot open the variable font, and text in the bitmap window will display in the smaller, somewhat less readable “fixed” font.
If you do choose to edit the fonts.alias file in the misc directory, it is important to preserve at least these two aliases. (As we’ve said, it’s probably a better idea to keep all the default entries and merely append any new ones.)
If you’re running Release 3, the fonts.alias file in the misc directory will be somewhat different. The Release 3 version of the fonts.alias file in the misc directory is comprised of only the following two lines:
Regardless of what edits you make to the file, the line specifying the variable alias must not be changed.
The variable font is slightly larger in Release 3 (14-point) than in Release 4 (12-point). If you examine the Release 3 alias file a little more closely, you may notice that the first line contains an incorrect alias specification. Remember, in Release 3, fixed is actually the name of the default system font—it is not an alias. The first column should contain aliases and the second column should contain proper font names. However, 6×13 is not a proper font name. It is actually the name of the file that contains the font named “fixed.” You can specify fixed as a font on the command line and it will work—but as a font name, not an alias.
After you create (or update) an alias file, the server docs not automatically recognize the aliases in question. You must make the server aware of newly created or edited alias files by “rehashing” the font path with xset. Enter:
% xset fp rehash
on the command line. The xset option
fp (font path) with the
rehash argument causes the server to reread the fonts.dir and fonts.alias files in the current font path. You need to do this every time you edit an alias file. (You also need to use xset if you add or remove fonts. See Appendix A, System Management, for details.)
We’ve already mentioned xlsfonts, which simply displays the names and aliases of available fonts. In addition, xfd can be used to display the full character set of a particular font, and xfontsel can be used to interactively preview and select a font for use in another window.
If you’re unfamiliar with general appearance of a particular font, we’ve included pictures of some representative fonts in Appendix E, Release 3 and 4 Standard Fonts.
You can also display the characters in a font using the xfd (font displayer) client. Note that since Release 3, xfd has taken an option,
-fn, before the font name. For example, to display the default system font, a 6×13 pixel fixed-width font known as fixed*, enter:
The xfd window will display the specified font as shown in Figure 5-7.
This figure depicts the Release 4 version of xfd, which has been greatly enhanced since Release 3. The font name is now displayed across the top of the window. (This is the actual font name, which we specified on the command line by the alias fixed.) Three command buttons have also been added to the application in Release 4. They appear in the upper-left of the window, below the font name. If the font being displayed doesn’t fit within a single xfd screen,
Prev Page and
Next Page allow you to scroll through multiple screens. (The horizontal and vertical dimensions of the window can vary slightly to accommodate different fonts, but certain fonts will still require multiple screens.) The
Quit button causes the application to exit, though this can also be done by typing q or Q anywhere within the window.
In addition to displaying a font, xfd also allows you to display certain information about the individual characters. But before we examine these capabilities, let’s take a closer look at the way the characters in a font are identified and how the xfd window makes use of this information.
Within a font, each character is considered to be numbered. The xfd client displays a font’s characters in a grid. By default, the first character of the font appears in the upper-left position; this is character number 0. The two text lines above the grid identify the upper-left character and the range of characters in the window, by character number(s) both in hexadecimal and in decimal notation (in parentheses following the hex character number).
You can specify a character other than character number 0 to be in the first position in the window using the
-start option. For example, if you enter the following command line:
% xfd -start 15 -fn fixed &
the xfd window begins with character number 15.
Notice the instruction
Select a character below the command buttons. To display information about a particular character, click any pointer button within its grid square. Statistics about the character’s width, left bearing, right bearing, ascent, and descent are displayed where the line
Select a character previously appeared.
If you are running the Release 3 version of xfd, read the section “Release 3 xfd.”
The xfd client is most useful when you have an idea what font you might want to display. If you don’t have a particular font in mind or would like to survey the possibities, the xfontsel client (available as of Release 4) allows you to preview a variety of fonts by specifying each component of the font name using a different menu. See the section “Previewing and Selecting Fonts: xfontsel” later in this chapter.
The Release 3 version of xfd is not as flexible or as self-explanatory as the Release 4 version. It offers no command buttons, no line identifying the font name, and no obvious scrolling capabilities. However, it is still very useful for looking at a particular font.
Like the Release 4 version, by default the Release 3 xfd displays character number 0 of the font at the upper left of the window. To see a character’s number, move the pointer to the desired character and click the middle button. That character’s number is displayed both in decimal and in hexadecimal notation at the bottom of the window, as in the following:
This version of xfd also accepts the
-start option, which lets you specify the first character of the font that appears at the upper left of the window.
Every character in the font may not fit in the window at once. Though this version of the application does not feature the handy command buttons introduced at Release 4, you can still view the obscured characters. To see additional characters, move the pointer to the xfd window and click the third (usually the right) mouse button. The next window full of characters is displayed. To see the previous window of characters, click the first (usually the left) mouse button. xfd beeps if an attempt is made to go back past the first (0) character.
The Release 3 xfd also provides statistics about the individual characters in a font, but you must run the client with the
-verbose option to access this information. Then, to see information about a character’s width, left bearing, right bearing, ascent, and descent, move the pointer to the desired character and click the second (usually the middle) button. The information is displayed in a portion of the window below the character grid.
To display the minimum or maximum values taken by each of these fields over the entire font, move the pointer to the desired character and type a less than symbol (<) to display the minimum values or a greater than symbol (>) to display the maximum. Information similar to the following is displayed below the grid:
left bearing = 2, right bearing = 6
ascent= 10 , descent = 3
width = 6
The xfontsel client, available as of Release 4, provides a font previewer window in which you select the font to view using 14 menus corresponding to the 14 components of a font name. By specifying various font name components, you can take a look at a variety of fonts. This is particularly useful if you are trying to pick good display fonts and you don’t have a very clear idea what type of font would be best. Rather than running several instances of xfd, you can dynamically change the font displayed in the xfontsel window by changing the font name components. (Despite the flexibility of xfontsel, it’s certainly not practical to preview all of the available fonts. If you have no idea what particular font families look like, see the discussion earlier in this chapter, or refer to Appendix E, Release 3 and 4 Standard Fonts, for complete listings.)*
Once you’ve displayed the desired font using the menus, you can make the name of that font the PRIMARY text selection by clicking on the window’s select button. (Selecting text is described in Chapter 4, The xterm Terminal Emulator.) You can then paste the font name into another window using the pointer: onto a command line, into a resource file, etc. Making a font name the PRIMARY selection also enables you to choose that font from the xterm
VT Fonts menu, described in Chapter 4.
To run xfontsel, enter the following command in an xterm window:
% xfontsel &
If your system is using the standard Release 4 fonts, the xfontsel window initially displays a bold, constant-width, 7×13 pixel font, from the misc font directory, as shown in Figure 5-8. This is the first font in the default font search path.
The upper-left corner of the xfontsel window features two command buttons:
select. As we’ve explained, clicking on
select (with the first pointer button) makes the font displayed in the window the PRIMARY text selection. Obviously,
quit causes the application to exit.
Below the command buttons is, in effect, a generic font name or font name template. It is divided into 14 fields corresponding to the 14 parts of a standard font name. Each field is an abbreviation for one part of a font name. Take a look again at the sample font name in Figure 5-1 to refresh your memory as to the components. Each of the fields in the xfontsel window is actually the handle to a menu, which lets you specify this part of the font name.
To get a clearer idea of how this works, move the pointer onto the generic font name, specifically onto the first field,
fndry. (This is an abbreviation for the first part of a font name, the foundry.) When you place the pointer on
fndry, the field title should be highlighted by a box. You can then display a menu of foundry names by pressing and holding down the first pointer button, as in Figure 5-9.
Notice that the first choice is the asterisk (*) wildcard character. This is the first choice on all of the menus and thus allows you to include wildcards in the font name you specify, rather than explicitly selecting something from all 14 menus.
To specify a font name component (i.e., make a selection from the menu), continue to hold down the first pointer button and move the pointer down the menu. As the pointer rests on each menu item, it is highlighted by reverse video. To select a highlighted menu item, release the first pointer button.
The line below the font name menus represents the actual font name. When you first run xfontsel, all of these fields contain wildcard characters because no menu selections have been made. The number of fonts matched by the font name is displayed in the upper-right corner of the window. The number of fonts matched initially depends on the number of fonts with this naming convention available on your system. In this example, 474 fonts match. (Since this line of wildcards can match any 14 part font name, the server chooses the first font in the font path that reflects this naming convention.)
When you select a font name component from one of the 14 menus, the component appears in the actual font name, and the xfontsel window displays the first font that matches this name. For example, say we select
adobe from the
fndry menu, the xfontsel window would look like Figure 5-10.
and the window displays the first font in the font path to match this wildcarded name. In this case, the first font to match is a 12-point bold Oblique Courier font, which is stored in the file courBO10.snf and has the actual font name:
Once you make a selection from one menu, the number of possible fonts matched by the name changes. (Notice the line
204 fonts match in the upper-right corner of the window.) Choosing one font name component also eliminates certain choices on other menus. For example, after you select Abobe as the foundry, the possible choices for font family (the second menu,
fmly) are narrowed from 14 to 5 (not counting the asterisk). Again display the
fmly menu using the first pointer button. The available choices for font family appear in a regular typeface; the items that cannot be selected appear in a lighter typeface. Families such as Clean, Lucida, and Charter are in a lighter typeface because none of the standard X fonts provided by Adobe are from these families. Adobe fonts in the standard X distribution are limited to the five families Courier, Helvetica, New Century Schoolbook, Symbol, and Times, and these are the items available on the
In order to display a particular font, you’ll probably have to make selections from several of the menus. As described earlier in the section “Font Name Wildcarding,” we suggest you explicitly select at least the following parts of the font name:
• Font family
• Point size
Thus, you would make selections from the
fmly, wght, slant, and
You can also usc the -pattern option with a wildcarded font name to start out with a more limited range of options. For example, if you typed:
% xfontsel -pattern '*courier-bold-o-*'
you’d start out with the pattern you specified in the filename template part of the xfontsel display. You could then simply select from the
ptSz menu to compare the various point sizes of Courier bold oblique until you found the one you wanted.
Note that if the pattern you specify to xfontsel matches more than one font, the one that is displayed (the first match found) is the one that the server will use. This is in contrast to xlsfonts, which sorts the font names. You can always rely on xfontsel to show you the actual font that will be chosen given any wildcard specification.
Once you compose the name of the font you want by making selections from the menus, the corresponding font is displayed in the xfontsel window. Then you can select that font name by clicking on the select command button with the first pointer button. The font name becomes the PRIMARY text selection and thus can be pasted in another window using the second (usually the middle) pointer button, as described in Chapter 4, The xterm Terminal Emulator.
You might paste the font name on a client command line in an xterm window, in order to specify it as the client’s display font (See Chapter 8, Command Line Options.) You might paste it into a resource file such as .Xresources to specify it as the default font for a client or some feature of a client (such as a menu). (See Chapter 9, Setting Resources, for more information.)
Less obviously, once a font name is made the PRIMARY text selection, it can be toggled as the xterm display font using the
Selection item of the xterm
VT Fonts menu. The
Selection menu item can only be chosen from the
VT Fonts menu when there is a PRIMARY text selection. (Otherwise, the menu item appears in a lighter typeface, indicating that it is not available.) If the PRIMARY text selection is a valid font name (as it is when you’ve pressed the
select button in the xfontsel window), the xterm window displays in that font (In cases where the PRIMARY selection is not a valid font name, the xterm display font does not change.)
By default, xfontsel displays the lower and uppercase letters a through z and the digits 0 through 9. You can specify alternative sample text using the
-sample option. For more information about this and other options, see the xfontsel reference page in Part Three of this guide.
As discussed in Chapter 4, The xterm Terminal Emulator, xterm includes a VT Fonts menu that allows you to change fonts on the fly. We discussed most of the menu entries in Chapter 4. However, two of the many items require a greater understanding of font naming than we’d covered by that point. So we’ve saved them until now.
Though it is by no means obvious, xterm allows you to change the display font by sending an escape sequence, along with the new font name, to the terminal window. Once you change the font in this way, the
Escape Sequence item on the xterm VT Fonts menu becomes available and choosing it toggles the font you first specified with the escape sequence. (In effect, whatever font you specify using the escape sequence is stored in memory as the menu’s
Escape Sequence font selection.)
You send an escape sequence to the terminal window by using the UNIX echo(1) command. The escape sequence to change the xterm display font is comprised of the following keystrokes:
To clarify, these keystrokes are: the Escape key, the right bracket (]), the number 50, a semicolon (;), a
fontname, and the Control-G key combination. We’ve shown the keystrokes with spaces between them for readability, but when you type the sequence on the command line, there should be no spaces. Note also that to supply this sequence as an argument to echo, you must enclose it in quotes:
%echo "Eac]50; fontnameControl-G"
These are the literal keys you type. However, be aware that when you type these keys as specified, the command line will not look exactly like this. Certain keys, like Escape, and key combinations, like Control-G, are represented by other symbols on the command line. When you type the key sequence above, the command line will actually look like this:
%echo "^50; fontname^G"
Typing the Escape key generates the ^[ symbol and typing the Control-G key combination generates ^G. You can use a full fontname, an alias, or a wildcarded font specification as the fontname. You should be aware that if the wildcarded specification matches more than one font, you will get the first font in the search path that matches. For example:
% echo "^50;*courier*^G"
will get you a 10-point courier bold oblique. The advantage of being able to change the display font with an escape sequence is that it allows you to add another font to your choices on the fly.* Changing the fonts associated with the
Tiny, Small, Medium, and
Large menu items is a more laborious process. It involves specifying other fonts in a resource file, making those resources available to the server, and then running another xterm process. (See Chapter 9, Setting Resources, for more information.) However, you can change the font specified by the
Escape Sequence menu item as often as you want during the current xterm process, simply by typing the escape sequence described above.
Now that we’ve looked at the mechanics of the escape sequence, let’s consider its practical use. Say you want to run a program in an xterm window and you want to be able to read the output easily, but you would like the window to be moderately small. You discover that toggling the
Medium font, the
8x13 font by default, makes the window a good size, but the typeface is too light to be read easily. (We presume you are using the default menu fonts and have not customized them using a resource file.) You could dynamically change the display font to a bold font of the same size by entering the following command line:
% echo "Esc]50;8x13boldControl-G"
The xterm font becomes the desired
8x13bold, a good choice; in addition, the
Escape Sequence item of the
VT Fonts menu becomes available for selection. This menu item allows you to toggle the
8x13bold font at any time during the xterm process. Thus, you could switch back to any of the other fonts available on the menu (
Small, Large, etc.) and then use
Escape Sequence to again select
This font will remain the
Escape Sequence font for the duration of the xterm process, unless you again change the display font with an escape sequence. If you enter another font name using the escape sequence described above, the window will display in that new font and the
Escape Sequence menu item will toggle it.
Selection menu item allows you to toggle a font whose name you’ve previously “selected.” The font name could be selected with the pointer, for example, from xlsfonts output, using the “cut-and-paste” techniques described in Chapter 4, The xterm Terminal Emulator. It is far more likely, though, that you would use this menu item after selecting a font with xfontsel. This menu item was clearly designed with xfontsel in mind. (If no text is currently selected, this menu item is “grayed out,” indicating that it is unavailable.)
The main limitation of this menu item is that it uses the last text selected as the font name, regardless of what that text is. If you select a font name, that name is only available through
Selection until you use the pointer to select other text. Since cutting and pasting text is one of the most useful features of xterm, you will probably be making frequent selections. If the last selected text was not a valid font name, toggling
Selection will not change the display font, and a beep will inform you that the toggle failed.
The primary intent of this guide is to describe the features of Release 4 of the standard X Window System shipped by MIT. However, we assume that many people are still using Release 3 and that some are still using Release 2. The available display fonts, font naming conventions, and possible system administration tasks supporting fonts changed radically from Release 2 to Release 3. For those who have been using Release 2 display fonts, switching to Release 3 or 4 may take some adjustment. The following two sections will acquaint you with the differences between Release 2 fonts and the fonts provided in later releases and show you how to work effectively with the fonts you have.
All Release 2 screen fonts are stored in a single directory called /usr/lib/X11/fonts.* If you do a listing of that directory, you’ll see a list of filenames with .snf extensions. These are the font files. In Release 2, the name of a font is equivalent to the name of the file in which it is stored, without the .snf extension.
Thus, the file fg-16.snf contains the font fg-16. To create an xterm window in which text will be displayed with the font named fg-16, type the command line:
You can find out which fonts are available by using the xlsfonts client. If you type
xlsfonts in an xterm window, you should get a list of the available fonts, which are summarized in Table 5-4.
These fonts are divided into fixed-width fonts (
typewriter style) and variable-width fonts (proportional). Use only fixed-width fonts for text in an xterm window. (Variable-width fonts would be treated as fixed-width, and would be spaced unevenly.) Use variable-width fonts only with programs designed to use them, such as a PostScript previewer or wysiwyg* editor.
The characters in each font can be displayed using the xfd client. To display the default font, a 6×13 pixel fixed-width font named fixed, type:
% xfd fixed
The resulting xfd window is shown in Figure 5-11.
When a font is referenced by an X client, the font is taken from the directory /usr/lib/X11/fonts unless an explicit path name to another font directory is provided. You can specify an alternative font path using the
fp option to xset, as described in Chapter 11, Setup Clients.
When a font is referenced by an X client, the font is taken from the directory /usr/lib/X11/fonts unless an explicit path name to another font directory is provided. You can specify an alternative font path using the
fp option to xset, as described in Chapter 11, Setup Clients.
*By contrast. the Macintosh supports dozens of font families, and commercial typesetters support hundreds, and in some cases, even thousands of families. Many of these fonts will doubtless be made commercially available for X.
†To generate the figures in this section and in Appendix E, Release 3 and 4 Standard Fonts, we wrote a short program called xshowfonts, which displays a series of fonts in a scrollable window. In each case, we used wildcards (discussed later in this chapter) to select the fonts we wanted, and then did screendumps of the resulting images. Note that the fonts look better on the screen than they do in the illustration, since the scaling factor used to make the screen dumps exacerbates the “jaggies” endemic to bitmap fonts.
Source code for xshowfonts is listed in Appendix E, along with the name of every font. printed in the font itself. Appendix E also includes complete character-set dumps of some of the more unusual fonts.
*Note that the difference are exaggerated further in printing the screen dump of this display. xpr lets you select a scale factor, such that each pixel on the screen appears as scale pixels in the printout. Since the laser printer has a 300-dpi resolution, a scale factor of 4 would produce a true scale screen dump if the resolution on the Sun monitor were truly 75 dpi by 75 dpi. Since it is actually 84 by 84, the printed image is enlarged by about 10%.
*These fonts all (incorrectly to our minds) have a set width of “normal.” They should be distinguished by set widths such as condensed, semi-condensed, etc. Since they do not, they can be distinguished by the difference in their average width.
*Unlike xfontsel, which displays fonts in the order of wildcard matches, xlsfonts will always list fonts in straight sort order, with the sort done character-by-character across the line. Since size in pixels comes before point size in the name, and the size in pixels of the 100-dpi fonts is larger than that of the equivalent 75-dpi font, the 75-dpi font will always be listed first for a given point size. But when listing more than one point size, the fonts will be jumbled. For example, the size in pixels of the 8-point charter font at 1 00-dpi is 11, so it will come after the 1 0-point charter font at 75-dpi, with a size in pixels of 10. The 8-point charter font at 75-dpi gets sorted to the very end of the list, since to a character-by-character sort, its size in pixels (8) looks larger to the size in pixels of even the largest 1 00-dpi font (the 24-point, with a height of 33 pixels).
but is aliased to 9x15 in the default fonts.alias file in the misc directory.
*To our minds, the major drawback of xfontsel is that it shows you only the first font that matches a given wildcarded font name. A far better interface would list all of the matching fonts, so that you could compare and choose the one that most suited your needs. There is no way in the standard X distribution to display the appearance of a group of fonts. To produce the figures in this book, we had to write such a program, which we called xshowfonts. The program has since been posted to comp.sources.x, and a listing appears in Appendix E.
*This is an acronym for “what you see is what you get” and describes a type of text editor or word processor that displays the page exactly as it would appear in print. MacWrite® is a wysiwyg program.