[tex-live] Extract glyph outlines from MetaPost font files

Steve White stevan.white at googlemail.com
Mon Feb 13 13:16:19 CET 2012

The mpost command is the ticket to pull glyph outlines from a MetaFont
(.mf) file, but the process is not at all clear from existing
documentation.  Here is my recipe.

1) Install metapost packages

A file "mfplain.mem" is required by mpost.
On my system, the texlive-metapost package puts that in

2) Produce an mfplain.mem file

$ mpost -ini '\input /usr/share/texmf-texlive/metapost/base/mfplain.mp; dump'
This is MetaPost, version 1.208 (kpathsea version 5.0.0) (INIMP)
Preloading the plain base, version 0.99:
Beginning to dump on file mfplain.mem
Transcript written on mfplain.log.

3) Extract the glyph outlines

For a MetaFont file named, for example, "grmk12.mf",

$ mpost '&./mfplain \mag=83.82; mode:=localfont; filenametemplate
"%j-%4c.eps"; input grmk12.mf'

The '\mag' setting adjusts the magnification (in percent).
The 'filenametemplate' prescribes the output file names.

The result should be a bunch of individual EPS files with names like

Further processing
FontForge can open these EPS files, but to open them individually is a
big chore.
To automate it, I wrote a script, now in the GNU FreeFont SVN, named

This results in a single FontForge font containing the glyphs, in the
order they appear in the MetaFont file.

The right bearing of the glyphs is set to some large value.  You have
to guess at a better one.
The glyphs are broken down into MetaFont strokes -- a good thing and a
bad thing.
First problem: many of the stroke outlines aren't drawn clockwise. Fix
that by hand.
Then FontForge can remove the overlap.

Then the real work of clean-up begins.

Guten Appetit!

More information about the tex-live mailing list