Fonts in the X Window System

Last updates: Thu Oct 11 17:25:23 2001     Thu Sep 13 16:43:57 2007


Table of contents


X11 font formats

Last update: [20-Nov-1997]

Fonts in the X Window System are available in these bitmap forms,

and on some systems, as outline fonts:

The .snf format is considered obsoleted, having been replaced by the .pcf format; however, many of our local systems still use the .snf format.

Outline fonts need to be rasterized into specific sizes; this may be done on-the-fly in the X server, or via a remote font server.

More information on font formats can be found in the GNU Font Utilities documentation in the emacs info and xinfo systems.


Font utilities

The utilities dxfc, bdftopcf and bdftosnf convert between some of these formats, but converters for several font file format combinations are lacking.

getbdf can fetch a font from the X server, and output it in .bdf format. Since there are converters from this format to the others, this utility makes it possible to convert between any pair of formats, albeit by a roundabout route through the X server.

bdfresize can be used to scale a font in .bdf format by a rational factor. The output is also a .bdf file, but before you can use it, you need to edit the FONT line in the output file to change the font name to reflect the altered size.

showsnf can be used to print the contents of an .snf file.

mftobdf can be used to convert Metafont fonts to .bdf format.

The fstobdf utility can read any font from a font server, and output it in .bdf format

The xfd utility displays a table of all characters in a font, for example, xfd -fn 10x20.

The xlsfonts utility lists all of the fonts known to the X server. On many systems, this will produce a long list of 1000--2000 fonts, so if you use it, you probably want to filter its output through a pager, like less, more, or pg, or else through a pattern search utility like agrep, cgrep, ceegrep, egrep, fgrep, grep, or sgrep.

There is a very nice BDF font editor developed at New Mexico State University, xmbdfed. It has a Web page at http://crl.nmsu.edu/~mleisher/download.html with pointers to source code and precompiled binary executable distributions for GNU/Linux, Microsoft Windows NT 4.0, and Sun Solaris 2.x.


How X11 fonts are found

Fonts are found in a directory path established by the xset command, and once the directories have been established, it is necessary to run xset fp rehash to force the X server to read all of the directories and load up the names of fonts found in them:

% xset fp+ /usr/local/share/lib/X11/fonts/European
% xset fp+ /usr/openwin/lib/X11/fonts/F3
% xset fp+ /usr/dt/config/xfonts
% xset fp rehash

The fp+ option adds the directory to the end of the current list, which was originally established by a command in your .xinitrc or .xsession file.

The fp+ option adds the directory to the end If required, you can add a directory to the front of the search path by using +fp instead.

You can find out what the current font path is like this:

% xset q
Keyboard Control:
...
Pointer Control:
...
Screen Saver:
...
Colors:
...
Font Path:
        /usr/openwin/lib/X11/fonts/F3/,
        /usr/openwin/lib/X11/fonts/F3bitmaps/,
        /usr/openwin/lib/X11/fonts/Type1/,
        /usr/openwin/lib/X11/fonts/Speedo/,
        /usr/openwin/lib/X11/fonts/misc/,
        /usr/openwin/lib/X11/fonts/75dpi/,
        /usr/openwin/lib/X11/fonts/100dpi/,
        /usr/openwin/lib/X11/fonts/Xt+/,
        /usr/dt/config/xfonts/C,
        /usr/dt/config/xfonts/C,
        /usr/local/share/lib/amaya/amaya-1.0b/Thot/fonts/,
        /usr/local/share/lib/X11/fonts/100dpi,
        /usr/local/share/lib/X11/fonts/European,
        /usr/local/share/lib/X11/fonts/Ethiopic,
        /usr/local/share/lib/X11/fonts/Asian,
        /usr/local/share/lib/X11/fonts/waterloo,
        /usr/local/share/lib/X11/fonts/Korean,
        /usr/local/share/lib/X11/fonts/Chinese,
        /usr/local/share/lib/X11/fonts/Chinese-BIG,
        /usr/local/share/lib/X11/fonts/Japanese,
        /usr/local/share/lib/X11/fonts/Japanese-BIG,
        /usr/local/share/lib/X11/fonts/Misc

