World Library  
Flag as Inappropriate
Email this Article


Article Id: WHEBN0000044263
Reproduction Date:

Title: Metafont  
Author: World Heritage Encyclopedia
Language: English
Subject: TeX, Donald Knuth, Sumihiri, Robinson–Schensted–Knuth correspondence, Concrete Mathematics
Publisher: World Heritage Encyclopedia


Developer(s) Donald Knuth
Stable release 2.7182818 / January 2014 (2014-01)
Operating system Cross-platform
Type Computer language
License Permissive

Metafont is a description language used to define vector fonts. It is also the name of the interpreter that executes Metafont code, generating the bitmap fonts that can be embedded into e.g. PostScript. Metafont was devised by Donald Knuth as counterpart to his TeX typesetting system.

One of the characteristics of Metafont is that all of the shapes of the glyphs are defined with geometrical equations. In particular, one can define a given point to be the intersection of a line segment and a Bézier cubic.

Mode of operation

Unlike more common outline font formats (such as TrueType or PostScript Type 1), a Metafont font is primarily made up of strokes with finite-width "pens", along with filled regions. Thus, rather than describing the outline of the glyph directly, a Metafont file describes the pen paths. Some simpler Metafont fonts, such as the calligraphic mathematics fonts in the Computer Modern family, use a single pen stroke with a relatively large pen to define each visual "stroke" of the glyphs. More complex fonts such as the Roman text fonts in the Computer Modern family use a small pen to trace around the outline of the visual "strokes", which are then filled; the result is much like an outline font, but with slightly softened corners defined by the pen shape.

Since the font shapes are defined by equations rather than directly coded numbers, it is possible to treat parameters such as aspect ratio, font slant, stroke width, serif size, and so forth as input parameters in each glyph definition (which then define not a single font, but a meta-font). Thus, by changing the value of one of these parameters at one location in the Metafont file, one can produce a consistent change throughout the entire font. Computer Modern Roman illustrates many uses of this feature; a typical TeX installation includes a number of versions of the font in sizes from 5pt to 17pt, with the stroke widths the same in all sizes (rather than increasing as the font is scaled up) and aspect ratios widening in the smaller sizes for increased legibility. In addition, the Computer Modern typewriter and sans-serif fonts are defined using essentially the same Metafont file as the Roman font, but with different global parameters.

Curves in Metafont are defined as cubic splines rather than quadratic, for greater versatility with similarly simple arithmetic.

Metafont can render any kind of graphical output, not just glyphs. However, MetaPost with its PostScript output is preferred for mathematical illustrations. Metafont is most commonly invoked without a direct request from the user. DVI files can only contain references to typefaces, rather than the sets of raster or vector glyphs that other formats like PostScript allow. Consequently the glyphs in the typefaces need to be accessed whenever a request is made to view, print or convert a DVI file. Most TeX distributions are configured so that any fonts not currently available at the required resolution are generated by calls to Metafont. The fonts are then stored for later reuse.

Metafont can also be run interactively, and has commands for displaying on the screen the images it produces. Knuth has said that he uses Metafont as a kind of desk calculator for solving complicated equations, though he now uses MetaPost for mathematical illustrations.

Producing PostScript Type 1 fonts

There are several tools for converting Metafont programs to PostScript Type 1 fonts. Most make use of MetaPost's ability to convert a subset of Metafont's language into EPS outlines, which can subsequently be converted to PostScript Type 1 fonts. Generating vector outlines of pen strokes directly in Metafont is nontrivial, as the bitmapped strokes are generated by rasterization rather than actual outlines.

  • The Polish JNS team developed METATYPE1[1] (based on MetaPost) for creating PostScript Type 1 fonts. Its big disadvantage is that no pens may be used which highly reduces the power of Metafont language. Initially, tool has been used by the Polish GUST typeface foundry to produce a modernized and extended variant of Computer Modern, called Latin Modern.
  • MnSymbol mathematical font developed by Achim Blumensath; MnSymbol was designed as a companion to Minion Pro.
  • MetaFog[3] is a proprietary converter that can analytically convert pen strokes, but it requires manual post processing to eliminate degenerate cases, and it is not publicly available. It can process only Metapost output.[4]

The common approach to generate Type 1 fonts with pen strokes remains to generate a high-resolution bitmap and then using an autotracer, implemented by packages such as mftrace.


While well-known font designers, such as Hermann Zapf, have collaborated with Knuth to create new fonts using Metafont, the system has not been widely adopted by professional type designers. Knuth attributes this to the fact that "asking an artist to become enough of a mathematician to understand how to write a font with 60 parameters is too much."[5]


Donald Knuth started work on font creation software in 1977, and produced the first version of Metafont in 1979. Due to shortcomings in the original Metafont language, Knuth developed an entirely new Metafont system in 1984, and it is this revised system that is used today; Metafont has a versioning system similar to that of TeX, where the number asymptotically approaches e with each revision.


The following example creates a closed beanlike shape for the character "B" of a font:


% Define a beanlike shape for the character B
  % Setup coordinates as an equation system

  % Define pen
  pickup pencircle xscaled 0.2w yscaled 0.04w rotated 90;

  % Draw the character curve
  draw z1..z3..z6{z2-z6}..z5..{z4-z2}z4..cycle;


This yields the following glyph:


  1. ^ CTAN web interface: Directory listing for /fonts/utilities/metatype1
  2. ^ CTAN web interface: Directory listing for /support/mf2pt1
  3. ^ , 233–43 (1995)16(3) TUGboatR. J. Kinch, "MetaFog: converting Metafont shapes to contours",
  4. ^ K. Píška, 2004
  5. ^ CSTUG, Charles University, Prague, March 1996, Questions and Answers with Prof. Donald E. Knuth, reproduced in TUGboat 17 (4) (1996), 355–67. Citation is from page 361. Available online at


  • Donald Knuth: Metafont: The Program, Addison-Wesley 1986. ISBN 0-201-13438-1
  • Donald Knuth: The Metafontbook, Addison-Wesley 1986. ISBN 0-201-13444-6 . The source code of the book in TeX (and a needed macro) is available online on CTAN.
  • Donald Knuth: The Metafont source code is written in the WEB programming language, and includes very extensive documentation about the algorithms used in Metafont.
  • Yannis Haralambous, "Fonts and Encodings", O'Reilly 2007, ISBN 0-596-10242-9, Appendix F: "METAFONT and its derivatives"
  • K. Píška, "Creating Type 1 fonts from Metafont sources: comparison of tools, techniques and results", in TeX, XML, and Digital Typography (Springer-Verlag, Berlin, 2004), Lect. Notes Comput. Sci., Vol. 3130, pp. 240–56. preprint
  • Hofstadter, Douglas R., "Metafont, Metamathematics, and Metaphysics: Comments on Donald Knuth's Article 'The Concept of a Meta-Font'" Visible Language, Vol. XVI no. 4, pp. 309-338 (republished in Hofstadter's book Metamagical Themas, NY: Basic Books, 1985)

External links

  • The Metafont Tutorial: an online guide to using Metafont.
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from World Library are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.