Search code examples
svgfontforge

Fontforge: Export a glyph to SVG with fontforge command line


How to export a glyph (from its unicode) to SVG with Fontforge command line ?

I also need to specify the font size and keep the original margins it has in the font.


Solution

  • You may have found your answer already, but I just had to do this with the latest build of FontForge. The old answer of this command:

    fontforge -lang=ff -c 'Open($1); SelectWorthOutputting(); foreach Export("svg"); endloop;' font.ttf 
    

    From a command prompt didn't want to work on Windows10 (I assume a permission issue), but you could give it a try. A quick work-around is to do it via the GUI Execute Script.

    • Run FontForge (For Windows10 installed in the Program Files (x86) directory, you may need to right-click "run_fontforge.exe" --> Run As Administrator).

    • Open the font you want to export.

    • Go to File > Execute Script

    • Paste: SelectWorthOutputting(); foreach Export("svg"); endloop;
    • Select "FF" radial button.
    • Hit OK

    It'll save to the FontForge folder (where run_fontforge.exe is located).