Misplaced Pages

Metafont

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

Metafont is a description language used to define raster 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 a companion to his TeX typesetting system.

#213786

41-492: One of the characteristics of Metafont is that the points defining the shapes of the glyphs —for example top of a stem , or intersection of a stem and crossbar—are defined with geometrical equations; the intent that the three stems of an ‘m’ are equally spaced horizontally might be expressed as x 2 − x 1 = x 3 − x 2 {\displaystyle x_{2}-x_{1}=x_{3}-x_{2}} if points 1, 2, and 3 are at

82-433: A serif font slowly transitioning into a sans-serif design over the course of a text. 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

123-499: 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

164-405: A common name prefix, an idiom supported by the type declaration system giving all variables whose names which differ only in numeric indices the same type (as expected for arrays) while keeping variables whole name differ in some symbolic token separate (as expected for records). A very distinctive feature of Metafont is the use of equations to define variables. A numeric variable (or component of

205-478: A confusing " somefont .mf not found" error message. Equally important, but not as common, is running Metafont to generate a font metric (TFM) file; a TFM file is only generated if the fontmaking variable is positive. Traditionally TeX distributions have often come with all TFM files pregenerated (since they are pretty small), but someone installing a Metafont font from sources will have to generate its TFM file before TeX can use it. A third way of operating Metafont

246-560: A document is displayed, but on the other hand TeX distributions with a Metafont component have typically not included any prebuilt bitmap fonts, since they would be rather large in comparison to the sources from which they could be generated. Since Metafont fonts were traditionally the TeX default from which other font formats were exceptions, an incomplete installation of a non-Metafont font can sometimes result in Metafont being called and emitting

287-515: A glyph is a graphical unit. 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 produces vector graphic diagrams from a geometric/algebraic description. The language shares Metafont's declarative syntax for manipulating lines, curves, points and geometric transformations. However, Many of

328-448: A ninth type of variable, although macros do not exist as first-class values in Metafont. Unusually, the names of variables are not simple tokens, but sequences of symbolic tokens and numeric indices; the variable name x2r is thus not one alphanumeric token, but a sequence of the three tokens x (symbolic), 2 (numeric), and r (symbolic). Record and array types may be simulated through collections of variables that share

369-440: A pair of matching delimiters, but normally Metafont programs use only the ordinary parentheses. Besides to override priorities in expressions, delimiters are also required around certain kinds of macro arguments. Curves in Metafont are defined as cubic splines , rather than quadratic, for greater versatility at the cost of more complex arithmetic. Unlike more common outline font formats (such as TrueType or PostScript Type 1 ),

410-412: A pair or transformation variable) may be in the three states known (set), unknown independent (not set), and unknown dependent (not set, but given by a linear expression of one or several independents). When Metafont executes an equation statement, it turns one of the independents involved into a dependent and eliminates it from the expressions for all other dependents; when no independents remain in

