8

I search a way to automatically convert an sfd file (The work format of Fontforge) to the main font format (at least otf, ttf, woof, svg).

But I need to do it in command line, I don’t need to do it from GUI.

Unfortunately it seams that the Fontforge application don’t support it (I read the manpage and there is no mention of this usage). Anyway, I need to do it from command line but it’s not necessary to do it from Fontforge. Any other application who can convert the Fontforge work format “SFD” to the main font format.

So, how can I get a commands like this:

sfd2ttf input.sfd output.ttf sfd2otf input.sfd output.otf sfd2woff input.sfd output.woff sfd2svg input.sfd output.svg 

1 Answer 1

12

You can do it with Fontforge, see here:

-c script-string

If FontForge's first (or second, if the first is -lang) argument is "-c" then the argument that follows will be treated as a string containing scripting commands, and those commands will be executed. All remaining arguments will be passed to the script.

$ fontforge -c 'Open($1); Generate($2)' foo.sfd foo.ttf 

Will read a font from "foo.sfd" and then generate a truetype font from it called "foo.ttf"

In your case you can create a script, say convertsfd, like this

#!/bin/bash fontforge -lang=ff -c 'Open($1); Generate($2)' "$1" "$2" 

make it executable, and call it like this:

$ ./convertsfd foo.sfd foo.ttf 

Change the second argument to foo.otf or to other formats as needed, I only tested with ttf and otf.

To call the script from anywhere, just place it in your ~/.local/bin, or some other directory in your PATH.

2
  • The produced ttf misses metadata from the input sfd like copyright, weight, version. Those are filled when doing the conversion in the GUI. How do I keep these fields when converting via the command line? Commented Mar 19, 2024 at 20:49
  • For me it just errors out saying it doesn't recognize the flag -lang=ff and after removing that it errors out complaining about the ( in the ID, when removing those it complains about not recognizing the flag -c. Commented Mar 6 at 22:14

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.