Reputation: 8350
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.
Upvotes: 15
Views: 10617
Reputation: 174
My PowerShell script for Windows 10 (execute from FontForge directory, i.e. C:\Program Files (x86)\FontForgeBuilds\bin):
.\fontforge -lang=ff -c 'Open($1); SelectWorthOutputting(); foreach Export($2); endloop;' 8bitlim.ttf '%n-%e.svg'
A version that reads all fonts from a subdirectory "fonts" and extracts glyphs:
$files = Get-ChildItem "fonts"
for ($i=0; $i -lt $files.Count; $i++) { $infile = "fonts" + $files[$i].Name .\fontforge -lang=ff -c 'Open($1); SelectWorthOutputting(); foreach Export($2); endloop;' $infile '%n-%e.svg' }
Upvotes: 1
Reputation: 16600
On Windows os (Tested on win10)
this is from inside a BATCH file:
c:\Programs\FontForge\bin\fontforge.exe -lang=ff -c "Open($1); SelectWorthOutputting(); foreach Export('%%e_%%f_%%n_%%u.eps'); endloop;" %1
this is directly on the command line:
c:\Programs\FontForge\bin\fontforge.exe -lang=ff -c "Open($1); SelectWorthOutputting(); foreach Export('%e_%f_%n_%u.eps'); endloop;" font-file.ttf
note - the color is not exported. And I don't know if it's unimplemented, or a bug.
Upvotes: 1
Reputation: 366
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
SelectWorthOutputting(); foreach Export("svg"); endloop;
It'll save to the FontForge folder (where run_fontforge.exe is located).
Upvotes: 32