* syntax sometimes problematic
[dejavu.git] / dejavu-fonts / scripts / generate.py
blob467d52bef2c0377cf809ce565750fc6e2a52b7d3
1 #!/usr/bin/env fontforge
2 # $Id: generate.py 1902 2007-06-21 23:44:12Z apanov $
4 # script file for FontForge for TTF generation
5 # usage:
6 # mkdir generated
7 # chmod +x generate.pe
8 # ./generate.pe *.sfd
9 import fontforge, sys;
10 required_version = "20080330"
12 # font generation flags:
13 # omit-instructions => do not include TT instructions (for experimental typefaces)
14 # opentype => include OpenType tables
15 # glyph-comments => generate a 'PfEd' table and store glyph comments
16 # glyph-colors => generate a 'PfEd' table and store glyph colors
17 # old-kern => generate old fashioned kern tables.
18 # - this one is important because it generates correct kerning tables for legacy
19 # applications
20 def_gen_flags = ("opentype", "glyph-comments", "glyph-colors", "old-kern")
21 exp_gen_flags = def_gen_flags + ("omit-instructions",)
23 if fontforge.version() < required_version:
24 print ("Your version of FontForge is too old - %s or newer is required" % (required_version));
25 # FoundryName is not used in TTF generation
26 fontforge.setPrefs("FoundryName", "DejaVu");
27 # first 4 characters of TTFFoundry are used for achVendId
28 fontforge.setPrefs("TTFFoundry", "DejaVu")
29 i = 1
30 while i < len(sys.argv):
31 font=fontforge.open(sys.argv[i]);
32 gen_flags = def_gen_flags
34 # Serif Italic and Serif Bold Italic are experimental
35 if font.fontname.rfind("Serif") > -1 and font.fontname.rfind("Italic") > -1:
36 gen_flags = exp_gen_flags;
37 if font.fontname.rfind("Condensed") > -1:
38 gen_flags = exp_gen_flags;
39 if font.fontname.rfind("ExtraLight") > -1:
40 gen_flags = exp_gen_flags;
42 fontname = "generated/" + font.fontname + ".ttf";
43 font.generate(fontname,"",gen_flags);
44 font.close();
45 i += 1;