I'm hoping to generate SVG paths for a large number of characters, and I wonder if this could be automated via Metapost. From what I've read,

mpost ’&mfplain’ cmr10

will let mpost process a Metafont description of font characters, and output one postscript file for each character. I'm looking for something similar — interpreting Metafont path descriptions and returning vector shapes — but producing open paths, as opposed to filled outlines. Basically just the trajectory of the pen, as opposed to the trace it leaves on paper.

Does this sound doable with Metapost? I'm very unfamiliar with the system, so I prefer to ask before going too deep and realising this is hopeless.

1 Answer 1


MetaPost does not change the kind of path you pass into it. So if you have a font like logo10 which is defined using open paths, then the output from MetaPost will also use open paths (both in PostScript and in SVG). If on the other hand you use font like cmr10 which is defined using filled outlines, then the SVG or PostScript output will use the same. (Actually cmr10 uses the combination: Almost all glyphs use both fill and stroke, which is also copied into the SVG or PostScript output)

The only exception is if you use a pen which is not round, then MetaPost has to transform the strokes into filled outlines.

By the way, to get mpost to output SVG files you can pass the argument -s outputformat=\"svg\".

  • Thank you for the response; I should have checked the Metafont books before posting but I left them at the office. I was hoping the CM fonts were described using only the central strokes, and it was Metafont that produced a filled outline corresponding to the pen's width. But it sounds even the trajectory already considers outlines :/ This is unfortunate, as I am not aware of any single-stroke font that contains math characters (I was hoping not to have to draw them all myself).
    – baptiste
    Jan 6, 2021 at 20:00
  • Still.. looking at this particular example I wonder if I could (programmatically) replace all mf filldraw stroke commands with one that just draws the "skeleton" stroke (what command would that be?) Would Metapost then be able to interpret such commands and produce single-stroke SVGs?
    – baptiste
    Jan 6, 2021 at 20:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .