Command line/batch processing of UFO to OTF?

blank's picture

I’m getting really tired of waiting for Fontlab to open a batch of UFO files. Aside from Area 51 are there any apps/scripts that can quickly convert a batch of UFO files to OTF or some other format Fontlab reads natively? Can I do this from the command line with FontForge?

Tal Leming's picture

I don't think a command line tool has been created yet. You could make one easily using the ufo2fdk package that I released last week. In fact, the demo script from my presentation might be a good starting point for you. It is included below. (Replace the "...." with the appropriate white space.)

Alternatively, you could use the batch generator in Area51.

from import OpenFont
import ufo2fdk
import glob
import os

# path to the fonts
directory = "/path/to/a/directory/containing/ufos"

# print a message if the FDK can't be found
if not ufo2fdk.haveFDK():
....print "I couldn't find the FDK :-(!"
# if the FDK is available
....# start the compiler
....compiler = ufo2fdk.OTFCompiler()

....# for each UFO in the directory
....for ufoPath in glob.glob(os.path.join(directory, "*.ufo")):
........print "Compiling: %s..." % os.path.basename(ufoPath)
........# put the OTF next to the UFO
........otfPath = os.path.splitext(ufoPath)[0] + ".otf"
........# open the UFO
........font = OpenFont(ufoPath)
........# compile = compiler.compile(font, otfPath)
........# print the makeotf report
........print report["makeotf"]

# done
print "Done!"

blank's picture

Thanks, Tal. I’m actually planning to update to 10.5 this week just to use Area51 for batch UFO generation.

Nagar's picture

I try to compile my UFO font to OTF as explained above but it doesn't work because my UFO font is not complete.

I'm working on a project where typography is gradually created. Thus, I don't have a complete UFO font but I have to create the OTF to display the progress…

Does anyone have an idea for this case?

Thank you very much.

Té Rowan's picture

Can you do it with FontForge? Yes, I'm pretty sure you can. FF can read UFO, and it handles scripts, both Python and its own old scripting language.

Nagar's picture

I work without FontForge. The project is a website and everything (all the process) must be launched online. Of course, it's very difficult to install FontForge on my webhosting…

Otherwise, you're right. Fontforge can do that.

Syndicate content Syndicate content