This document, "TEX and METAFONT: New Directions in Typesetting" by Donald E. Knuth, published in 1979, introduces two groundbreaking computer systems developed to revolutionize typesetting, particularly for technical and mathematical texts.
The book is divided into three main parts:
Mathematical Typography (The Vision): This section, based on Knuth's 1978 Gibbs Lecture, outlines the motivation and core ideas behind the project. Knuth observed a decline in the quality of mathematical typesetting due to the high cost of traditional methods. He proposes a solution rooted in mathematics and computer programming.
- TEX: A system for precise, unambiguous specification of manuscript content, allowing machines to produce high-quality print. It aims to streamline publishing, enabling authors to directly influence the printed appearance of their work.
- METAFONT: A system for mathematically defining and designing character shapes (fonts). It allows for the creation of an infinite variety of related type styles from a single definition by adjusting a few parameters, ensuring consistency across different symbols and sizes. This approach aims to capture the "substance" of type design rather than merely copying existing forms, addressing a historical challenge where early mathematical approaches to type design (15th-17th centuries) often failed aesthetically.
- Core Concepts: The document introduces fundamental ideas like "boxes and glue" for page layout (TEX) and describing character shapes via "pen motions and shapes" rather than outlines (METAFONT). It discusses how mathematics, such as spline curves and "badness" metrics for line-breaking, are applied to achieve aesthetically pleasing and efficient results.
TEX, a system for technical text (The Layout Engine): This part serves as a detailed manual for using TEX.
- Purpose: To produce professional-quality printed materials, especially those with complex mathematical formulas.
- Input Language: TEX uses specific control sequences (commands starting with
\) and special characters to interpret plain text for typesetting. It distinguishes various types of dashes, handles ligatures and kerning automatically, and allows for font selection and grouping ({...}).
- Page Construction: TEX conceptualizes a document as a hierarchical structure of "boxes" (characters, lines, paragraphs, pages) separated by "glue" (variable spacing). This "glue" has attributes of ideal space, stretchability, and shrinkability.
- Line and Page Breaking: A key innovation is TEX's advanced line-breaking algorithm, which considers an entire paragraph at once (using a "badness" metric and dynamic programming) to find the optimal arrangement of words, minimizing awkward spacing and hyphenation. Similar principles apply to page breaking.
- Mathematics Typesetting: TEX provides extensive capabilities for formatting complex mathematical expressions, including fractions, superscripts/subscripts, Greek letters, large operators (summation, integration), and various delimiters, all with intelligent spacing rules.
- Macros: Users can define custom control sequences (
\def) to automate repetitive or complex typesetting tasks.
- Error Handling: The manual includes a comprehensive guide to TEX's error messages and recovery procedures, designed to help users debug their input files.
METAFONT, a system for alphabet design (The Font Generator): This section details the METAFONT system for creating digital typefaces.
- Design Philosophy: Instead of drawing characters pixel by pixel or scanning existing fonts, METAFONT allows designers to write "programs" that mathematically describe how a character is formed by a "pen" moving through space.
- Geometric Primitives: Characters are defined using Cartesian coordinates, equations to relate points, and
draw commands to connect them with lines and smooth curves (cubic splines). Directions and "velocities" can be specified to control the curve's shape.
- Pens and Erasers: METAFONT employs various "pen" shapes (circular, horizontal, vertical, elliptical) and "erasers" to construct letterforms. It allows for the pen's size and shape to vary dynamically along a stroke (
ddraw for filling areas).
- Parametric Design: A crucial aspect is the use of variables (e.g.,
pw for pen width, hpenht for horizontal pen height) that act as design parameters. By changing these, an entire family of fonts can be generated from a single set of programs (e.g., Computer Modern fonts), ensuring aesthetic consistency across different weights, slants, and optical sizes.
- Discretization: METAFONT defines characters in continuous space but then renders them onto a discrete pixel grid, employing sophisticated rounding rules to maintain visual quality and symmetry even at low resolutions.
- Font Information for TEX: METAFONT generates not only the character bitmaps but also critical font metric information (width, height, depth, italic correction, ligature, and kerning data) that TEX needs for proper text layout and spacing.
In essence, the document presents Knuth's vision and detailed technical implementation of an integrated, mathematically-driven approach to high-quality digital typesetting, covering both document layout (TEX) and typeface design (METAFONT). It highlights the innovative "new directions" that were crucial to the development of modern digital typography.