Batch process fonts > ufo?

oneweioranother's picture

Does anyone know a good way to batch process fonts into UFO format? I don't have RoboFont so unfortunately that's not an option.

Thanks

jasonc's picture

from a VFB or from otf?

PabloImpallari's picture

What do you mean by batch "process"?
batch generate? batch edit font info? batch rename?

If batch Generate, you can use Area51
if batch Edit Font Info, you can write some python scripts
It depends on what you want to do...

Michel Boyer's picture

Did you find a problem with FontForge? For me the script

---- fnt2ufo ----
#!/usr/bin/env fontforge -lang=ff

Open($1);
Generate($1:r + ".ufo");
Quit(0);
---- cut here ---

appears to work. With linux or OS X, a simple

find . -name "*.otf" -exec fnt2ufo {} \;

should do the job for all otf font files in the current directory and subdirectories. If that is not fast enough (due to one call to fontforge for each file) you can reduce the number of calls to one reusing some code of http://fontforge.org/scripting-tutorial.html

Michel Boyer's picture

Now I remember that you have been using the github version of FontForge. If so, and if FontForge.app is in /Applications then save the following lines in a file, say sfnt2ufo

#!/Applications/FontForge.app/Contents/Resources/opt/local/bin/fontforge -lang=ff
Open($1);
Generate($1:r + ".ufo");

Then execute the command

chmod 755 sfnt2ufo

and put the file sfnt2ufo somewhere in your path (one of the folders listed when you type echo $PATH). Then, and only then, you can execute (in any folder)

find . -iname "*.[ot]tf" -exec sfnt2ufo {} \;

to process all ttf and otf files or simply use

sfnt2ufo <fontfile>

to get the corresponding ufo of one particular font file.

Michel Boyer's picture

I just tried on a MacBook Air with no programmer tool installed (no X code), just XQuartz and github FontForge and applications from the mac store. The input was 486 western fonts from Adobe Type Classics (something of about 10 years ago). It took about 2 minutes to generate the ufo, but FontForge would not process back some of the UFO files, telling it could not process the features in the ufo and scrapping them.

abattis's picture

Please post the exact error message so I can get this fixed :)

Michel Boyer's picture

More that two months afterwards! You are lucky I did not scrap those files. Here is the answer I had prepared for your post.

----
Here is a trace searching for a particular problem in the .fea files that were generated

 find . -name "*.fea" -exec grep 'by[ ]*;' {} \; | sort | uniq -c
 102        sub [\uniF661 ]' [\slash \fraction \uni2215 ]' [\uniF661 ]'  by ;
  12        sub [\uniF661 ]' [\slash \fraction ]' [\uniF661 ]'  by ;
 128        sub [\zero ]' [\slash \fraction ]' [\zero ]'  by ;

This found all feature files and searched in them for lines where 'by ;' is written. There is a total of 102 + 12 +128 =242 lines. Those are the 242 lines that cause the problem with the 242 ufo files.

After executing

find . -name "*.fea" -exec sed -i .orig '/by[ ]*;/d' {} \;

to remove those lines, FontForge accepted the ufo files as input without scrapping the features.

Michel Boyer's picture

Please post the exact error message so I can get this fixed :)

Here is the stderr file that was generated when reading in the .ufo file for Utopia Standard Regular

Copyright (c) 2000-2012 by George Williams. See AUTHORS for contributors.
License GPLv3+: GNU GPL version 3 or later
with many parts BSD . Please read LICENSE.
Executable based on sources from 12:29 EST 18-Jul-2013-ML-NoPython-D.
Library based on sources from 12:29 EST 18-Jul-2013.
Based on source from git with hash:f8dc0063ea93c64e70e5ab1402a840e8c9801cc8
No substitution specified on line 583 of /Users/boyer/Desktop/Western Fonts/Utopia Std Opticals/UtopiaStd-Regular.ufo/feature.fea
There were errors when parsing the feature file and the features have not been applied

Line 583 is

    sub [\uniF661 ]' [\slash \fraction \uni2215 ]' [\uniF661 ]'  by ;
Syndicate content Syndicate content