MetaPost

Last updated
MetaPost
MPlogo.svg
Paradigm imperative, typesetting
Designed by John D. Hobby
Developer Taco Hoekwater, Luigi Scarso
First appeared1994 (1994)
Stable release
1.8 / 17 June 2013;10 years ago (2013-06-17)
Preview release
2.0rc2 / 19 February 2018;5 years ago (2018-02-19)
Typing discipline duck, dynamic, strong
OS Cross-platform
License LGPL
Website tug.org/metapost
Influenced by
Metafont

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,

Contents

Many of 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.

Availability and usage

MetaPost is distributed with many distributions of 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 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.

Examples

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 the right.

example outputs Metapost ex.svg
example outputs
transformpagecoords;pagecoords:=identityscaled10mmshifted(100mm,150mm);beginfig(1)fill((0,0)--(2,0)--(2,1)--(1,1)--(1,2)--(0,2)--cycle)transformedpagecoordswithcolorgreen;draw((2,0)..(2,1)..(1,1)..(1,2)..(0,2))transformedpagecoords;drawarrow((0,0)--(2,2))transformedpagecoords;endfig;beginfig(2)draw(fori=0upto7:dir(135i)--endforcycle)transformedpagecoords;endfig;pagecoords:=identityscaled15mmshifted(100mm,150mm);beginfig(3);% declare paths to be usedpathp[],p[]t;% set up points by defining relationshipsz1=(0,0);z2=z1+2up;z3=z1+whatever*dir(60)=z2+whatever*dir(-50);z4=z3+(-1.5,-.5);z5=z1+dir(135);z0=whatever[z1,z2]=whatever[z3,z4];% set up pathsp0=fullcircleyscaled.5rotated45shiftedz0;p1=z2---z4..z0..z3---z1;p2=p1cutbeforep0cutafterp0;p3=p0cutbeforep1cutafterp1;p4=p2---p3---cycle;% define transformed versions of paths and pointsfori=0upto4:p[i]t=p[i]transformedpagecoords;endforfori=0upto5:z[i]t=z[i]transformedpagecoords;endfor% do some drawingfillp4twithcolor(1,1,0.2);drawz1t---z2twithcolor.5white;drawz3t---z4twithcolor.5white;pickuppencircle;drawp0tdashedwithdotsscaled.3;drawp1tdashedevenly;drawp2twithcolorblue;drawp3twithcolorred;label.lrt(btex $z_0$ etex,z0t);label.llft(btex $z_1$ etex,z1t);label.top(btex $z_2$ etex,z2t);label.rt(btex $z_3$ etex,z3t);label.llft(btex $z_4$ etex,z4t);fori=0upto4:drawdotz[i]twithpenpencirclescaled2;endforendfig;bye

The resulting three eps files can be used in TeX via LaTeX's \includegraphics command, ConTeXt's \externalfigure, Plain TeX's \epsfbox command, or (in Plain pdftex) the \convertMPtoPDF command from supp-pdf.tex. To view or print the third diagram, this inclusion is necessary, as the TeX fonts (Computer Modern) are not included in the eps files produced by MetaPost by default.

See also

Related Research Articles

<span class="mw-page-title-main">PostScript</span> File format and programming language

PostScript (PS) is a page description language in the electronic publishing and desktop publishing realm. It is a dynamically typed, concatenative programming language. It was created at Adobe Systems by John Warnock, Charles Geschke, Doug Brotz, Ed Taft and Bill Paxton from 1982 to 1984.

TeX, stylized within the system as TeX, is a typesetting system which was designed and written by computer scientist and Stanford University professor Donald Knuth and first released in 1978. TeX is a popular means of typesetting complex mathematical formulae; it has been noted as one of the most sophisticated digital typographical systems.

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.

OpenType is a format for scalable computer fonts. Derived from TrueType, it retains TrueType's basic structure but adds many intricate data structures for describing typographic behavior. OpenType is a registered trademark of Microsoft Corporation.

<span class="mw-page-title-main">Device independent file format</span> Typesetting file format

The device independent file format (DVI) is the output file format of the TeX typesetting program, designed by David R. Fuchs and implemented by Donald E. Knuth in 1982. Unlike the TeX markup files used to generate them, DVI files are not intended to be human-readable; they consist of binary data describing the visual layout of a document in a manner not reliant on any specific image format, display hardware or printer. DVI files are typically used as input to a second program which translates DVI files to graphical data. For example, most TeX software packages include a program for previewing DVI files on a user's computer display; this program is a driver. Drivers are also used to convert from DVI to popular page description languages and for printing.

<i>Computers and Typesetting</i> 1986 book series on digital typography by American computer scientist Donald Knuth

Computers and Typesetting is a 5-volume set of books by Donald Knuth published in 1986 describing the TeX and Metafont systems for digital typography. Knuth's computers and typesetting project was the result of his frustration with the lack of decent software for the typesetting of mathematical and technical documents. The results of this project include TeX for typesetting, Metafont for font construction and the Computer Modern typefaces that are the default fonts used by TeX. In the series of five books Knuth not only describes the TeX and Metafont languages, he also describes and documents the source code of the TeX and Metafont interpreters, and the source code for the Computer Modern fonts used by TeX. The book set stands as a tour de force demonstration of literate programming.

<span class="mw-page-title-main">Xfig</span> Vector graphics editor for UNIX-like systems

Xfig is a free and open-source vector graphics editor which runs under the X Window System on most UNIX-compatible platforms.

<span class="mw-page-title-main">Computer Modern</span> Family of typefaces

Computer Modern is the original family of typefaces used by the typesetting program TeX. It was created by Donald Knuth with his Metafont program, and was most recently updated in 1992. Computer Modern, or variants of it, remains very widely used in scientific publishing, especially in disciplines that make frequent use of mathematical notation.

<span class="mw-page-title-main">ConTeXt</span> General-purpose document processor, derived from TeX

ConTeXt is a general-purpose document processor. Like LaTeX, it is derived from TeX. It is especially suited for structured documents, automated document production, very fine typography, and multilingual typesetting. It is based in part on the TeX typesetting system, and uses a document markup language for manuscript preparation. The typographical and automated capabilities of ConTeXt are extensive, including interfaces for handling microtypography, multiple footnotes and footnote classes, and manipulating OpenType fonts and features. Moreover, it offers extensive support for colors, backgrounds, hyperlinks, presentations, figure-text integration, and conditional compilation. It gives the user extensive control over formatting while making it easy to create new layouts and styles without learning the low-level TeX macro language.

A computer font is implemented as a digital data file containing a set of graphically related glyphs. A computer font is designed and created using a font editor. A computer font specifically designed for the computer screen, and not for printing, is a screen font.

<span class="mw-page-title-main">AMS Euler</span> Typeface

AMS Euler is an upright cursive typeface, commissioned by the American Mathematical Society (AMS) and designed and created by Hermann Zapf with the assistance of Donald Knuth and his Stanford graduate students. It tries to emulate a mathematician's style of handwriting mathematical entities on a blackboard, which is upright rather than italic. It blends very well with other typefaces made by Hermann Zapf, such as Palatino, Aldus and Melior, but very badly with the default TeX font Computer Modern. All the alphabets were implemented with the computer-assisted design system Metafont developed by Knuth. Zapf designed and drew the Euler alphabets in 1980–81 and provided critique and advice of digital proofs in 1983 and later. The typeface family is copyright by American Mathematical Society, 1983. Euler Metafont development was done by Stanford computer science and/or digital typography students; first Scott Kim, then Carol Twombly and Daniel Mills, and finally David Siegel, all assisted by John Hobby. Siegel finished the Metafont Euler digitization project as his M.S. thesis in 1985.

TeX font metric (TFM) is a font file format used by the TeX typesetting system. It is a font metric format, not an outline font format like TrueType, because it provides only the information necessary to typeset the font such as each character's width, height and depth. The actual glyphs are stored elsewhere. This is not unique to TeX; Adobe's AFM files and Windows' PFM files use the same technique.

<span class="mw-page-title-main">FontForge</span> Font editor created by George Williams

FontForge is a FOSS font editor which supports many common font formats. Developed primarily by George Williams until 2012, FontForge is free software and is distributed under a mix of the GNU General Public License Version 3 and the 3-clause BSD license. It is available for operating systems including Linux, Windows, and macOS, and is localized into 12 languages.

<span class="mw-page-title-main">AUCTeX</span>

AUCTeX is an extensible package for writing and formatting TeX files in Emacs and XEmacs.

<span class="mw-page-title-main">WinEdt</span>

WinEdt is a shareware Unicode (UTF-8) editor and shell for Microsoft Windows. It is primarily used for the creation of TeX documents, but can also be used to edit HTML or any other type of text file. It can be configured to run as a front-end for a variety of TeX systems, including MiKTeX, fpTeX and TeX Live. WinEdt's highlighting schemes can be customized for different modes and its spell checking functionality supports multi-lingual setups, with dictionaries (word-lists) for many languages available for downloading from WinEdt's Community Site. It supports DVI and PDF workflow.

MetaType1, also stylized as METATYPE1, is a tool for creating Type 1 fonts using MetaPost, developed by the Polish JNS team.

LuaTeX is a TeX-based computer typesetting system which started as a version of pdfTeX with a Lua scripting engine embedded. After some experiments it was adopted by the TeX Live distribution as a successor to pdfTeX. Later in the project some functionality of Aleph was included. The project was originally sponsored by the Oriental TeX project, founded by Idris Samawi Hamid, Hans Hagen, and Taco Hoekwater.

The computer program pdfTeX is an extension of Knuth's typesetting program TeX, and was originally written and developed into a publicly usable product by Hàn Thế Thành as a part of the work for his PhD thesis at the Faculty of Informatics, Masaryk University, Brno, Czech Republic. The idea of making this extension to TeX was conceived during the early 1990s, when Jiří Zlatuška and Phil Taylor discussed some developmental ideas with Donald Knuth at Stanford University. Knuth later met Hàn Thế Thành in Brno during his visit to the Faculty of Informatics to receive an honorary doctorate from Masaryk University.

PGF/Ti<i>k</i>Z Graphics languages

PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description, with standard features including the drawing of points, lines, arrows, paths, circles, ellipses and polygons. PGF is a lower-level language, while TikZ is a set of higher-level macros that use PGF. The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost. Till Tantau is the designer of the PGF and TikZ languages. He is also the main developer of the only known interpreter for PGF and TikZ, which is written in TeX. PGF is an acronym for "Portable Graphics Format". TikZ was introduced in version 0.95 of PGF, and it is a recursive acronym for "TikZ ist kein Zeichenprogramm".

<span class="mw-page-title-main">WinFIG</span>

WinFIG is a proprietary shareware vector graphics editor application. The file format and rendering are as close to Xfig as possible, but the program takes advantage of Windows features like clipboard, printer preview, multiple documents etc.

References