Notice that there are many common directory paths in this list. That is a clue about where to find other fonts. For example,

% ls -F /usr/dt/config/xfonts/
C/         ja/        ko/        tchinese@  zh_TW/
chinese@   japanese@  korean@    zh/

% ls -F /usr/local/share/lib/X11/fonts/
100dpi/        Ethiopic/      Korean/        cyrillic/      ncd/
75dpi/         European/      Misc/          dec/           pcfonts/
Asian/         European-BIG/  axfonts/       fonts/         waterloo/
Chinese/       Japanese/      chinese/       hds/
Chinese-BIG/   Japanese-BIG/  cm/            misc/

% ls -F /usr/openwin/lib/X11/fonts
100dpi/     F3/         Speedo/     Type3/      encodings/
75dpi/      F3bitmaps/  Type1/      Xt+/        misc/

Because most users will use only a rather small number of fonts, their font paths may be rather short. Nevertheless, if you want to take advantage of additional fonts, you should be prepared to investigate the local offerings with suitable ls -F commands as shown above.


European language fonts

Most computer users in the Western World are accustomed to the ASCII or ISO8859-1 Latin 1 character sets, which are standard on computer keyboards (except in the IBM mainframe world). ISO8859-1 is the standard character set used in HTML, the document markup language used on the World-Wide Web.

These character sets offer 128 or 256 characters, which is usually enough for languages such as English, French, German, Danish, .... However, when the accented characters of the European languages are enumerated, then 256 characters are insufficient, and consequently, there are several character set variants, sometimes called code pages, in the ISO8859 Standard which have common lower-128 character assignments, but differ in the upper 128:

ISO8859-0
Latin alphabet No. 0 [old proposal, since replaced by ISO 8859-14 and ISO 8859-15, see below].
ISO8859-1
Latin alphabet No. 1: Western Europe (Danish, Dutch, English, Faeroese, Finnish, Flemish, French, German, Icelandic, Irish, Italian, Norwegian, Portuguese, Spanish, and Swedish). Many other languages can be written in this character set, including Hawaiian, Indonesian, and Swahili.
ISO8859-2
Latin alphabet No. 2: Eastern Europe (Czechoslovakian, English, German, Hungarian, Polish, Rumanian, Serbo-Croatian, Slovak, Slovene).
ISO8859-3
Latin alphabet No. 3: (English, Esperanto, Galician, Maltese and Turkish). Use for Turkish is deprecated, in favor of ISO8859-9 (see below).
ISO8859-4
Latin alphabet No. 4: (English, Baltic languages (Estonian, Latvian, Lithuanian), and Scandinavian languages (Danish, Faeroese, Icelandic, Lappish, Norwegian, and Swedish)).
ISO8859-5
Latin/Cyrillic alphabet: (Bulgarian, Byelorussian, English, (Slavic) Macedonian, Russian, Serbian, Ukrainian (up to 1990)).
ISO8859-6
Latin/Arabic alphabet: (English, Arabic).
ISO8859-7
Latin/Greek alphabet: (English, Greek).
ISO8859-8
Latin/Hebrew alphabet: (English, Hebrew).
ISO8859-9
Latin alphabet No. 5: (Danish, Dutch, English, Finnish, French, German, Irish, Italian, Norwegian, Portuguese, Spanish, Swedish, Turkish), formed by extending ISO8859-1 with additional characters from Icelandic and Turkish.
ISO8859-10
Latin alphabet No. 6: Nordic alphabets: Modification of ISO8859-4 to include characters needed for Sami.
ISO8859-11
Latin/Thai alphabet.
ISO8859-12
Not yet assigned.
ISO8859-13
Latin alphabet No. 7 (Baltic Rim).
ISO8859-14
Latin alphabet No. 8 (Celtic); see ISO/IEC 8859-14:1998 (E) at http://www.indigo.ie/egt/standards/iso8859/8859-14-en.pdf for details.
ISO8859-15
Latin alphabet No. 9 (similar to Latin-1, with euro and oe ligature); see the FDIS for ISO/IEC 8859-15:1998 (E) document at http://www.indigo.ie/egt/standards/iso8859/lat9-en.pdf and http://www.indigo.ie/egt/standards/iso8859/8859-15-en.pdf for details.
ISO8859-16
Latin alphabet No. 10: (Albanian, Croatian, English, Finnish, French, German, Hungarian, Irish Gaelic (new orthography), Italian, Latin, Polish, Romanian, and Slovenian).

