Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Inspired by Why Metapost discrimination?, I'd like to come to know Metapost far better than I do now. All I really know is that Metapost is a language for describing graphics, and Metafont is used specifically for describing fonts.

So what is Metapost/Metafont?

  • do Metafont/Metapost have similar syntax, as the names would suggest?
  • are the tools to work with and compile them included in the popular TeX distributions?
  • is there anything like a 'Hello World' for these systems? (Various examples with Metapost can be found throughout the site, but not so much Metafont, it seems.)
  • can pdfTeX use fonts created with Metafont without too much hassle?
  • (same for Metapost, but it would seem that the multiple examples on this site speak for themselves)
share|improve this question
For starters, texdoc mpman and texdoc metafont. For more fun with metapost, I find this and this really helpful. –  hpesoj626 Apr 8 '13 at 9:21
No documentation for metafont under MikTeX---that doesn't bode well for point #2 :( –  Sean Allred Apr 8 '13 at 9:44
Related: pgf/tikz vs metapost. Also Why does anyone prefer Metapost? –  hpesoj626 Apr 8 '13 at 9:51
The documentation of Metafont is Knuth's "The METAFONTbook". Yes, pdftex can use MF created fonts, but they are bitmap. –  egreg Apr 8 '13 at 12:23
With LuaTeX you can use MetaPost as an environment; no need for running an external program. –  Herbert Apr 21 '13 at 14:31

2 Answers 2

up vote 16 down vote accepted
  1. METAFONT was designed by Knuth to be a companion of TeX. Its job is to produce fonts from "mathematically described" shapes. The output of METAFONT is a collection of bitmapped glyphs; by setting suitable parameters, if the description of the characters is careful, the output can be adjusted to suit any particular printing device (for instance resolution is very important, but it's not the unique aspect to take care of).

  2. Metapost is a program directly derived from METAFONT; it was originally written by John Hobby, who made valuable contributions to METAFONT. So, yes, their syntax is similar: the language is actually the same, but Metapost adds several primitives and also data types (RGB and CMYK colors are respectively triples and quadruples that aren't used in METAFONT). Conversely, some of the features of METAFONT are meaningless in Metapost

  3. Metapost's output is a simple form of Postscript, and this is the main difference between the two programs: Metapost's output is vector graphics, while METAFONT only outputs rasters.

  4. Metapost can interface with TeX to get character metrics and include type in its output. This is not possible in METAFONT (well, there are some TUGboat papers describing clever usage of METAFONT).

  5. Fonts created by METAFONT are usable with pdftex: all that's possible in Knuth TeX is possible also with pdftex. However, the fonts are bitmap, so high resolution versions of them have to be generated if one wants good output; pdftex has a couple of primitives for this: \pdfpkresolution and \pdfpkmode that are used for generating on demand bitmaps from the sources.

  6. The output of Metapost, being (Encapsulated) Postscript, can be directly included with latex; but, since it uses a restricted set of Postscript functions, it can also be included in pdflatex via a set of TeX macros originally written for ConTeXt.

  7. A "Hello world" for METAFONT can be found in the METAFONTbook, but it's not really as simple as a similar test document for (La)TeX.

  8. A "Hello world" for Metapost can be written "easily". Write the following hello.mp document:

    prologues:=3;                % include all fonts
    outputtemplate:="%j-%c.mps"; % output file will be hello-1.mps
    label(btex Hello world! etex, (1.5cm,1.5cm));

    Run mpost hello and then epstopdf hello-1.mps to get hello-1.pdf for previewing

    enter image description here

The complete documentation of Metapost is available in the TeX distributions (for TeX Live do texdoc metapost).

share|improve this answer

To expand upon Herbert's comment and as an adjunct to egreg's, here's a code snippet which will allow one to directly process MetaPost code within LuaLaTeX, no need for external tools, Thanks in part to luamplib, a package/support interface for the mplib Lua library, an embedded version of MetaPost:

label ("Insert MP code here", (10,10));
share|improve this answer
Just another reason I should start using LuaTeX... thanks! –  Sean Allred Aug 20 '13 at 13:37
Will the label use the document fonts? In ConTeXt, you have to use btex text etex to use document fonts in metapost labels. –  Aditya Aug 20 '13 at 20:07
Apparently one can use the default MP command for this, e.g., defaultfont := "ptmr8r"; as Taco Hoekwater pointed out to me on the mailing list. –  WillAdams Aug 22 '13 at 12:57
@Aditya: starting from recent versions of luamplib you can indeed use the btex … etex flags to use the same fonts as in the rest of your LuaLaTeX document. You can even use the more flexible textext("…") macro much (much similar to the textextmacro of Metafun), thus allowing loop constructs on your labels for instance. –  fpast Jan 26 at 17:28
@fpast: Thanks for the update. This is great news. –  Aditya Jan 26 at 23:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.