Naming convention: XLFD

Starting with X11 Release 3, fonts have been named using the following convention:


This naming convention is known as the "X Logical Font Description", or XLFD. The fields are defined as follows:

foundry The name of the company that digitized the font.
family The typeface family - Courier, Times Roman, Helvetica, etc.
weight The "blackness" of the font - bold, medium, demibold, etc.
slant The "posture" of the font. "R" for upright, "I" for italic, etc.
setwidth Typographic proportionate width of the font.
addstyle Additional typographic style information.
pixels Size of the font in device-dependent pixels
points Size of the font in device-independent points
horiz Horizontal dots-per-inch for which the font was designed.
vert Vertical dots-per-inch for which the font was designed
spacing The spacing class of the font.  "P" for proportional, "M" for monospaced, etc
avgwidth Average width of all glyphs in the font
rgstry Tells the language the characters conform to. (iso8859 = Latin characters)
encoding Further language encoding information

Here's a sample font name.  This is the XLFD name for the "fixed" font.


Accessing Fonts

How to access a Font

Each font can be accessed using the full XLFD name, the alias name (if there is an alias for the font you want), or by wildcarding certain parts of the XLFD name.  For example, if you want to start xterm using the "6x10" font, you can use any of these commands:
xterm -fn 6x10
xterm -fn -misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1

or possibly by using this command:

xterm -fn "-misc-fixed-*--10-100-*-iso8859-1"

The word possibly is used in the last sentence because the X server  will search through all fonts in the font path, one by one, until it finds one whose XLFD name matches the wildcarded XLFD name.

The default font path for the X server is set up in different ways.  For the R3 X server, the file /usr/lib/X11/Xdeffontpath contains the default font path.  For the R5 X server, there is an entry in /usr/lib/X11/Xconfig that gives the font path.  For X-stations, the font path is set up in the config file loaded by the X-station. For R6 X Servers,
there is an entry in /etc/X11/XF86config that gives the font path.

Determining the Font Path

Fonts are stored in the directory /usr/X11R6/lib/X11/fonts.  There are several directories of fonts here, including misc, 100dpi, 75dpi, pcf, Type1, and 34XX.  To find out which fonts your X server is accessing, you need to find out which directories it is searching for fonts in.  Use the command xset -q to see the "Font Path".  For the R5 X server, the default font path is:
#xset -q

For an R6 X server, the default font path is:

#xset -q

How Fonts are Stored

Each directory in the font path contains font files, along with two special files: fonts.dir and fonts.alias.  The fonts.dir file's first line contains a number, which tells the number of font files in that directory, and is followed by a line for each font file in the following format:
file name    XLFD name

The fonts.alias contains lines in the following format:

alias                XLFD name

Font Utilities


To list all fonts that are available, or to get a listing of all fonts that match a certain pattern, use the xlsfonts utility.  This utility can also be used to extract detailed information about the font, including all XLFD properties and other typographic properties.

From the previous example, we can see which font will match the wildcarded XLFD name:

xlsfonts -fn "-misc-fixed-*--10-100-*-iso8859-1"



which is the full name for the "6x10" font after all.


The xfontsel client provides an easy way to choose a font by building the XLFD font name section by section.  Xfontsel pops up a window, with the 14 XLFD fields each in a button.  The user can select settings for each field, and see what the font that matches the resulting font name looks like.


The xfd client displays all the glyphs in a given font.  It also allows  the user to choose glyphs one at a time, and displays the typographic properties of that glyph.


The xset client allows you to change the "font path" to your liking. To change the font path, use the following command:
xset fp <directory>,<directory>,<directory>...
xset also allows the user to "rehash" the font path.  This causes the X server to re-read each font path directory's fonts.dir and fonts.alias files, so that missing entries can be made to these files or extraneous entries can be removed.
xset fp rehash


If for some reason the "fonts.dir" entry gets corrupted in one of the font path directories, you can use the mkfontdir utility to re-create it.
mkfontdir <directory>

However, if the "fonts.alias" file is corrupted, there is no way to re-create it.  You need to copy a good fonts.alias from another system, and then run xset fp rehash to re-read the alias file.

Font Formats

.bdf Format

The .bdf (Bitmapped Distribution Format) font format is the "source" version of each font.  It is a text file which contains all the XLFD resource values, along with bitmaps of every glyph in the font.

.snf Format

The .snf (Server Natural Format) font format is the "compiled" version of each font, which is used by X servers previous to R5.  The fonts are compiled using the bdftosnf format.  The .snf font data must match the architecture of the X server that is using it (bit and byte order, padding,etc.)  A good example of this can be found here at MCPD-Columbia; the X-Stations we have require a different byte order than the R3 X server.  Thus, we havethe "xstatsup" package, which contains all the .snf fonts from the "xfonts" package, but in a different byte order.

.pcf Format

The .pcf (Portable Compiled Format) font format is new for X11 R5 X servers.  This format eliminates the architecture-dependent requirements of the .snf format.  All X11 R5 servers and X stations will be able to use the same versions of .pcf font files.

.spd Format

The .spd (Speedo) fonts are a type of "scalable" font.  They are able to adapt their "pixels", "points", "horiz", "vert", and "avgwidth" XLFD values to match whatever value is requested by the X server.  Scalable fonts are new to X11R5, and will only work on X11 R5 X servers and X stations.

.pfa Format

The .pfa (Type1) fonts are another set of scalable fonts.

Font Server


X11R5 provides a "font server".  Basically, the font server allows one or more machines to share all or some of its fonts over the network.  Thus, you won't need to install "xfonts" on systems running the R5 X server; they can load their fonts over the network from the font server.

Accessing a shared font

To access shared fonts, the following entry needs to be added to the font path:

tcp/server_name/port_number/:[directory, directory, ...]

When the R5 X server sees an entry beginning with "tcp/" in the font path, it knows to try to connect to the specified server over the port given, and
to access the specified directories, if any.

Sharing fonts

The system that shares fonts runs the font server client xfs.  This program reads the file /usr/X11R6/lib/X11/xfs/config.  This file lists the font directories which the server should export.