METAFONT / MetaPost
Donald Knuth's declarative, equation-driven language for parametric type design — and John Hobby's MetaPost descendant that retargets the same geometric model to produce PostScript vector graphics.
Created by Donald E. Knuth (METAFONT); John D. Hobby (MetaPost)
METAFONT and MetaPost are a closely related pair of declarative graphics languages built around a single, unusual idea: describe a shape not by listing its coordinates, but by stating the relationships the shape must satisfy and letting the system solve for the rest. METAFONT, created by Donald Knuth as the companion to his TeX typesetting system, was designed to define typefaces — its programs generate the bitmap fonts that classic TeX uses to render text and mathematics. MetaPost, written roughly a decade later by John D. Hobby, takes the same elegant geometric language and retargets it to emit PostScript vector graphics instead of fonts, making it a favorite tool for producing precise technical diagrams. Together they represent one of computing’s most thoughtful experiments in treating drawing as a problem of equations rather than pixels.
History & Origins
Knuth and the Problem of Fonts
In the late 1970s, Donald Knuth grew dissatisfied with the way his books were being typeset as printing technology shifted from hot metal to digital phototypesetting. His response became one of the great yaks of computer science: he set out to build his own typesetting system, TeX, and — realizing he would also need typefaces to feed it — a font-design system to go with it. He began the font work in 1977 and produced the first version of METAFONT in 1979.
The original language had real shortcomings, and after several years of experience Knuth threw it out and wrote an entirely new METAFONT in 1984. It is this revised system, documented in The METAFONTbook (1986), that survives essentially unchanged today. In keeping with Knuth’s famous insistence on stability, METAFONT’s version numbers now asymptotically approach the mathematical constant e (the current release is 2.71828182, from January 2021), signaling that the system is considered finished and receives only bug fixes.
Hobby and the Leap to PostScript
The second half of the story belongs to John D. Hobby, who had collaborated with Knuth on METAFONT’s path-drawing algorithms (the elegant method METAFONT uses to draw smooth curves through a set of points is sometimes called “Hobby’s algorithm”). Around 1989, while at AT&T Bell Labs, Hobby realized that METAFONT’s language could be redirected to output PostScript rather than the run-length-encoded bitmaps METAFONT produces. He built this adaptation over the following years; MetaPost was distributed within AT&T and then released publicly, with the first widely available version (0.63) appearing around January 1995 — the 1.000 milestone would not come until 2007.
Where METAFONT outputs device-specific raster fonts, MetaPost outputs resolution-independent vector graphics (EPS, and in modern versions SVG and PNG), with support for color, embedded TeX-typeset text labels, and arbitrary drawings. AT&T eventually handed the project to the TeX community in the mid-2000s, and maintainers including Taco Hoekwater and Luigi Scarso have carried it forward — releasing version 1.000 in July 2007 after a major restructuring and, most notably, the 1.8 release (June 2013), which replaced METAFONT’s inherited fixed-point arithmetic with 64-bit floating point.
Design Philosophy
The defining idea of both languages is declarative, equation-based geometry. Instead of telling the computer “put a point at (35, 100),” a METAFONT program can assert facts like “this point is one-third of the way between those two” or “the left and right stems are equally wide,” and the interpreter solves the resulting system of linear equations to find the actual coordinates.
This rests on a striking treatment of variables. At any moment a numeric variable may be:
- known — its value has been determined,
- unknown but independent — not yet pinned down,
- unknown but dependent — expressible as a linear combination of other unknowns.
As equations accumulate, METAFONT continuously simplifies and solves them, promoting variables to known the instant enough constraints exist. The programmer never writes “solve this”; they simply state relationships and the linear-algebra engine does the rest.
The second great idea is parametrization — the “meta” in METAFONT. A typeface is not written as one fixed design but as a program with parameters: pen width, x-height, slant, serif length, and dozens more. Adjust the parameters and you get a different but consistent member of the same family. Knuth’s vision was a single source that could yield bold, light, condensed, and slanted variants as smoothly as turning dials — a font that is really a “meta-font.”
Key Features
| Feature | Description |
|---|---|
| Equation solver | Linear equations over numeric and pair (x, y) values are solved automatically; geometry is declared, not computed by hand |
| Pen-stroke model | Glyphs and shapes are drawn by dragging a pen (of a given shape and width) along paths, rather than by filling outlines — closer to how a human draws with a nib |
| Bézier paths with Hobby’s algorithm | Smooth curves are inferred through control points using Hobby’s “mock curvature” method, so designers specify where a curve goes, not its raw control points |
| First-class types | numeric, pair, path, pen, picture, transform, color, string, and boolean are built-in data types |
| Parametrized designs | A single program plus a parameter file generates an entire font family or a family of figures |
| METAFONT output | Raster fonts (GF/PK bitmaps at a chosen resolution) plus TeX font-metric (.tfm) files |
| MetaPost output | Vector EPS/SVG/PNG with color, transparency, and embedded TeX-typeset labels |
A Taste of the Language
The two languages share most of their syntax. A small MetaPost figure that draws a curved path through three points and an arrow looks like this:
beginfig(1);
% declare three points and let MetaPost solve the geometry
pair a, b, c;
a = (0, 0);
b = (60, 40);
c = (120, 0);
% draw a smooth curve through them, then an arrow
draw a .. b .. c withcolor (0.2, 0.3, 0.8);
drawarrow a -- c dashed evenly;
% a TeX-typeset label
label.top(btex $\sqrt{x}$ etex, b);
endfig;
end.
The .. operator asks MetaPost to find a smooth curve through the points (using Hobby’s algorithm), while -- draws straight segments. Nowhere does the programmer compute Bézier control points — they state the path and let the system infer the rest.
METAFONT vs. MetaPost
Although they share a language, the two systems serve different ends:
- METAFONT is fundamentally a font compiler. Its natural output is a device-resolution bitmap font plus metric data, optimized for classic TeX’s bitmap-based rendering pipeline. Its pen model and parameter system are tuned for letterform design.
- MetaPost is a general drawing tool. It produces scalable vector output suitable for any resolution, adds color and text integration, and is most often used for diagrams and illustrations embedded in documents — though it can still be used to design fonts.
A useful way to remember the relationship: MetaPost is METAFONT with the bitmap font machinery swapped out for a PostScript graphics backend.
Evolution & Current Relevance
METAFONT itself is frozen by design — Knuth long ago declared the language complete, and it now changes only to fix bugs, with its version number creeping ever closer to e. In practice, the rise of scalable outline fonts (PostScript Type 1, TrueType, and OpenType) meant that the wider type-design world moved toward outline editors rather than METAFONT’s stroke-and-equation approach. Knuth himself acknowledged the adoption barrier, noting that asking an artist to also become enough of a mathematician to manage a font with dozens of interacting parameters was a tall order. A small ecosystem of conversion tools — METATYPE1, Scott Pakin’s mf2pt1, and autotracing pipelines like mftrace and TeXtrace — emerged to bridge METAFONT sources into modern Type 1 outline formats.
MetaPost, by contrast, remains actively used and maintained. It ships in major TeX distributions such as TeX Live and MiKTeX, and it has found new life through tight integration with modern TeX engines: ConTeXt drives it through the MetaFun package to draw page graphics, and LuaTeX embeds it as a library (mplib) so MetaPost code can run inline during typesetting. Its lineage also lives on in Asymptote, a modern vector-graphics language explicitly conceived as a successor to MetaPost — adding a C++-like syntax, native floating-point numerics, and 3D capabilities while preserving the descriptive, constraint-oriented spirit.
Why It Matters
METAFONT and MetaPost matter less for their market share than for the idea they proved: that drawing can be declarative. By letting designers state geometric relationships and having a solver work out the coordinates, Knuth showed that the gap between a designer’s intent (“these stems are equal,” “this point sits between those”) and the machine’s representation could be closed with linear algebra rather than manual arithmetic. The parametric “meta-font” concept — one program yielding a whole family of consistent designs — anticipated ideas that have only recently gone mainstream with variable fonts.
For the millions of pages of mathematics and science typeset in Computer Modern, every character traces back to a METAFONT program. And for generations of researchers who needed a clean, precise diagram inside a TeX document, MetaPost has remained the tool that draws exactly what the equations say — no more, no less. As a piece of computing history, the pair stands as one of the most intellectually elegant answers ever given to the question of how to describe a shape.
Timeline
Notable Uses & Legacy
Computer Modern
TeX's default typeface family — Roman, sans-serif, and typewriter variants and the math symbols used throughout scientific publishing — is defined entirely in METAFONT, with the different styles generated from largely shared source code and different parameter values
AMS & academic publishing
The American Mathematical Society and countless journals rely on Computer Modern and related METAFONT-built fonts, so virtually every classically typeset mathematics paper carries glyphs that originated as METAFONT programs
ConTeXt & MetaFun
The ConTeXt typesetting system embeds MetaPost via its MetaFun macro package, using it to draw backgrounds, page decorations, and complex graphics directly inside documents
LuaTeX (mplib)
LuaTeX embeds a MetaPost library (mplib) so that MetaPost code can be evaluated inline during a document run, without shelling out to a separate process
Technical diagrams & figures
Researchers and textbook authors use MetaPost to produce precise, resolution-independent figures — geometric constructions, graphs, and labeled diagrams — that integrate seamlessly with TeX typography