Although not applicable to every client,
fonts play a major role in many applications. Defined as a set of characters for displaying text and symbols,
fonts share a common appearance in terms of size, boldness, and other physical
characteristics. Fonts themselves can be grouped together into font families.
Additionally, font families are grouped by resolutions (dots-per-inch, or DPI)
into directories. Font families are so named because they were initially stored
together in the same directory in the file system. Each directory contains a
database that the server uses to translate font names into data that the server
uses to display the characters on the screen. How the name of a font is
translated, we see in Figure 0-2.
If the X
client has a font menu like
MS-Windows or Macintosh, life would be easy when it came to fonts. Instead, you
need to choose the font as you start the application.
If you were tired of the boring font used by default on XTerms, you could choose something a little more fancy, perhaps one that looked like cursive. For example, we could start xterm
xterm -fn -bitstream-charter-bold-i-normal--12-120-75-75-p-74-iso8859-1
this appears rather intimidating. There are several hundred fonts on an Linux
system and learning them all is a pain. More than that, it is a waste of time.
Two utilities make like easier for you: xlsfont and xfontsel. The xlsfont
utility simply lists all the available fonts with their complete name, as in the
previous example. The xfontsel is a real X
client that enables you to pick and
choose a font based on different criteria. What those criteria are is helpful in
understanding more about fonts.
Characteristics of the Font Name
The foundry is the fonts developer. Here we have bitstream, which, as one
might guess, is from the company Bitstream, the same people who develop so many
fonts for MS-Windows. The font family (here, charter) is a convenient way of
organizing the fonts by certain appearance characteristics.
The weight of
a font can be thought of as its thickness. Common weights are medium and bold.
The slant, as you might guess, is the change in orientation of the character
from the vertical. A Roman slant is upright, italic is tilted, but the
characters are given a slightly different shape to make them more esthetically
pleasing, and oblique is just tilted with no changes to the characters shape. In
the example in Figure 0-2 we have an italic slant.
The set width is a
general description of the average width. Common set widths are normal,
condensed, and double-width. The size of the font on the screen is determined by
several aspects of the font name. These characteristics are the pixels, points,
and both vertical and horizontal DPI.
Because the appearance on your screen
depends on your monitor as well as what fonts you choose, it's safe to gauge the
font size by the points. A point is an old printers measurement that represents
1/72 of an inch. In the example in Figure 0-2 we have 120 tenths of a pitch,
therefore the size of each character is 1/6 of an inch.
characteristic is the font spacing, which determines whether the font is
proportional or monospaced. A proportional font is one in
which the width of each character is different. Although this looks good on
paper or on a word processor, it is not really suited for applications like
terminal emulators. The monospaced font, in which every character takes up the
same space, is better for such applications.
The character set is
basically another way of saying what letters are represented. In this example
and most others in Linux, this field will be iso8859-1, which represents the ISO
Latin 1 character set, which is a superset of the standard ASCII
character set. In addition to American English characters, iso8859-1 contains the special
characters used in most European languages.
So now that we know what goes
into font name, we can easily come up with the right font. Well, maybe.
Fortunately, we don't have to. We can use a wild card for the parts of the font
that we either don't think are important or don't want to guess at. Any one of the
specifications can be wild carded and the system will do it's best to find a
match. By "do its best," I mean that there can and will be cases in
which multiple fonts match the specification. A rather simple example would
XTerm -fn -bitstream-charter*
On most systems there are 60
matches. So, which one does the system choose? Easy enough: the first one it
finds. Unless you are more specific or know that the first one the system will
find is the font you want, you might not get the font you want. Fonts are sorted
in alphabetical order, and because bold comes before medium, we get the bold
version of this font instead of the medium.
Pop quiz: Why did we enclose
the font name in this example inside single quotes though we didn't in the first
example? Remember that the shell
expands everything into tokens before it passes
things off to the command. If we didn't use the single quotes, the shell
try to expand the font name and we would get a message indicating that the
system cannot find that font. Details on using quotes can be found
Life is even simpler than that. We don't need remember any long, drawn-out font names or try 20 different combinations to find the font we want. We can take advantage of the fact that the system understands font aliases, which are stored in the font directories in the file fonts.alias. These files are ASCII
files with the alias
in the first column and the font name in the second column.
There are two things to keep mind. First, although
you can edit these files and make changes, the system will not recognize the new
alias unless you reset the font path with the xset command, which is simply done
Next, unless you are absolutely positive about what fonts
each user is using and how they are being referenced, it is not a good idea to
remove aliases. If you remove an alias
that some client
is expecting, the results are unpredictable.
If you always want to use a particular font with a particular application,
you don't need to always specify the
looked though the directory files, you wouldn't find a font simply named
ibm10x20; this is actually an alias.
However, you could specify the full name of
the font. Also, just like specifying the font from the command line,
we can use
wild cards to specify the "we-don't-cares."
The directories in
which the fonts are found by the server are referred to by the font path. This
is the XFONTS variable,
which defaults to /usr/lib/X11/fonts but can be changed
using the xset command. Because the server displays the information on the
screen, the font path is on the server, not on the client
machine. Therefore it
is important to ensure that the server is able to display a particular font
before changing it for any given client.
There are five subdirectories under
/usr/lib/X11/fonts varying in size and appearance.
The font database is
contained in the fonts.dir file in each directory. You use this database when
you select a font. The system knows what file to read to be able to show the
proper characters on the screen. The fonts.dir files are ASCII
files with the
name of the font file in the first column and the font name in the second
column. When the system is installed, the mkfontdir reads the font files found
in the font path and creates the fonts.dir files. You can use mkfontdir
yourself, but the details of fonts creation and management goes beyond the scope
of this book.
Rather than requiring every machine on the network
to have a full compliment of fonts, the system has something called a font
server. Like a file server that provides files across the network,
a font server provides fonts across the network. Just like files, if the font you want is not available by the server but is available locally, there is no
problem. You can access it as well.
The font server program, xfs, is not
started by default but can be started in one of several different ways. Although
starting it manually might be good for testing purposes, it is more efficient to
have the font server start up every time the system goes into multiuser mode. As
with many of the differenromant aspects of the system, this is accomplished through a
script in the /etc/rc.d directory. However, there is no script there by default. Obviously, you could write the script yourself, but you ought to let the system
do it for you.
Starting the font server from the command line
recommended for everyday use. To be able to use the fonts provided by the font
server, you need to tell your X
session about it. The best place to do this is
inside your $HOME/.xinitrc file. Although the system administrator (you?) can
change the /etc/xinitrc file, everyone using the default gets to use it, so you need to remember those people who already have their own .startxrc file. Before
any clients are started, use the xset command to specify where the font server is. The general syntax is
where the server
is the name of the machine on which the font server is running, and port is the
TCP broadcast port, which is 7000 by default. For example, to access the font
server on the machine siemau, the command would be
Or, if you want to use local fonts as well, the line might look like this:
The font servers configuration
file is /usr/lib/X11/fs/config. Here you can limit what fonts will be made
available through the font server by changing the catalog entry and specifying
the full paths to the directories with the appropriate fonts. For example, if
you only wanted to have access to the 100 dpi fonts, the line might look like
catalogue = /usr/lib/X11/fonts/100dpi
To make the changes take
effect, either stop and restart the font server or use the /etc/fontserv command to re-read the configuration file and flush the cached entries:
Like name servers in TCP/IP, which get name
information from other name servers, you can have font server get fonts from
other font servers. This is also done with the catalogue entry. For example, if
I wanted to make the local 100 dpi fonts available, as well as the from the
remote host scoburg, the entry might look like this
catalogue = /usr/lib/X11/fonts/100dpi,tcp/scoburg:7000
assuming that scoburg has its
font server configured to use port 7000. Changing the port is also accomplished
by changing the /usr/lib/X11/fs/config file. On a line by itself, add a line
specifying the appropriate port. For example, if you wanted to change it to
7042, the entry would look like this:
Once the change is made, the font server needs to be stopped and restarted. If any other machines
were using this server, they need to be told that it is now set for port 7042.
You can use the