TransWikia.com

Convert in command line an sfd file (fontforge) to ttf, otf, woff, svg

Unix & Linux Asked on December 4, 2021

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

2 Answers

I have started to put together a tool to provide a simplified interface to common actions.

You can convert TTF to any other font type with this:

$ npm install @mountbuild/mouse -g
$ mouse convert input.ttf -o output.otf

If nothing else check out the source and see how to write your own script to do this in JavaScript.

Answered by Lance Pollard on December 4, 2021

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.

Answered by resc on December 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP