Donald Knuth, 1979, Mathematical Typografy, Bull. Amer. Math. Soc. (N.S.) Volume 1, Number 2 (1979), 337-372 PDF
Donald Knuth, 1979, Mathematical Typografy, Bull. Amer. Math. Soc. (N.S.) Volume 1, Number 2 (1979), 337-372 PDF
Donald Knuth, 1979, Mathematical Typografy, Bull. Amer. Math. Soc. (N.S.) Volume 1, Number 2 (1979), 337-372 PDF
MATHEMATICAL TYPOGRAPHY
BY DONALD E. KNUTH
Dedicated to George Plya on his 90th birthday
FIGURE 1 [continued]:
(g) vol 114 (1965), p. 216; (h) vol 125 (1966), p. 38; (i) vol 169 (1972), p. 232;
(j) vol 179 (1973), p. 314; (k) vol 199 (1974), p. 370; (1) vol 225 (1977), p. 372.
CO
CO
to
340 D. E. KNUTH
2
(ADDED IN PROOF). I was pleased to find that this announcement was greeted with an
enthusiastic round of applause when I delivered the lecture.
346 D. E. KNUTH
in proportion to the individual shrinkages z,. In the latter case t is not allowed
to become greater than 1; the glue will never be smaller than x z, although
it might occasionally become greater than x + y. Once the glue has been set,
the box is rigid and never changes its size again.
Consider, for example, a normal line of text, which is a list of individual
character boxes. The glue between letters of a word will have x = y = z = 0,
say, meaning that this word always has the letters butting against each other;
but the glue between words might have x equal to the width of the letter V,
and>> = x9 and z = \x9 meaning that the space between words might expand
or shrink. The spaces after punctuation marks like periods and commas might
be allowed to stretch at a faster rate but to shrink more slowly.
An important special case of this glue concept occurs when we have
"infinite" stretchability. Suppose the x and z components are zero, but the y
component is extremely large, say y is one mile long. If such an element of
glue is placed at the left of a list of boxes, the effect will be to put essentially
MATHEMATICAL TYPOGRAPHY 347
all of the expansion at the left, therefore the boxes will be right-justified so
that the right edge will be flush with the margin. Similarly if we place such
infinitely stretchable glue at both ends of the list, the effect will be to center
the line. These common typographic operations therefore turn out to be
simple special cases of the general idea of variable glue, and the computer can
do its job more elegantly since it is dealing with fewer primitives. Incidentally
you will notice from this example that glue is allowed to appear at the ends of
a list, not just between boxes; actually it is also possible to have glue next to
glue, and boxes next to boxes, so that a list of boxes really is a list of boxes
and glue mixed in any fashion whatever. I didn't mention this before, because
for some reason it seems easier to explain the idea first in the case when boxes
alternate with glue.
The same principles apply to vertical lists. For example, the glue which
appears above and below a displayed equation will tend to be stretchable and
shrinkable, but the glue between lines of text will be calculated so that
adjacent base lines will be uniformly spaced when possible. You can imagine
how the concept of glue allows you to do special tricks like backspacing (by
letting x be negative), in a natural manner.
Line division. One of the more interesting things a system like TEX has to
do is to divide up a paragraph into individual lines so that each line is about
the right length. The traditional way to do this, which is still used on today's
computer typesetting systems, is to make the best possible line division you
can whenever you come to the right margin, but once this line has been
output you never reconsider ityou start the next line with no memory of
what has come before. Actually it often happens that one could do better by
moving a short word down from one line to the next, but the problem is that
you don't know what the rest of the paragraph will be like when you have
only looked at one line's worth.
The TEX system will introduce a new approach to the problem of line
division, in which the end of a paragraph does influence the way the first lines
are broken; this will result in more even spacing and fewer hyphenated
words. Here is how it works: First we convert the line division problem to a
precisely-defined mathematical problem by using TEX's glue to introduce the
concept of "badness". When a horizontal list of boxes has a certain natural
width w (based on the width of its boxes and the space components of its
glue), a certain stretchability y (the sum of the stretch components) and a
certain shrinkability z (the sum of the shrinkages), the badness of setting the
glue to make a box of width W is defined to be 1 + 100*3 in our previous
notation; more precisely, it is
1, if W - w9
l + lOolW"w\9 i!W>w,
1 + l00lW"zW\\ iw-z<W<w>
infinite, if W < w z.
348 D. E. KNUTH
Thus if the desired width W is near the natural width w, or if there is a lot of
stretchability and shrinkability, the badness rating is very small; but if W is
much greater than w and there isn't much ability to stretch, we have a lot of
badness. Furthermore we add penalty points to the badness rating if the line
ends at a comparatively undesirable place; for example, when a word needs
to be hyphenated, the badness goes up by 50, and an even worse penalty is
paid if we have to break up mathematical formulas.
The line division problem may now be stated as follows. "Given the text of
a paragraph and the set of all allowable places to break it between lines, find
breakpoints which minimize the sum of the squares of the badnesses of the
resulting lines." This definition is quite arbitrary, of course, but it seems to
work. Preliminary experiments show that the same choice of breakpoints is
almost always found when simply minimizing the sum of the individual
badnesses rather than the sum of their squares, but it seems wise to minimize
the sum of squares as a precautionary measure since this will also tend to
minimize the maximum badness.
Just stating the line division problem in mathematical terms doesn't solve
it, of course; we need to have a good way to find the desired breakpoints. If
there are n permissible places to break (including all spaces between words
and all possible hypenations), there are 2n possible ways to divide up the
paragraph, and we would never have time to look at them all. Fortunately
there is a technique that can be used to reduce the number of computational
steps to order n2 instead of 2n; this is a special case of what Richard Bellman
calls "dynamic programming." Let (j) be the minimum sum of badness
squares for all ways to divide the initial text of the paragraph up to
breakpoints, including a break aty, and let b{ij) be the badness of a line
that runs from breakpoint / to breakpoint j . Let breakpoint 0 denote the
beginning of the paragraph; and let breakpoint n + 1 be the end of the
paragraph, with infinitely expandable glue inserted just before this final
breakpoint. Then
/(0) = 0;
SU) = omin ((/) + b{ijf), for 1 < j < n + 1.
The computation of /(l), . . . , ( + 1) can be done in order n2 steps, and
S(n + 1) will be the minimum possible sum of badnesses squared. By remem-
bering the values of i at which the minima occurred for each j , we can find
breakpoints that give the best line divisions, as desired.
In practice we need not test extremely unlikely breakpoints; for example,
there is rarely any reason to hyphenate the very first word of a paragraph.
Thus it turns out that this dynamic programming method can be further
improved to an algorithm whose running time is almost always of order n
instead of n2, and comparatively few hyphenations will need to be tried.
Incidentally, the problem of hyphenation itself leads to some interesting
mathematical questions, but I don't have time to discuss them today. (Cf. [41]
and the references in that paper.)
The idea of badness ratings applies in the vertical dimension as well as in
the horizontal; in this case we want to avoid breaking columns or pages in a
MATHEMATICAL TYPOGRAPHY 349
bad manner. For example, penalty points are given for splitting a paragraph
between pages after a hyphenation, or for dividing it in such a way that only
one of its linesa so-called "widow" lineappears on a page. The placement
of illustrations, tables, and footnotes is also facilitated by formulating
appropriate rules of placement in terms of badness.
There is more to TEX, including for example some facilities for handling
the rather intricate layouts often needed to typeset tables without having to
calculate column widths; but I think I have described the most important
principles of its organization. During the next few months I plan to write the
computer programs for TEX in such a way that each algorithm is clearly
explained and so that the system can be implemented on many different
computers without great difficulty; then I intend to publish the programs in a
book so that everyone who wants to can use them.
Entr'acte. I said at the beginning that this talk would be in two parts,
discussing both the ways that typography can help mathematics and that
mathematics can help typography. So far we have seen a little of both, but the
mathematics has been comparatively trivial. In the remainder of my lecture I
would like to discuss what I believe is a much more significant application of
mathematics to typography, namely to the specification of the letter shapes
themselves. A more accurate way to describe the two parts of my lecture
would be to say that the first part was about TEX, a system which takes
manuscripts and converts them into specifications about where to put each
character on each page; and the second part will be about another system I'm
working on called METAFONT, which generates the characters themselves,
for use in the inkier parts of the printing business.
Before I get into the second part of my lecture I need to discuss recent
developments in printing technology. The most reliable way to print mathe-
matics books of high quality during the past several decades has been to use
the monotype process3 which casts characters in hot lead, together with hand
operations for complex built-up formulas. When I watched this process being
applied to my own books several years ago, I was surprised to learn that the
lead type was used to print only one copy; this master copy was then
photographed, and the real printing took place from the photographic plates.
This somewhat awkward sequence of steps was justified because it was the
best way known to give good results. During the 1960s, however, hot lead
type was replaced for many purposes by devices like the Photon machine
used to prepare the printed programs for this lecture; in this case the process
is entirely photographical, since the letter shapes are stored as small negatives
on a rotating disk, and the plates needed for printing are obtained by
exposing the film after transforming the characters into the proper size and
position with mirrors and lenses (cf. [10]). Such machines are limited by slow
speed and the difficulties of adding new characters.
"Third-generation" typesetting equipment. More recent machines, such as
the one used to prepare the current volumes of the Transactions, have
replaced these "analog" processes by a "digital" one. The new idea is to
3
Actually the Monotype Corporation now manufactures digital photosetting equipment as well
as the traditional 'monotype' machines.
350 D. E. KNUTH
divide the page or the photographic negative into millions of tiny rectangles,
like a piece of graph paper or like a television screen but with a much higher
resolution of about 1000 lines per inch. For each of the tiny "pixels" in such a
raster patternthere are about a million square pixels in every square
inchthe typesetting machine decides whether it is to be black or white, and
the black ones are exposed on the photographic plate by using a very
precisely controlled electron beam or laser beam. Since these machines have
few moving parts and require little or no mechanical motion, they can operate
at very high speeds even though they are exposing only a tiny bit of the film
at any time.
Stating this another way, the new printing equipment essentially treats each
page of a book as a huge matrix of 0's and l's, with ink to be placed in the
positions that are 1 while the 0 positions are to be left blank. It's like the
flashcards at a football stadium, although on a much grander scale. The total
job of a system like TEX now becomes one of converting an author's
manuscript into a gigantic bit matrix.
The first question we must ask, of course, is, "What happens to the quality?"
Clearly a television picture is no match for a photograph, and the digital
typesetting machines would be quite unsatisfactory if their output looked
inferior to the results obtained with metal type. In matters like this, I have to
confess being somewhat of a stickler and a perfectionist; for example, I refuse
to eat margarine instead of butter, and I have never heard an electronic organ
that sounds even remotely as beautiful as a pipe organ. Therefore I was quite
skeptical about digital typography, until I saw an actual sample of what was
done on a high quality machine and held it under a magnifying glass: It was
impossible to tell that the letters were generated with a discrete raster! The
reason for this is not that our eyes can't distinguish more than 1000 points per
inch; in appropriate circumstances they can. The reason is that particles of
ink can't distinguish such fine detailsyou can't print the edge of an ink line
that zigzags 1000 times on the diagonal of a square inch, the ink will round
off the edges. In fact the critical number seems to be more like 500 than 1000.
Thus the physical properties of ink cause it to appear as if there were no
raster at all.
It now seems clear that discrete raster-based printing devices will soon
make the other machines obsolete for nearly all publishing activity. Thus in
future days the fact that Gutenberg and others invented movable type will
not be especially relevant; it will merely be a curious historical fact that
influenced history for only about 500 years. The ultimately relevant thing will
be mathematics: the mathematics of matrices of 0's and l's!
Semiphilosophical remarks. I have to tell the next part of the story from my
personal point of view. As a combinatorial mathematician, I really identify
with matrices of 0's and l's, so when I learned last spring about such printing
machines it was impossible for me to continue what I was doing; I just had to
take time off to explore the possibilities of the new equipment. My motivation
was also increased by the degradation of quality I had been observing in
technical journals; and furthermore the publishers of my books on computer
programming had tried valiantly but unsuccessfully to produce the second
edition of volume 2 in the style of the first edition without using the
MATHEMATICAL TYPOGRAPHY 351
(c)
FIGURE 4. Sixteenth century ruler-and-compass constructions for the letter B by
(a) Pacioli [42], (b) Torniello [48], and (c) Palatino [43].
(a) (b)
FIGURE 5. Two more B's, by Tory [49].
Mathematical type design. Fortunately the Stanford Library has a wonder-
ful collection of books about printing, and I had the chance to read many
rather rare source materials. I learned to my surprise that the idea of defining
letters mathematically is by no means new, it goes back to the fifteenth
century and it became rather highly developed in the early part of the
sixteenth. This was the time when there were Renaissance men who combined
mathematics with the real world, and in particular there was an interest in
MATHEMATICAL TYPOGRAPHY 353
FIGURE 6. Roman and italic letters designed for Louis XIV of France [24].
constructing capital letters with ruler and compass. The first person to do this
was apparently Felice Feliciano, about 1460, whose handwritten manuscript
in the Vatican Library was published 500 years later [19]. Feliciano was an
excellent calligrapher who wanted to put the principles of calligraphy on a
sound mathematical foundation. Several other fifteen-century authors made
similar experiments ([8] gives a critical summary of these early developments),
but the most notable work of this kind appeared in the early sixteenth
century.
The Italian mathematician Luca Pacioli, who had previously written the
most influential book on algebra at the time (one of the first algebra books
ever published), included an appendix on alphabets in his De Divina Propor-
tioned a book about geometry and the "golden section" which appeared in
1509. Another notable Italian work on the subject was published by Fran-
cesco Torniello in 1517 [48], [33]; Figure 4 illustrates the letter B as con-
structed by Pacioli, Torniello, and by Giovanbattista Palatino [43]. Palatino
was one of the best calligraphers of the century, and he did this work about
354 D. E. KNUTH
1550. Similar work appeared in Germany and France; the German book was
probably the most famous and influential, it was Albrecht Drer's Underwey-
sung der Messung [18], a manual of instruction in geometry for Renaissance
painters. The French book was also rather popular, it was Champ Fleury by
Geofroy Tory [49], the first royal printer of France and the man who
introduced accented letters into French typography. Figure 5 shows Tory's
two suggestions for the letter B. Of all these books I much prefer Torniello's,
since he was the only one who stated the constructions clearly and unambigu-
ously.
Apparently nobody carried this work further to lower case letters, numer-
als, or italic letters and other symbols, until more than 100 years later when
Joseph Moxon made a detailed study of some beautiful letters designed in
Holland [38]. The ultimate in refinement of this mathematical approach took
place shortly afterwards when Louis XIV of France commisioned the creation
of a Royal Alphabet. A commision of artists and typographers worked on
Louis's project for more than ten years beginning about 1690, and they made
elaborate constructions such as those shown in Figure 6 [24].
Thus it is clear that the mathematical definition of letter forms has a long
history. However, I must also report near-universal agreement among today's
scholars of typography that those efforts were a failure. At worst, the
ruler-and-compass letters have been called "ugly" and at best they are said to
be "deprived of calligraphic grace" [8]. The French designs were not really
followed faithfully by Phillipe Grandjean who actually cut Louis XIV's type,
nor by anybody else to date, and F. W. Goudy's reaction to this was: "God
be praised!" [20, p. 139]. Such strictly geometric letter forms were in fact
criticized already in the sixteenth century by Giovan Cresci, a noted scribe at
the Vatican Library and the Sistine Chapel. Here is what Cresci wrote in
1560:
I have come to the conclusion that if Euclid, the prince of geometry,
returned to this world of ours, he would never find that the curves of the
letters could be constructed by means of circles made with compasses. [16]
Well, Cresci was right. But fortunately there have been a few advances in
mathematics during the last 400 years, and we now have some other tricks up
our sleeves besides straight lines and circles. In fact, it is now possible to
prescribe formulas that match the nuances of the best type designers; and
perhaps a talented designer working with appropriate mathematical tools will
be able to produce something even better than we now have.
Defining good curves. Let's consider the following mathematical problem:
Given n points zl9 z2,..., zn in the plane, what is the most pleasing closed
curve that goes through them in the specified order zX9 z29... 9zn and then
returns to z{t To avoid degenerate situations we may assume that n is at least
4. This problem is essentially like the dot-to-dot puzzles that we give to young
children.
Of course it is not a well-posed mathematical problem, since I didn't say
what it means for a curve to be "most pleasing". Let's first postulate some
axioms that the most pleasing curve should satisfy.
MATHEMATICAL TYPOGRAPHY 355
In the first place, I decided that the cubic equation between zx and z2
should be determined completely by zx and z2 and the directions of the
tangents at zx and z2. We have already seen that these tangents are essentially
predetermined if Properties 4, 5, and 6 are to be valid, and I have also found
frequent occasion in type design when it was desirable to specify that a
certain tangent was to be made horizontal or vertical. Thus, my method of
computing a nice curve through a given sequence of points is first to compute
the tangent directions at each point, then to compute the cubics in each
interval based solely on the endpoints of that interval and on the desired
tangents there. By rotation and translation and scaling, according to Property
1, we can assume that the problem is to go in the complex plane from 0 to 1,
with given directions at the endpoints. The most general cubic equation which
does this is
z(t) = 3/ 2 - 2t3 + ret(l - tf~ se'ln2{\ - /),
and it remains to determine positive numbers r and s as appropriate functions
of 0 and <p.
In the second place, I realized that it was impossible to satisfy Property 6
with cubic splines, because you can't draw a circle as a cubic function of t.
But I wanted to be able to get curves that were as near to being circles as
possible, whenever four consecutive data points lay on a circle; the curves
should preferably be indistinguishable from circles as far as the human eye is
concerned. Therefore when 0 = <p I decided to choose r = s in such a way
that z{\) was precisely on the relevant circle, hoping that the curve between 0
and \ and between \ and 1 wouldn't veer too far away. Well, this turned out
to work extremely well: A little calculation, done with the help of a com-
puter,4 showed that the maximum deviation from a true circle occurs at the
point t = (3 V I )/6, and the relative error is negligibly small. For exam-
ple, if we take four points equally spaced at distance 1 from some center, the
spline curve defined by these points in the above manner stays between
distance 1 and distance 71/54 - 2 V 2 / 9 < 1.00055 from the center, an error
of less than one part in a thousand. If there are 8 points, the maximum error
is less than four parts per million; and if there are n points, the maximum
error goes to zero as l/n6.
(Changing the notation slightly, let
z{t) - 1 + {e* - 1)(3/2 - 2t3)
cos -z 1
'(/) = 8(sin2 | ) (t - l)t(2t - 1)(6/2 - 6/ + 1)
COS -r + 1
4
Thanks are due to the developers of the computer algebra system called MACSYMA at MIT,
and to the ARPA network which makes this system available for research work.
358 D. E. KNUTH
and
w e(
max \z
'4(^)1= 1+
55296
e 10
106168320
while min o < / < 1 |z(0| = *(0) = z{\) = z(l) = 1. The "two-point circle" has
m a x | z ( 0 | = V 2 8 / 2 7 = 1.01835, while the three-point circle has
max|z(0| = V325/324 = 1.001542, and the eight-point cicle has max|z(/)| =
1.0000042455.)
FIGURE 7.
Spline curves with
0 - 0 (5) 120 and <J> = 60
FIGURE 8.
Same as Figure 7
but adjusted so that
r' = max(|, r), s' = max(|, s).
Another case when a natural way to choose r and s suggests itself is when
9 + <p = 90; then the curve z(t) should be nearly the same as an ellipse
having the endpoints on its axes. (This boils down to requiring that (3/ 2 - 2/ 3
- 0/cos <p)t2(l - 0 - l)2 + (3/ 2 - 2/ 3 + (r/cos 9)t{\ - /)2)2 be approxi-
mately equal to 1.) So far therefore I knew that I wanted
r = s = when = <p;
i + cos e ' 1 + cos <p
4 cos 9 4 cos <p
r = (1 + cos 45)(cos 45) ' s = (1 + cos 45)(cos 45)
when 0 + (p = 90
So I tried the formulas
4 cos 9 4 cos <p
5 =
9 + <p'
1 + cos 1 ^ jfcos r J I
2
which fit both cases. However, this didn't give satisfactory results, especially
when 9 + <p approached 180. My second attempt was
4 sin<p 4sin0
r = 0 + <p /, . 0 + <p\ 9 + 9
! ( cos -y-jsm 2
and this has worked very well. Figure 7 shows the spline curves that result
from the above approach when <p = 60 and when 9 varies from 0 to 120 in
5 steps.
MATHEMATICAL TYPOGRAPHY 359
It can be proved that if 0 and <p are nonnegative and less than 180, the
cubic curve z(t) I have defined will never cross the straight lines at angles 0
and <p that meet the endpoints 0 and 1 respectively. This is a valuable
property in type design, since it can be used to guarantee that the curve won't
get out of bounds. However, I found that it also led to unsatisfactory curves
when one of 0 or <p was very small and the other was not, since this meant
that the curve z(t) would be very close to a straight line yet it would enter
that line from outside at a rather sharp angle. In fact, the angle 0 is not
infrequently zero, and this forces a straight line and a sharp corner at the
right endpoint. Therefore I changed the formulas by making sure that both r
and s are always \ or greater unless special exceptions are made; furthermore
I never let r or s exceed 4. Figure 8 shows the spline curves obtained under
the same conditions as Figure 7, but with s set to \ if the above formula calls
for any smaller value.
Using these techniques we obtain a system for drawing reasonably nice
curves, if not the most pleasing ones, and it is especially good at circles. If the
method gives the wrong tangent direction at some point, you can control this
by specifying two points very close together having the desired slope. I have
also included another way to modify the standard tangent directions, in-
tended to make the system as good at drawing ellipses as it is at drawing
circles: Before computing the splines I first shrink the entire figure in the
vertical direction by multiplying all the y coordinates by a given aspect ratio
(normally 1); then the splines are calculated, and the resulting shrunken
curves are stretched out again by dividing the y coordinates by the aspect
ratio.
Application to type design. Now let's take a closer look at what can be
drawn with a mathematical system like this. I suppose the natural thing to
show you would be the letters A to Z; but since this is a mathematical talk,
let's consider the digits 0 to 9 instead. (See Figure 9.) Incidentally, the way I
have arranged these numerals illustrates a fundamental distinction between a
mathematician and a printer: the mathematician puts 0 next to the 1, but the
printer always puts it next to the 9.
FIGURE
0123456789
9. Digits 0 to 9 drawn by the prototype METAFONT programs.
(Further refinements to these characters will be made before the font has its final form. )
Most of these digits are drawn by using another idea taken from the history
of typography, namely to imitate the calligrapher who uses pen and ink.
Consider first the numeral '3', for example. The computer program which
drew this symbol in Figure 9 can be paraphrased as follows. "First draw a dot
whose left boundary is \ of the way from the left edge to the right edge of the
type and whose bottom boundary is f of the way from the top to the bottom
of the desired final shape. Then take a hairline pen and, starting at the left of
the dot, draw the upward arc of an ellipse; after reaching the top, the pen
begins to grow in width, and it proceeds downward in another ellipse in such
a way that the maximum width occurs on the axis of the ellipse, with the right
360 D. E. KNUTH
0ABCDEFGHIJKLMN
OPQRSTUVWXYZH
'abcdefghijklmno
pqrstuvwxyzfffflffiffl aelikoe/ELfA
0123456789:;<=>? * ""*~
w
! %&'()*+--/ rAeAsnznronij
FIGURE 10. A font of 128 characters defined by METAFONT with
standard pen settings. (The accent characters will be
appropriately raised and centered over other letters
when used by TEX.)
edge of the pen of the way from the left edge to the right edge of the type.
Then the pen width begins to decrease to its original size again as the pen
traverses another ellipse taking it down to a position 48% of the way from the
top to the bottom of the desired final s h a p e . . . . "
Notice that instead of describing the boundary of the character, as the
renaissance geometers did, my METAFONT system describes the curve
traveled by the center of the pen, and the shape of this pen is allowed to vary
as the pen moves. The main advantage of this approach is that the same
definition readily yields a family of infinitely many related fonts of type, each
font being internally consistent. The change in pen size is governed by cubic
splines in a manner analogous to the motion of the pen's center. In order to
define the 20 or so different type fonts used in various places in my books, I
need for the most part to use only three kinds of pens, namely (i) a circular
pen, used for example to draw dots and at the base of the numeral '7'; (ii) a
horizontal pen, whose shape is an ellipse, the width being variable but the
height being constantly equal to the height of a hairline pensuch a pen is
used most of the time, and in particular to draw all of the numeral '3' except
for the dots; (iii) a vertical pen, analogous to the horizontal one, used for
example to draw the strokes at the bottom of the '2' and at the top of the '5'
and the '7'. For the fonts I am using, it was not necessary to use an oblique
pen (i.e., an ellipse that is tilted on its side) except to make the tilde accent for
Spanish AZ'S; but to produce fonts of type analogous to Times Roman, an
oblique pen would of course be used. If this system were to be extended to
Chinese and Japanese characters, I believe it would be best to add another
degree of freedom to the pen's motion, allowing an elliptical pen shape to
rotate as well as to change its width.
The digit '4' shows another aspect of the METAFONT system. Although
this character is fairly simple, consisting entirely of straight lines, notice that
the thick line has to be cut off at an angle at the top. In order to do this, there
are erasers as well as pens. First the computer draws a thick line all the way
from top to bottom, like the upper case letter 'I', then it takes an eraser which
erases everything to its left and comes down the diagonal stroke, then it takes
a hairline pen and finishes the diagonal stroke. Such an eraser is used also at
the top of the T and the bottom of the '2', etc.
Sometimes a simple spline seems to be inadequate to describe the proper
growth of pen width, so in a few cases I had to resort to describing the left
and right edges of the pen as separate curves, to be filled in afterwards. This
MATHEMATICAL TYPOGRAPHY 361
(C) (d)
FIGURE 11. The letter S as defined by (a) Pacioli [42]; (b) Torniello [48];
(c) Palatino [43]; (d) French commission under Jaugeon [24].
occurs for example in the main stroke of the numeral '2', whose edges are
defined by two splines having a specified tangent at the bottom and having
vertical slope at the right of the curve.
With these techniques I found that it was possible to define a decent-look-
ing complete font, containing a total of 128 characters, in about two months,
although it will still be necessary of course to do fine tuning when more trial
pages are typeset. (See Figure 10.) The most difficult symbol by far, at least
for me, was the letter S (and the numeral 8, which uses the same procedure);
in fact I spent three days and nights without sleep, trying to make the S look
right, before I got it. At one point I even felt it would be easier to rewrite all
my books without using any S"s! After the first day of discouraging trials, I
showed what I had to my wife, and she said, "Why don't you make it
S-shaped?"
Figure 11 shows how this problem was solved by Pacioli, Torniello,
Palatino, and the French academicians; but the letter doesn't look like a
362 D. E. KNUTH
QQQQQQQ
uuijuuuij
FIGURE 12. Different S's obtained by varying the slope in the middle.
(This shows ^, f, | , 1, 5, , and 2 times the "correct" slope.)
Families of fonts. To extend the METAFONT system, one essentially
writes a computer program for the description of each character, in a special
language intended for describing pen and eraser strokes. My colleague R. W.
Gosper has observed that this is the opposite of Sesame Street: Instead of
"This program was brought to you by the letter S" we have "This letter S
was brought to you by a program." There are about 20 parameters to the
program, telling how big a hairline pen is, how wide it should be when
drawing straight or curved stem lines, and specifying the sizes and propor-
tions of various parts of the letters (the x-height, the heights of ascenders and
descenders, the set width, the length of serifs, and so forth). By changing
these parameters, we obtain infinitely many different styles of type, yet all of
them are related and they seem to blend harmoniously with each other.
For example, Figure 13 shows some of the possibilities. In Figure 13a we
have a conventional "modern" font in the tradition of Bodoni and Bell and
"Scotch Roman". Then Figure 13b shows a corresponding boldface, in which
the hairlines are slightly larger and the stem lines are substantially wider. By
making the hairlines and stem lines both the same size, and setting the serif
length to zero, we obtain a sans-serif font as shown in Figure 13c. All of these
examples are produced with the same programs defining the letter shapes;
only the parameters are being varied. Actually the particular font shown in
Figure 13c will have a different style of g, because the descenders are
especially short in this font, but I have shown this "g" in order to illustrate
the parametric variations. Figure 13d shows a boldface sans-serif style in
which the pen has an oval shape wider than it is tall; I find this style
especially pleasing, particularly because it came out by accidentI designed
the programs only so that two or three different fonts would look right, all the
others are free bonuses, and I had no idea that this one would be so nice.
With a suitable setting of the parameters, we can even imitate a typewriter
with its fixed width letters, as shown in Figure 13e. There is also a provision
MATHEMATICAL TYPOGRAPHY 363
Typography
to slant the letters as in Figure 13f; here the pen position is varied, but the
actual shape of the pen is not being slanted, so circles remain circles.
Another setting of the parameters leads to caps and small caps as shown in
Figure 13g; small caps are drawn with the pens and heights ordinarily used
for lower case letters, but controlled by the programs for upper case letters.
Figure 13h shows something printers have never seen before: this is what
happens when you draw lower case letters in the small caps style, and we
might call it "small lower case". It actually turns out to be one of the most
pleasing fonts of all, except that the dots are too large.
Finally, Figure 13i illustrates the variations you can get by giving weirder
settings to the parameters.
When I was an assistant professor at Caltech, the math department
secretaries used to send occasional "crank" visitors to my office, and I recall
one time when a man came to ask if anybody had calculated the value of m
364 D. E. KNUTH
"out to the end" yet. I tried to explain to him that m had been proved
irrational, but this didn't seem to sink in, so finally I showed him a table of TT
to 100,000 decimals and told him that the expansion hadn't ended yet. I wish
I could have had my typographical system ready at that time, so that I could
have shown him Figure 14!
3
FIGURE
2653 5 8 9 7 . . . w
14. Variation in height, width, and pen size.
Figure 14 illustrates another principle of type design, namely that different
sizes of type in the same style are not simply obtained from each other by
optical transformations. The heights and widths and pen stroke sizes change
at different rates, and a good typographer will design each size of type
individually. I'm not claiming that Figure 14 shows the best way for the
proportions to vary; it will take further experimentation before I have a good
idea of what is desirable. The point I wish to make is that the alteration of
type sizes for subscripts and so on is not as simple as it might seem at first,
but a system like METAFONT will be able to vary the parameters quite
readily, and visual experiments on different parameter settings can be carried
out quickly. It used to take months for a type designer to make his drawings
and have them converted to metal molds before he could see any proofs. One
of the results was that there simply wasn't time to give proper attention to all
the mathematical symbols and Greek letters, etc., as well as to the more
common symbols, so a printer of mathematics had to make do with a
hodge-podge of available characters in different sizes. (For example, he was
often obliged to use different styles of letters in subscript positions, as we
have seen.) Under the approach I am recommending, we automatically get
consistency of all the symbols whenever the parameters change.
1500; this shows the name of St. Thomas in a style imitating contemporary
calligraphy, and I'm sure that examples which antedate the printing press can
be found elsewhere.
mathematics
mathematics
mathematics
mathematics FIGURE 16.
Adjusting the letters to
mathematics coarser rasters.
Figure 16 shows how METAFONT produces the same letters from the
same parameters but with different degrees of resolution in the raster. This
digitization process itself is considerably more difficult than it may seem at
first, and some nontrivial mathematical concepts were needed before I could
produce satisfactory results. In the first place, it is not sufficient merely to
draw or to imagine drawing the character with infinite precision and then to
"round" it by blacking in all the squares on graph paper that are sufficiently
dark in the true image. One of the reasons this fails is that the three stem lines
of the m, for instance, might be located in different relative positions with
respect to the grid, so that the first stroke ,might round to three units wide
(say) and the second might round to four. This would be quite unsatisfactory,
as the eye quickly picks up such a variation in thickness, but it is avoided by
METAFONT since the pen itself is first digitized and then the same digitized
pen is used for all three strokes. Another problem is that those three strokes
should be equally spaced; it would look bad if there were seven units between
the first two and eight units between the last two, so the program for 'm9
needs to round its points in such a way that this doesn't happen.
The process of digitizing the pen is not trivial either. Suppose, for example,
we want a circular pen that is 2 raster units wide; the appropriate pen is
clearly a 2 X 2 square, which is the closest to a circle that we can come at this
low degree of resolution. Now notice that we can't center a 2 X 2 square on
any particular square, since none of the four squares is at its center; the same
problem arises whenever we have to deal with a pen having even dimensions.
One way to resolve this would be to insist on working only with odd numbers,
but this would be far too limiting; so METAFONT uses a special rounding
rule for the position of the pen's center. In general, suppose the pen is an
ellipse of integer width w and integer height h; then if the pen is to be
positioned at the real coordinates (x, y), its actual position on the discrete
grid is taken to be
(Lx - (w)J, Ly - 8(h)J)
where LxJ denotes the greatest integer less than or equal to JC, and
fi(even) = | , 5(odd) = 0. The pen itself, if positioned at the origin, would
366 D. E. KNUTH
!
Ill**
llttt FIGURE 17.
HUM*
Discrete "elliptical" pens
of small integer width and height.
:>:D
(a)
Still another (b)
problem appears (c)
FIGURE 18.
Difficulties of rounding an arc
properly. (Three circles of radius
10 drawn with a 1 X 3 pen.)
(a) yn^AM^r?uz^(k
(b)
(c) y>w/Aj^a<M<jC4...'
(d)
FIGURE 20.
Examples of the cubic splines
(e) applied to sloppy handwriting.
to a circle (as I said it would). In this illustration the pen is thicker and has a
slightly oblique stress. Although my handwriting is inherently unbeautiful,
there are still some kinks in Figure 20(e) that could probably be ironed out if
a different approach were taken.
The most interesting alternative from a mathematical standpoint seems to
be to find a curve of given length that minimizes the integral of the square of
the curvature with respect to arc length. This integral is proportional to the
strain energy in a mechanical spline (in other words, a thin slat or beam) of
the given length, going through the given points, so it seems to be an
appropriate quantity to minimize. E. H. Lee and G. E. Forsythe [31] have
reviewed early work on this variational problem, and shown that it is
equivalent to having the spline at equilibrium with forces applied only at the
given points of support. The Norwegian mathematician Even Mehlum [36]
has shown that if we specify a fixed arc length between consecutive points,
the optimum curve will have linearly changing curvature of the form ax + by
+ c at point (x,y\ and he has suggested choosing the constants by taking
b/a = (y2 - y\)/(x2 xx) between (xl9yx) and (x2,y2% and requiring that
slope and curvature be continuous across endpoints. Such an approach seems
to require considerably more computation than the cubic splines recom-
mended here, but it may lead to better curves, e.g. satisfying the extensional-
ity property.
Another interesting approach to curve-drawing, which may be especially
useful for simulating handwriting, is a "filtering" method suggested to me
recently by Michael S. Paterson of the University of Warwick (unpublished).
To get a smooth curve passing through points zk, assuming that these points
are about equally spaced on the desired curve, one simply writes
I have not had time yet to experiment with Paterson's method or to attempt
to harness it for the drawing of letters. It is easy to see that the derivative
*'(**) = / 0 ) 0 * + i - **-i) - /(2)(** +2 - **-2> + ' l i e s approximately in
the direction of zk+l zk_v
mathematics
mathematics
mathematics
mathematics
mathematics
mathematics
mathematics
mathematics
math emat \cs
mat\ie;nat\cp
mathematici F*21.
niatJiein&ti es SSSSt.T.
Randomization. In conclusion, I'd like to report on a little experiment that I
did with random numbers. One might complain that the letters I have
designed are too perfect, too much like a computer, so they lack "character."
In order to counteract this, we can build a certain amount of randomness into
the choices of where to put the pen when drawing each letter, and Figure 21
shows what happens. The coordinates of key pen positions were chosen
independently with a normal distribution and with increasing standard
deviation, so that the third example has twice as much standard deviation as
the second, the fourth has three times as much, and so on. Note that the two
m's on each line (except the first) are different,FIGURE
and so
22. are the a's and the t%
since each letter is randomly drawn. A bit of randomness introduced
into various styles of type.
mathematics
After the deviation gets sufficiently large the results become somewhat
mathematics
ludicrous; and I don't want people to say that I ended this lecture by making
a travesty of mathematics. So let us conclude by looking at Figure 22, which
mathematics
shows what is obtained in various fonts when the degree of randomness is
somewhat controlled. I think it can be said that the letters in this final
mthamutlos
example have a warmth and charm which makes it hard to believe that they
370 D. E. KNUTH
28. David Kindersley, Optical letter spacing for new printing systems, London, Wynkyn de
Worde Society, 1976.
29. Donald E. Knuth, Tau Epsilon Chi, a system for technical text, Stanford Computer Science
report CS675, September, 1978. To be published by the American Mathematical Society.
30. Dorothy K. Korbuly, A new approach to coding displayed mathematics for photocomposition,
IEEE Trans, on Prof. Commun. PC-18 (1975), 283-287.
31. E. H. Lee and G. E. Forsythe, Variational study of nonlinear splines, SIAM Rev. 15 (1973),
120-133.
32. M. E. Lesk and B. W. Kernighan, Computer typesetting of technical journals on UNIX,
Computing Science Tech. Report 44, Murray Hill, N. J., Bell Laboratories, June, 1976.
33. Giovanni Mardersteig, The alphabet of Francesco Torniello (1517) da Novara, Verona,
Officini Bodoni, 1971.
34. M. V. Mathews and Joan E. Miller, Computer editing, typesetting, and image generation,
Proc. AFIPS Fall Joint Computer Conf. 27 (1965), 389-398.
35. M. V. Mathews, Carol Lochbaum and Judith A. Moss, Three fonts of computer drawn
letters, Communications of the ACM 10 (1967), 627-630.
36. Even Mehlum, Nonlinear splines, Computer Aided Geometric Design, Robert E. Barnhill
and Richard F. Riesenfeld, eds., New York, Academic Press, 1974, pp. 173-207.
37. A. W. Kenneth Metzner, Multiple use and other benefits of computerized publishing, IEEE
Trans, on Prof. Commun. PC-18 (1975), 274-278.
38. Joseph Moxon, Regulae trium ordinum literarum typographicarum, or the rules of the three
orders of print letters: viz, the {roman, italick, english) capitals and small', Shewing how they are
compounded of Geometrick Figures, and mostly made by Rule and Compass, London, Joseph
Moxon, 1676.
39. Phoebe J. Murdock, New alphabets and symbols for typesetting mathematics, Scholarly
Publishing 8 (1976), 44-53. Reprinted in Notices Amer. Math. Soc. 24 (1977), 63-67.
40. Nicholas Negroponte, Raster scan approaches to computer graphics, Computers and Graph-
ics 2 (1977), 179-193.
41. Wolfgang A. Ocker, A program to hyphenate English words, IEEE Trans, on Prof. Commun.
PC-18 (1975), 78-84.
42. Luca Pacioli, Divina Proportione, Opera a tutti glingegni perspicaci e curiosi necessaria Ove
ciascun studioso di Philosophia, Propectiva, Pictura, Sculptura: Architecturo: Musice: altre
Mathematice: suavissima: sottile: e admirable et doctrina consequira: e delectarassi: con varie
questione de secretissima scientia (Venice, 1509).
43. Giovanbattista Palatino Cittadino Romano, Libro primo del Ie lettere maiuscole antiche
romane (unpublished), Berlin Kunstbibliothek, MS. OS5280. Some of the individual pages are
dated 1543, 1546, 1549, 1574, or 1575. See James Wardrop, Civis romanus sum: Giovanbattista
Palatino and his circle, Signature, n.s. 14 (1952), 3-39.
44. Paul A. Parisi, Composition innovations of the American Society of Civil Engineers, IEEE
Trans, on Prof. Commun. PC-18 (1975), 244-273.
45. R. G. D. Richardson, The twenty-ninth annual meeting of the Society, Bull. Amer. Math.
Soc. 29 (1923), 97-116. (See also vol. 28 (1922) pp. 234-235, 378 for comments on the special
Transactions volume, and pp. 2-3 of vol. 28 for discussion of deficits due to increased cost of
printing.)
46. Glenn E. Roudabush, Charles R. T. Bacon, R. Bruce Briggs, James A. Fierst, Dale W.
Isner and Hiroshi A. Noguni, The left hand of scholarship: Computer experiments with recorded
text as a communication media, Proc. AFIPS Fall Joint Computer Conf. 27 (1965), 399-411.
47. Ellen E. Swanson, Mathematics into type, Amer. Math. Soc., Providence, R. I., 1971.
48. Francesco Torniello, Opera del modo de fare le littere mauiscuole antique, Milan, Italy, 1517.
49. Geofroy Tory, Champ fleury, Paris, 1529. Also translated into English and annotated by
George B. Ives, New York, Grolier Club, 1927.
50. Karel Wick, Rules for typesetting mathematics, translated by V. Boublik and M. Hejlov,
The Hague, Mouton, 1965.
51. Hermann Zapf, About alphabets: some marginal notes on type design, Cambridge, Mass.,
M.I.T. Press, 1970.