Understanding Font File Formats
Broadly
speaking, fonts come in two types:bitmapped
and outline (or scaleable ).
These two types of fonts have very different characteristics and are best
applied in different ways. Common Linux font servers support both types of
font. It's important that you understand the differences between them, as well
as know examples of specific font formats, so you know what their capabilities
and limitations are.
Bitmapped Font Formats
Most computer
font display devices, including the most common types of computer video cards
and printers, break their display areas into a fine grid. Within this grid,
each square (known as a pixel, a shortening of picture element ) is assigned a color. In the case of
a two-color display like a monochrome laser printer, the color may be only one
of two values, such as black or white. Color printers and modern monitors
support multiple colors, but standard X font-handling only supports two colors.
(You can set what those colors are, such as black and white or red and yellow,
but there may be only two of them for any given letter.) Thus, each
pixel of a font can be represented by a single bit. The point of all this is
that computers must shoehorn fonts into a computer display, which can be
considered a map of bits, or a bitmap. One
obvious way to do this is to represent the fonts directly in this form. This is
the bitmapped font approach.
for a single letter in a bitmapped font. This representation has many important
characteristics, even aside from the details of which pixels are black and
which are white. For instance, the grid used to represent the letter is of a
fixed size. In a proportionally-spaced font,
like the one used for most text in this book, some letters are wider than
others. Thus, bitmapped font formats usually permit variable grid widths in a
single font. The height is usually fixed, though. (Letters with descenders, which are elements that extend below the
bottoms of most letters, like portions of the letters g,
j, p, q, and y, simply use
parts of the grid that are lower than those used by most other letters. Note
that in href="http:// /JVXSL.asp?x=1&mode=section&sortKey=insertDate&sortOrder=desc&view=&xmlid=0-201-77423-2/ch15lev1sec2&open=true&title=New%20This%20Week&catid=&s=1&b=1&f=1&t=1&c=1&u=1#ch15fig01#ch15fig01"> Figure 15.1 , the letter is positioned high
within its grid, to permit descenders for those characters that need them.)
Because the grid is fixed in size, the font appears at a fixed size on any
given device, but if the resolution of the display changes, the font size will
change. To support a single font on many devices, or to support variants of a
font at different sizes on a single device, many different font bitmaps are
required.
Figure 15.1. A bitmapped font
precisely defines which pixels are black and which are white.
that can be arrayed end-to-end in a single inch. Most devices have
approximately the same horizontal and vertical resolutions, but sometimes these
differ. Monitors usually have resolutions of between 72 and 120 dpi, while
printers usually support resolutions of 144 to 1200 dpi (the lowest of these printer
resolutions are used for fast or low-quality print modes, or on very old
dot-matrix printers; even very old laser printers supported 300 dpi printouts).
Very high-end printers and typesetting equipment support still higher
resolutions. The wide variety of resolutions available, in conjunction with the
need to create a new font file for every resolution and size, leads to one of
the problems of bitmapped fonts: The number of font files required to support
even a modest collection of font display devices is huge.
v:shapes="_x0000_s1026">
Many printers include their own fonts, some of which may be
bitmapped fonts. In the 1980s, these were commonly used instead of fonts
stored on the computer. Today, some programs may use a printer's fonts, but
others rely on fonts stored on the computer.
which is a term from the printing trade. Typical sizes for body text are
roughly 914 points, depending upon the font and the purpose of the text.
Larger point sizes correspond to larger characters on the screen or page. A
bitmapped font is designed to create a specific point size at a specific
resolutionfor instance, 12 points at 144 dpi. The same font file may be used
to create a different point size at a different resolution, such as 24 points
at 72 dpi, but a font designed from scratch for this new resolution might
differ in subtle ways. It's possible to adjust a bitmapped font's size (for
instance, displaying this 12 point, 144 dpi font at 10 points in 144 dpi), but
the result is usually aesthetically unappealing, because pixels will have to be
added or deleted by an artistically challenged computer program.
simple. This simplicity translates into quick display of the fonts; the
computer can move a few bits from a font it's stored in memory to the video
display or printer output buffer to display text in the font. This factor was
important in the 1980s and to a lesser extent in the early 1990s, when bitmap
font formats resulted in noticeably snappier displays than did competing font
formats. Today, CPUs are fast enough that this factor is less important.
formats. Early versions of X used a format called Server Normal Format (SNF),
but SNF fonts are rare today. Most X bitmap fonts today are in the Portable
Compiled Font (PCF) format. The Bitmap Distribution Format (BDF) is another
common bitmap font format for X, but it's usually not used directly by the
server. Instead, you pass a BDF font through a converter program, called bdftopcf , to create a PCF file that X
uses. Other OSs frequently use other font formats, and there are converters
available for some of these, if you want to use a foreign bitmapped font in
Linux.
v:shapes="_x0000_s1027">
XFree86 can use PCF fonts that have been compressed with gzip . Most distributions take advantage
of this fact to distribute fonts in a format that consumes less disk space,
so PCF font filenames typically end in .pcf.gz .
You don't need to uncompress these files to make them available to X.
font formats. The most notable of these is the TeX layout system, which uses
the Packed Font format (these fonts use the .pk
filename extension). Because TeX was designed with printing in mind, not
display of fonts on the screen, TeX Packed Fonts are typically created at much
larger sizes, in terms of width and height in pixels, than are most other
bitmap font formats.
Outline
Font Formats
One of the major problems with bitmap font formats is that
they don't scale well. If you want to support a font at different sizes on the
same display device, or at the same size on a variety of devices, you need
several files. Given the plethora of display devices today, and the demand of
users to be able to scale their fonts in word processors and the like, this
need for multiple files to create a good display is extremely unappealing. The
solution is to use an outline (aka scaleable) font format. These don't describe
the fonts in terms of a bitmap; instead, they use a mathematical description of
a font's curves and lines. For instance, consider href="http:// /JVXSL.asp?x=1&mode=section&sortKey=insertDate&sortOrder=desc&view=&xmlid=0-201-77423-2/ch15lev1sec2&open=true&title=New%20This%20Week&catid=&s=1&b=1&f=1&t=1&c=1&u=1#ch15fig01#ch15fig01"> Figure 15.1 again. If the 8x8 grid is replaced
by one of much higher resolution (say, 80,000x80,000), the H described in that grid can be described in outline
as a series of lines and intersections, as shown in href="http:// /JVXSL.asp?x=1&mode=section&sortKey=insertDate&sortOrder=desc&view=&xmlid=0-201-77423-2/ch15lev1sec2&open=true&title=New%20This%20Week&catid=&s=1&b=1&f=1&t=1&c=1&u=1#ch15table01#ch15table01"> Table 15.1 .
Table 15.1. Partial Outline
Description of Letter H from href="http:// /JVXSL.asp?x=1&mode=section&sortKey=insertDate&sortOrder=desc&view=&xmlid=0-201-77423-2/ch15lev1sec2&open=true&title=New%20This%20Week&catid=&s=1&b=1&f=1&t=1&c=1&u=1#ch15fig01#ch15fig01"> Figure 15.1
Operation
X Coordinate
Y Coordinate
Start
10,000
10,000
Line to
10,000
60,000
Line to
20,000
60,000
Line to
20,000
40,000
etc
Once the outline is complete, it's filled in with a solid
color. This description offers the advantage that it can be easily scaled to just
about any resolution that's desired; all that's needed is remapping the
underlying coordinate grid to the actual coordinate grid. The underlying grid
is of such high resolution that errors in the placement of control points are
trivial. Of course, most fonts require more than simple line descriptions, as
in the preceding example. Outline font formats use mathematical forms to
represent various types of curves, in addition to straight lines. Many of these
formats also include the capacity for hints,
which are overrides a human designer can build into the font to improve the
font's appearance at low resolutions. Without hints, outline fonts have a
tendency to become illegible when displayed at small sizes on low-resolution
devices like computer monitors.
v:shapes="_x0000_s1028">
Technically, a font is a representation at a single size,
and a typeface is a family of fonts at a
variety of sizes. Thus, bitmap fonts are truly fonts, but outline fonts are
more properly called typefaces. The computer industry has largely ignored
this distinction, however, effectively redefining the word font, albeit subtly. I follow the use of the term
in the computer industry in this chapter.
computer has to use the outline description of a font to determine precisely
which pixels will be dark and which will be light, displaying text in an
outline font takes more time than does displaying the same text in a similar
bitmapped font. There are various ways to minimize this problem, such as prerendering
the font at a particular size and using this prerendered version. In some
sense, this is part of what a font server does, because the font server, when
it serves an outline font, renders it and delivers a bitmap to the client. The
client doesn't know whether it's working from an outline font or a bitmap font.
are many bitmap font formats, there are many outline font formats. These
include Bitstream's Speedo, Adobe's Type 1, Type 3, Type 5, and Type 42, and
Apple's TrueType. (Type 42 fonts are really just TrueType fonts encoded for use
on PostScript printers.) These formats differ in more fundamental ways than do
bitmapped font formats, because the outline font formats can use fundamentally
different types of mathematical descriptions of lines and curves. It's often
possible to convert from one format to another, but such conversions frequently
alter the font in subtle ways, or cause hinting information to be lost, thus
degrading the font's appearance at low resolution. Whenever possible, it's best
to use the font in its original format, or obtain an alternate format from the
font's publisher.
(or, more precisely, XFree86) have long supported the Speedo and Adobe Type 1
(aka Adobe Type Manager, or ATM ) outline font formats. Speedo has been a fairly
minor player in the font marketplace and in Linux, but Type 1 fonts are readily
available on commercial font CD-ROMs and the Internet, and Linux ships with
several Type 1 fonts. In the Windows and MacOS worlds, though, TrueType has outstripped
Type 1's popularity, in large part because it's the standard outline font
format in Windows. TrueType fonts are therefore even more available than are
Type 1 fonts. TrueType fonts have a reputation for looking better at low
resolutions than do Type 1 fonts, but this reputation is based largely on a
handful of very well-hinted fonts. Low-cost TrueType fonts that contain little
in the way of hinting often look no better on the screen than do their Type 1
counterparts.
v:shapes="_x0000_s1029">
Microsoft
has made some very well-hinted TrueType fonts, intended for use with Web
browsers, available from its Web site at href="http://www.microsoft.com/typography/fontpack/" target="_blank">http://www.microsoft.com/typography/fontpack/ . The easiest way to use these in
Linux is to download the files intended for Windows 3.1. These are
self-extracting (in Windows) zip file archives; in Linux, you can extract
their contents using the unzip command. You can then install the fonts as described in the upcoming
section, " href="http:// /?xmlid=0-201-77423-2/ch15lev1sec3#ch15lev2sec4"> Common Default Font
Server Configurations ." Many Web sites assume that these fonts are installed, so doing
so can help your users see Web pages as they were intended to be seen.
4.0, XFree86 didn't support TrueType fonts, so the only way to use them in
Linux was through a font server. Today, you can install TrueType fonts directly
in X, but many distributions began using local font servers to provide support
for TrueType fonts prior to the release of XFree86 4.0, and continue to use
these configurations.
isn't the only tool that uses bitmapped fonts, X isn't the only user of outline
fonts. There are various tools available that allow TeX to use outline fonts,
for instance. Of more significance to many users, the Ghostscript program that
functions as a PostScript interpreter for non-PostScript printers can use
outline fontsprimarily Type 1 fonts, but also other formats, including
TrueType. Some word processors require that you install fonts in them as well
as in X. Most of these programs don't use font servers, although some word
processors are an exception, as described in " href="http:// /?xmlid=0-201-77423-2/ch15lev1sec4#ch15lev1sec4"> Running an Expanded
Font Server ."