* I guess this commit is for ignoring fc-lang in this directory...
[dejavu.git] / dejavu-fonts / narrow.pe
blob2535fa49b1c3446224f2997944c00e00a54a9861
1 #!/usr/bin/env fontforge
2 # $Id$
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");
12 endif
13 if ($argc < 2)
14   Error("usage: scale sfds...")
15 endif
16 scale = Strtol($argv[1])
17 i = 2
18 while (i < $argc)
19   Open($argv[i], 1)
20   SelectAll()
21   Scale(scale, 100, 0, 0)
22   # Panose changes are valid only for DejaVu fonts (I guess)
23   SetPanose(3, 6)
24   new_fontname = $fontname
25   old_familyname = $familyname
26   j = Strstr(new_fontname, "-Roman")
27   if (j > -1)
28     new_fontname = Strsub(new_fontname, 0, j)
29   endif
30   j = Strstr(new_fontname, "-")
31   if (j > -1)
32     new_fontname = Strsub(new_fontname, 0, j) + "Condensed" + Strsub(new_fontname, j)
33   else
34     new_fontname = new_fontname + "Condensed"
35   endif
36   new_fullname = $fullname
37   newprefsubfamily = "Condensed"
38   j = Strstr(new_fullname, "Bold")
39   if (j == -1)
40     j = Strstr(new_fullname, "Oblique")
41   endif
42   if (j > -1)
43     new_fullname = Strsub(new_fullname, 0, j) + "Condensed " + Strsub(new_fullname, j)
44     newprefsubfamily = newprefsubfamily + " " + $weight
45   else
46     new_fullname = new_fullname + " Condensed"
47   endif
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")
56   i++
57 endloop