1 #!/usr/bin/env fontforge
4 # script file for FontForge for font narrowing
5 # usage: fontforge -script narrow.pe scale *.sfd
6 # created files have suffix .narrow
8 # DejaVu Condensed have scale 90
10 if ($version < "20050209")
11 Error("Your version of FontForge transforms glyphs w/o content");
14 Error("usage: scale sfds...")
16 scale = Strtol($argv[1])
21 Scale(scale, 100, 0, 0)
22 # Panose changes are valid only for DejaVu fonts (I guess)
24 new_fontname = $fontname
25 old_familyname = $familyname
26 j = Strstr(new_fontname, "-Roman")
28 new_fontname = Strsub(new_fontname, 0, j)
30 j = Strstr(new_fontname, "-")
32 new_fontname = Strsub(new_fontname, 0, j) + "Condensed" + Strsub(new_fontname, j)
34 new_fontname = new_fontname + "Condensed"
36 new_fullname = $fullname
37 newprefsubfamily = "Condensed"
38 j = Strstr(new_fullname, "Bold")
40 j = Strstr(new_fullname, "Oblique")
43 new_fullname = Strsub(new_fullname, 0, j) + "Condensed " + Strsub(new_fullname, j)
44 newprefsubfamily = newprefsubfamily + " " + $weight
46 new_fullname = new_fullname + " Condensed"
48 new_familyname = $familyname + " Condensed"
49 SetFontNames(new_fontname, new_familyname, new_fullname)
50 SetOS2Value("Width",4)
51 SetTTFName(1033, 2, $weight) # ttf_subfamily
52 SetTTFName(1033, 3, new_fullname) # ttf_uniqueid
53 SetTTFName(1033, 16, old_familyname) # ttf_preffamilyname
54 SetTTFName(1033, 17, newprefsubfamily) # ttf_prefmodifiers
55 Save($argv[i] + ".narrow")