METAFONT
Encyclopedia
Metafont is a programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 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
PostScript
PostScript is a dynamically typed concatenative programming language created by John Warnock and Charles Geschke in 1982. It is best known for its use as a page description language in the electronic and desktop publishing areas. Adobe PostScript 3 is also the worldwide printing and imaging...

. Metafont was devised by Donald Knuth
Donald Knuth
Donald Ervin Knuth is a computer scientist and Professor Emeritus at Stanford University.He is the author of the seminal multi-volume work The Art of Computer Programming. Knuth has been called the "father" of the analysis of algorithms...

 as counterpart to his TeX
TeX
TeX is a typesetting system designed and mostly written by Donald Knuth and released in 1978. Within the typesetting system, its name is formatted as ....

 typesetting system.

One of the characteristics of Metafont is that all of the shapes of the glyph
Glyph
A glyph is an element of writing: an individual mark on a written medium that contributes to the meaning of what is written. A glyph is made up of one or more graphemes....

s are defined with geometrical equations, e.g., one can define a given point to be the intersection of a line segment and a Bézier cubic
Bézier curve
A Bézier curve is a parametric curve frequently used in computer graphics and related fields. Generalizations of Bézier curves to higher dimensions are called Bézier surfaces, of which the Bézier triangle is a special case....

.

Mode of operation

Unlike more common outline font formats (such as TrueType
TrueType
TrueType is an outline font standard originally developed by Apple Computer in the late 1980s as a competitor to Adobe's Type 1 fonts used in PostScript...

 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
Computer Modern
Computer Modern is the family of typefaces used by default by the typesetting program TeX. It was created by Donald Knuth with his METAFONT program, and was most recently updated in 1992. However, the family font was superseded by CM-Super , the latest release dating 2008...

 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
Roman type
In typography, roman is one of the three main kinds of historical type, alongside blackletter and italic. Roman type was modelled from a European scribal manuscript style of the 1400s, based on the pairing of inscriptional capitals used in ancient Rome with Carolingian minuscules developed in the...

 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
Serif
In typography, serifs are semi-structural details on the ends of some of the strokes that make up letters and symbols. A typeface with serifs is called a serif typeface . A typeface without serifs is called sans serif or sans-serif, from the French sans, meaning “without”...

 size, and so forth as input parameters in each glyph definition (which then define not a single font, but a meta
Meta
Meta- , is a prefix used in English to indicate a concept which is an abstraction from another concept, used to complete or add to the latter....

-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
Sans-serif
In typography, a sans-serif, sans serif or san serif typeface is one that does not have the small projecting features called "serifs" at the end of strokes. The term comes from the French word sans, meaning "without"....

 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
MetaPost
MetaPost refers to both a programming language and the interpreter of the MetaPost programming language. Both are derived from Donald Knuth's Metafont language and interpreter. MetaPost excels at producing diagrams in the PostScript programming language from a geometric/algebraic description...

 with its PostScript output is preferred for advanced 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
Dots per inch
Dots per inch is a measure of spatial printing or video dot density, in particular the number of individual dots that can be placed in a line within the span of 1 inch . The DPI value tends to correlate with image resolution, but is related only indirectly.- DPI measurement in monitor...

 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
MetaPost
MetaPost refers to both a programming language and the interpreter of the MetaPost programming language. Both are derived from Donald Knuth's Metafont language and interpreter. MetaPost excels at producing diagrams in the PostScript programming language from a geometric/algebraic description...

's ability to convert a subset of Metafont's language into EPS
Encapsulated PostScript
Encapsulated PostScript, or EPS, is a DSC-conforming PostScript document with additional restrictions which is intended to be usable as a graphics file format...

 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
    METATYPE1
    METATYPE1 is a tool for creating Type 1 fonts using METAPOST, developed by the Polish JNS team ....

     (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
    Gust
    is a Japanese developer and publisher of game software titles, known for their Atelier and Ar tonelico series.-Company:Gust Co. Ltd. was founded in 1993 in Nagano, Japan, as the first game software house in Nagano Prefecture. The company began by creating dôjinshi games for personal computers. Its...

     typeface foundry to produce a modernized and extended variant of Computer Modern
    Computer Modern
    Computer Modern is the family of typefaces used by default by the typesetting program TeX. It was created by Donald Knuth with his METAFONT program, and was most recently updated in 1992. However, the family font was superseded by CM-Super , the latest release dating 2008...

    , called Latin Modern.
  • mf2pt1, which is also based on Metapost, was developed by Scott Pakin with some contributions from Werner Lemberg. It also has several limitations detailed in its manual, the most significant one being the restriction that each glyph must be drawn entirely from closed paths. In order to overcome the limitations of mf2pt1, the EPS output by Metapost can be post-processed with FontForge
    FontForge
    FontForge is a typeface editor program developed by George Williams. FontForge is free software and is distributed under the BSD license. FontForge is available for several operating systems and is localized in several languages.- Features :Fontforge supports many font formats, including...

    , which is capable of interpreting complex PostScript paths generated by Metapost from Metafont's elliptic pens, and also capable of removing contour overlaps. Since FontForge supports scripting, this post-processing step can also be automated. This approach was used to produce Type 1 outlines for the MnSymbol mathematical font developed by Achim Blumensath; MnSymbol was designed as a companion to Minion Pro
    Minion (typeface)
    Minion is the name of a typeface designed by Robert Slimbach in 1990 for Adobe Systems. The name comes from the traditional naming system for type sizes, in which minion is between nonpareil and brevier...

    .
  • MetaFog 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.


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.

Use

While well-known font designers, such as Hermann Zapf
Hermann Zapf
Hermann Zapf is a German typeface designer who lives in Darmstadt, Germany. He is married to calligrapher and typeface designer Gudrun Zapf von Hesse....

, 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."

History

Donald Knuth
Donald Knuth
Donald Ervin Knuth is a computer scientist and Professor Emeritus at Stanford University.He is the author of the seminal multi-volume work The Art of Computer Programming. Knuth has been called the "father" of the analysis of algorithms...

 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
TeX
TeX is a typesetting system designed and mostly written by Donald Knuth and released in 1978. Within the typesetting system, its name is formatted as ....

, where the number asymptotically
Asymptote
In analytic geometry, an asymptote of a curve is a line such that the distance between the curve and the line approaches zero as they tend to infinity. Some sources include the requirement that the curve may not cross the line infinitely often, but this is unusual for modern authors...

 approaches e
E (mathematical constant)
The mathematical constant ' is the unique real number such that the value of the derivative of the function at the point is equal to 1. The function so defined is called the exponential function, and its inverse is the natural logarithm, or logarithm to base...

with each revision.

Example

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

mode_setup;

% Define a beanlike shape for the character B
beginchar("B",11pt#,11pt#,0);
% Setup coordinates as an equation system
y1=y2=y3=0;
y4=y5=y6=h;
x1=x4=0;
x2=x5=w;
x3=x6=2*w;

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

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

end

This yields the following glyph:

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK