This article contains wording that promotes the subject in a subjective manner without imparting real information. Please remove or replace such wording and instead of making proclamations about a subject's importance, use facts and attribution to demonstrate that importance.(January 2016)
Metafont is set up to produce fonts, in the form of image files (in .gf format) with associated font metric files (in .tfm format), whereas MetaPost produces encapsulated PostScript files
The output of Metafont consists of the fonts at a fixed resolution in a raster-based format, whereas MetaPost's output is vector-based postscript graphics (lines, Bézier curves)
Metafont output is monochrome, whereas MetaPost uses RGB colors.
The MetaPost language can include text labels on the diagrams, either strings from a specified font, or anything else that can be typeset with TeX.
Many of the limitations of MetaPost derive from features of Metafont. For instance, numbers have a low-precision fixed-point representation, sufficient for representing the coordinates of points in a glyph, but this can be restrictive when working with figures in a larger coordinate space. Moreover, 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. To this end, the Asymptote graphics language has been developed to address these shortcomings.
MetaPost is distributed with many distributions of the TeX and Metafont framework. In particular, it is included in the teTeX and the TeX Live distribution, common on Linux and Unix (including Mac OS X) platforms.
The encapsulated postscript produced by Metapost can be included in TeX, ConTeXt, and LaTeX documents via standard eps-inclusion commands. This output can also be included in the PDFTeX dialect of TeX, thus directly giving PDF output from TeX. 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 even supports the creation of MetaPost files from within the TeX file.
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.
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(for i=0 upto 7: dir (135i)-- endfor cycle)transformedpagecoords;endfig;pagecoords:=identityscaled15mmshifted(100mm,150mm);beginfig(3);% declare paths to be usedpathp,pt;% 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.