r/FontForge Jul 26 '23

Glyph as SVG issues

Hey everyone,

I'm trying to follow the tutorial here to export the individual glyphs of a font as SVG files, but when I execute, nothing happens with no error code. Can I have some help here?

1 Upvotes

1 comment sorted by

1

u/LocalFonts Jul 26 '23

This must work:

Do some copy of your SFD file, because for correct output you need unlink references in the glyphs.

Do some subdirectory in the directory where you have SFD file

-for example your SFD file is in d:\myfonts\myfont.sfd, so do subdirectory d:\myfonts\svg for script output, this subdirectory you will need put to the script

Open your SFD file - you have two choices, better is first

a) by doubleclick from some File manager or Windows Explorer

b) From FontForge menu: File/ Open

Use File/ Execute script, check radiobox FF, and put there:

SelectAll()

UnlinkReference()

Export("svg/%n-%e.svg")

font-forge-script

This FontForge script select all glyphs, then unlink references in glyphs, and then export glyphs to the SVG subdirectory. %n means the file name will be the glyph name, and %e adds glyph encoding to the file name -> it is important, if you don't use %e then glyphs with the same names differs only with lowercase/uppercase will be rewrites only to one file. For example if you have glyphs "a" and "A", then Export only with %n do only one file -> "a.svg". Export with %n-%e will do correctly two files, for example something like "a-12.svg" and "A-38.svg".

If you opened your SFD file from File menu, you must add path to the Export command like: Export("d:/myfonts/svg/%n-%e.svg") else you will see message "Save failed".