More details on these character sets, and some amusing comments on their history, can be found at Roman Czyborra's Web site.

Within the limitations of an 8-bit character set, there are a great many `code pages', that is, assignments of particular glyphs to entries in a 256-character table, with the glyph set chosen to be important for a particular language or region. For an extensive listing of such code tables, follow this link to IBM's code page compendium.

For information about pre-1980 computer character sets, see the excellent book

@String{pub-AW                  = "Ad{\-d}i{\-s}on-Wes{\-l}ey"}

@String{pub-AW:adr              = "Reading, MA, USA"}

@Book{Mackenzie:CCS80,
  author =       "Charles E. Mackenzie",
  title =        "Coded Character Sets: History and Development",
  publisher =    pub-AW,
  address =      pub-AW:adr,
  pages =        "xxi + 513",
  year =         "1980",
  ISBN =         "0-201-14460-3",
  LCCN =         "QA268 .M27 1980",
  bibdate =      "Wed Dec 15 10:38:43 1993",
  price =        "US\$24.95",
  series =       "The Systems Programming Series",
}

Asian language fonts

Chinese, Japanese, and Korean pose a much larger problem for font designers and font software, because each requires several thousand characters.

The X Window System font file formats can support up to 65,536 characters in a font, but not all font software works properly with these fonts. In particular, on Sun Microsystems systems, /usr/openwin/bin/xfd will display only the first 256 characters in such a font. You need to use /usr/local/X11R5/bin/xfd to view such fonts.

Until recently, vendor support of Asian language fonts was spotty, at least in the vendors of the systems normally sold in North America. Fortunately, the Free Software Foundation has collected a large number of international fonts contributed by many individuals and companies around the world, and our local systems now have all of them available for use.

The sample listing above for the directory /usr/local/share/lib/X11/fonts/ shows subdirectories containing fonts for Chinese, Japanese, Korean, ISO-8859-n European, Asian (Devanagiri, Lao, Tibetan, and Thai), Arabic, and Hebrew. Some of these are still incomplete (notably, Devanagiri), and there is still no coverage of the scripts required by most the major languages of India, nor of Persian and Urdu, nor of any of the south-central Asian languages, such as Georgian.


Unicode fonts

Roman Czyborra has developed prototype Unicode fonts for the X Window System: see http://czyborra.com/unifont/ for details.

Markus Kuhn has developed prototype ISO10646-1 (Unicode) fonts for the X Window System; see http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html for details.

Microsoft maintains a comprehensive Web site on Unicode-related issues at http://www.microsoft.com/globaldev/

More information on Unicode fonts is available here: http://www.math.utah.edu/~beebe/fonts/unicode.html


Font file names

Fonts in the X Window System have long descriptive names, but such names are often inconvenient to type, so provisions are made for aliases.

Each X11 font directory contains one or two additional files beside the font files: fonts.dir and fonts.alias.

The fonts.dir file is created by the mkfontdir utility, which reads all of the font files in the directory and extracts their long names. A typical file looks like this:

% cd /usr/local/share/lib/X11/fonts/Asian
% head -5 fonts.dir
14
mule-indian-24.pcf -misc-fixed-medium-r-normal--24-240-72-72-c-120-muleindian-2
thai-16.pcf -misc-fixed-medium-r-normal--16-160-72-72-m-80-tis620.2529-1
thai-14.pcf -misc-fixed-medium-r-normal--14-140-72-72-m-70-tis620.2529-1
thai-24.pcf -misc-fixed-medium-r-normal--24-240-72-72-c-120-tis620.2529-1

The first line contains a font count, and the remaining lines consist of a file name, and a long font name.

The fonts.alias file is created by a human, and consists of lines with a short name and a full name, for example:

% cd /usr/local/share/lib/X11/fonts
% cat fonts.alias
a14 -ETL-Fixed-Medium-R-Normal--14-140-72-72-C-70-ISO8859-1
a16 -ETL-Fixed-Medium-R-Normal--16-160-72-72-C-80-ISO8859-1
a24 -ETL-Fixed-Medium-R-Normal--24-240-72-72-C-120-ISO8859-1

Thus, you should use the second of these fonts in an X terminal session like this:

% xterm -fn a14 &
or like this:
% xterm -fn -ETL-Fixed-Medium-R-Normal--14-140-72-72-C-70-ISO8859-1 &

Alternatively, you can switch to such a font in an X terminal selection by getting the font name into the X selection buffer (e.g. by a copy operation in the emacs text editor, or in an xfontsel window), then using Ctrl-Right-MouseButton to popup the VT Fonts menu, and from it select the last item, labelled Selection . This can be convenient if you need to temporarily switch fonts, such as to read an e-mail message in a different character set.

You can find further details of the X Window System font naming conventions in the X11 UNIX manual pages.


Font servers

In order to address some of the deficiencies of font handling in the X Window System, among them the need to propagate many megabytes of font files to each client system, and to rasterize outline fonts into bitmap fonts on-the-fly, X11R5 introduced the idea of font servers.

While font servers may indeed work adequately at sites with all machines purchased from a single UNIX vendor, the experience at our site, which has more than a hundred workstations representing 5 vendors, 8 operating systems, and dozens of hardware models, is that font servers tend to cause hard-to-debug hangs of client systems, and therefore, we choose not to run them. Instead, we simply provide the font files in a common NFS-mounted directory that is accessible to all of our systems. This avoids file space replication, and greatly facilitates maintenance and update of the font collection.


X server font access and file permissions

The X server, which is responsible for rendering fonts, normally runs as the root user, rather than as the logged-in user. In most cases, this is transparent to the human user. However, if there are directories in the font path which reside on another system, and those directories, or files in them, lack world read access, then the X server will not be able to read them, even if the human user can.


X terminals and X11 fonts

X terminals are low-cost workstations that run a simplified UNIX-like operating system that is just sufficient to support running an X server, but no user processes. X terminals usually have no disks, and therefore, no file system.

X terminals may be configured so that the user automatically logs in on a specific remote system, or they may be configured to offer a menu of assorted remote hosts that the user can select from before logging in.

X terminals store a very small set of fonts in read-only nonvolatile memory, and then when they are powered on, or rebooted, they fetch their operating system and other needed fonts from a remote server machine. Because they do not have user accounts on the remote server, there is no password authentication possible, so they get their data via TFTP (Trivial File Transfer Protocol), or via a mount of a memory-mapped read-only NFS (Network File System) tree.

For both TFTP and NFS access, remote servers drastically limit the part of the file system that the X terminals can see, usually just to a small file directory tree provided by the X terminal vendor. For security reasons, this tree does not permit symbolic links to other files or directories outside the tree.

This practice has a significant impact on users who want to use additional X11 fonts:

In the second case, your only recourse is to ask your system management to add your personal X11 font collection to the X terminal TFTP trees.

If I login to a local X terminal (an HDS ViewStation) and run xset q, here is what I get for a font path:

% xset q
...
Font Path:
        /builtin/,
        /hds/fonts/100dpi/,
        /hds/fonts/75dpi/,
        /hds/fonts/Asterx2.1/,
        /hds/fonts/Asterx3.0/,
        /hds/fonts/Xol/,
        /hds/fonts/lotus123/,
        /hds/fonts/misc/,
        /hds/fonts/softpc/,
        /hds/fonts/wp5.1/,
        /hds/fonts/international/,
        /hds/fonts/tn/,
        /hds/local/fonts/decwin/100dpi/,
        /hds/local/fonts/decwin/75dpi/

The path /hds represents the root of the TFTP tree, which actually corresponds to the UNIX file path /export/local/netOS/2.0.2 on a local file server.

To solve these problems, at the University of Utah Center for Scientific Computing facilities in the Mathematics Department, we are making rearrangements in the NCD and HDS/Neoware X terminal TFTP trees, and the normal shared X11 font tree, /usr/local/share/lib/X11/fonts, to ensure that the same set of fonts is available in all of them. However, as of the time of writing this [21-Nov-1997], the work is still in progress.