451-424: 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 pitches from 5 to 17 cpi, with the stroke widths the same in all sizes (rather than increasing as

SECTION 10

#1732787426214

492-492: A single glyph. Older models of typewriters required the use of multiple glyphs to depict a single character, as an overstruck apostrophe and period to create an exclamation mark . If there is more than one allograph of a unit of writing, and the choice between them depends on context or on the preference of the author, they now have to be treated as separate glyphs, because mechanical arrangements have to be available to differentiate between them and to print whichever of them

533-416: A single unit, is arguably not a glyph as this is just a design choice of that typeface, essentially an allographic feature, and includes more than one grapheme . In normal handwriting, even long words are often written "joined up", without the pen leaving the paper, and the form of each written letter will often vary depending on which letters precede and follow it, but that does not make the whole word into

574-559: A subset of Metafont's language into EPS outlines, which can subsequently be converted to PostScript Type 1 fonts. Generating vector outlines of Metafont pen strokes is nontrivial, as the Metafont model of a glyph is a raster image and the exact outlines of most strokes are not Bézier curves . The common approach to generate Type 1 fonts with pen strokes remains to generate a high-resolution bitmap and then use an autotracer , implemented by packages such as mftrace and TeXtrace Glyph A glyph ( / ɡ l ɪ f / GLIF )

615-550: A whole range of fonts to actually draw the individual glyphs; this is the meta aspect of the system. Metafont is most often run as a helper to output device (printer, screen) drivers; in those cases, its job is to generate bitmaps for a font for a specific combination of output device (called a mode in Metafont) and resolution (visible in the name of the output file, see below). These bitmaps are typically stored for later reuse, so that Metafont does not have to be run every time

656-521: Is proof mode : if the proofing variable is positive then the bitmap font file also contains additional information provided via special commands, in particular the positions and names of points the font designer considered important for the design. If using the separate gftodvi utility to generate enlarged images of the font glyphs, this information from specials is included; point positions are not limited to pixel resolution. Metafont can also be run interactively, and has commands for displaying on

697-461: Is an interpreted language for programs that are essentially declarative rather than imperative . Variables in Metafont can be of eight different types: Metapost adds color (a triple of numerics) as a ninth type and has a completely different (non-raster) model for pictures; the latter is the main point of divergence between the two programs. Metafont vardef macros also live in the same namespace as variables and may in some ways be regarded as

738-436: Is any kind of purposeful mark. In typography , a glyph is "the specific shape, design, or representation of a character". It is a particular graphical representation, in a particular typeface , of an element of written language. A grapheme , or part of a grapheme (such as a diacritic ), or sometimes several graphemes in combination (a composed glyph) can be represented by a glyph. In most languages written in any variety of

779-427: Is no restriction that tokens with certain meanings must have names consisting of certain characters. At runtime, there can additionally be capsule tokens, which are effectively constant value tokens of arbitrary type; in the source code those appear as symbolic tokens. Except where characters are involved in numeric or string constants, the extent of the token containing a particular character depends on to which class

820-587: Is required. In computing as well as typography, the term " character " refers to a grapheme or grapheme-like unit of text, as found in natural language writing systems ( scripts ). In typography and computing, the range of graphemes is broader than in a written language in other ways too: a typeface often has to cope with a range of different languages each of which contribute their own graphemes, and it may also be required to print non-linguistic symbols such as dingbats . The range of glyphs required increases correspondingly. In summary, in typography and computing,

861-499: Is still likely to be recognized correctly. However, in Turkish and adjacent languages, this dot is a glyph because that language has two distinct versions of the letter i , with and without a dot . In Japanese syllabaries , some of the characters are made up of more than one separate mark, but in general these separate marks are not glyphs because they have no meaning by themselves. However, in some cases, additional marks fulfil

SECTION 20

#1732787426214

902-511: The Latin alphabet except English, the use of diacritics to signify a sound mutation is common. For example, the grapheme ⟨à⟩ requires two glyphs: the basic a and the grave accent ` . In general, a diacritic is regarded as a glyph, even if it is contiguous with the rest of the character like a cedilla in French , Catalan or Portuguese , the ogonek in several languages, or

943-625: 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

984-728: The TeX and Metafont framework, for example, it is included in the MiKTeX and the TeX Live distributions. The encapsulated postscript produced by Metapost can be included in LaTeX , ConTeXt , and TeX documents via standard graphics inclusion commands. The encapsulated postscript output can also be used with the PDFTeX engine, thus directly giving PDF . This ability is implemented in ConTeXt and in

1025-565: The LaTeX graphics package, and can be used from plain TeX via the supp-pdf.tex macro file. ConTeXt and LuaTeX supports the inclusion of MetaPost code within the input file. Inclusion of MetaPost code in LaTeX is also possible by using LaTeX-packages, for example gmp or mpgraphics . This is a single file example.mp which when processed by the MetaPost interpreter (via the command mpost on Linux ) produces three eps files example.1 , example.2 , example.3 . These are pictured on

1066-599: The above is the class of internal quantity variables. These have names consisting of just one symbolic token, are always numeric, and are always known. They have a more direct internal representation than ordinary variables, making it convenient for primitive operations in Metafont (or extensions thereof) to use them implicitly. Metafont has numeric and string constant tokens with mainstream syntaxes; strings are delimited by " quotes, numeric constants can have decimals but not an exponent part . All other tokens are classified as symbolic , and can be redefined arbitrarily; there

1107-496: The bitmaps (bounding box, eliding repeated rows) and encodes all rows of a character as one long bit-sequence. In the TeX Directory Structure standard, filenames are limited to 8+3 characters, so GF and PK files would only have extensions .gf and .pk . Files for different resolutions are kept apart by placing them in separate directories, named dpi NNNN, e.g. dpi300/cmr10.pk . The Metafont language

1148-411: The bottom ends of the three stems, whereas the intent that they all end on the same vertical position would be y 1 = y 2 = y 3 {\displaystyle y_{1}=y_{2}=y_{3}} . Metafont is a macro language, where operations such as "draw a lower case top of stem serif at point 4" might appear as one macro instruction (with the point as argument) in

1189-416: The character belongs; unlike TeX , Metafont has fixed character classes. The characters , , ; , ( , and ) are "loners" and only form single character tokens. For the character classes <=>:| , ‘’ (single quotes), +- , /*\ , !? , #&@$ , ^~ , [ , ] , {} , and . , as well as the class of underscore together with upper and lower case A–Z, the token consists of

1230-428: The expression for a dependent variable, that variable becomes known. Solving linear equation systems thus is a built-in feature of the Metafont language, and the recommended method of assigning most variables (especially those whose values have geometric significance) is to state equations determining their values. Equation systems frequently mix numeric (scalar) equations with pair (vector) equations. An exception to

1271-454: 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." Jonathan Hoefler commented that the Metafont system ultimately became "a technology behind zero of your favourite fonts...Knuth's idea that letters start with skeletal forms is flawed." The Metafont system allows fonts to be processed in unusual ways; in 1982, Knuth showed how it could be used to morph fonts, with

Metafont - Misplaced Pages Continue

1312-472: The font is scaled up). 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. While well-known type 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

1353-468: The gftopk program to convert the NNNNgf files to pk (packed) format (.NNNNpk). The pk format was primarily introduced to reduce file size (to about half), but expected to also speed up processing since less data would have to be input/output . The GF and PK formats both employ run-length encoding of bitmaps, but make different binary encodings of the run-lengths. The PK format also does some preprocessing of

1394-413: The limitations of MetaPost derive from features of Metafont. For instance, MetaPost does not support all features of PostScript . Most notably, paths can have only one segment (so that regions are simply connected ), and regions can be filled only with uniform colours. PostScript level 1 supports tiled patterns and PostScript 3 supports Gouraud shading . MetaPost is distributed with many distributions of

1435-440: The longest consecutive sequence of characters from the same class. Whitespace characters don't contribute tokens. % starts a comment lasting until end of line. A notable application of these rules is that # is frequently appearing as part of variable names in Metafont code, e.g. em# and pt# . Delimiters (such as parentheses) do not have built-in meanings, instead there is a command that turns two symbolic tokens into

1476-659: The number asymptotically approaches e with each revision. The following example creates a closed beanlike shape for the character "B" of a font: This yields the following glyph: [REDACTED] The above example will be processed with a command line such as: Then it can be used in a LaTeX file such as the following (all files should dwell in the same directory, or the TeX system should be informed about them using appropriate methods): The resulting PDF file should look like this: [REDACTED] There are several tools for converting Metafont programs to PostScript Type 1 fonts. Most make use of MetaPost 's ability to convert

1517-417: The program for a letter. For describing shapes, Metafont has a rich set of path construction operations that mostly relieves the user of having to calculate control points. Many families of Metafont fonts are set up so that the main source file for a font only defines a small number of design parameters ( x-height , em width, slant, vertical stroke width, etc.), then calling a separate source file common for

1558-534: The role of diacritics , to differentiate distinct characters. Such additional marks constitute glyphs. Some characters such as " æ " in Icelandic and the " ß " in German may be regarded as glyphs. They were originally typographic ligatures , but over time have become characters in their own right; these languages treat them as unique letters. However, a ligature such as "fi", that is treated in some typefaces as

1599-410: 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. Metafont can render any kind of graphical output, not just glyphs. However, MetaPost and Asymptote are preferred for mathematical illustrations. Metafont is most commonly invoked without a direct request from

1640-418: The stroke on a Polish " Ł ". Although these marks originally had no independent meaning, they have since acquired meaning in the field of mathematics and computing, for instance. Conversely, in the languages of Western Europe, the dot on a lower-case ⟨i⟩ is not a glyph in itself because it does not convey any distinction, and an ⟨ı⟩ in which the dot has been accidentally omitted

1681-410: 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. Metafont outputs several kinds of files: for a file called NAME.mf, it can output: After running Metafont, typically one uses

Metafont - Misplaced Pages Continue

#213786