Debian Codegraph @

scripts/FD-Generator.py

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 import os
2 import sys
3 import fontforge
4
5
6
7 PATH = os.path.abspath(os.getcwd()) + "\\" +sys.argv[1]
8
9 os.chdir(PATH)
10 for file in os.listdir():
11 font = fontforge.open(file)
12 filename = os.path.splitext(file)[0]
13 FNameStyle, FWeight = filename.rsplit('-',1)
14 # copy Farsi digits (0 1 2 3 4 5 6 7 8 9) to Latin digits
15 mapDigits = {
16 "uni06F0": "zero",
17 "uni0661": "one",
18 "uni0662": "two",
19 "uni0663": "three",
20 "uni06F4": "four",
21 "uni06F5": "five",
22 "uni06F6": "six",
23 "uni0667": "seven",
24 "uni0668": "eight",
25 "uni0669": "nine",
26 }
27 for index in mapDigits:
28 font.selection.select(index)
29 font.copyReference()
30 font.selection.select(mapDigits[index])
31 font.paste()
32 font.selection.none()
33 font.fontname = FNameStyle + "-FD-" + FWeight
34 font.familyname = FNameStyle + "-FD " + FWeight
35 font.fullname = FNameStyle + "-FD " + FWeight
36 PreferredFamily = FNameStyle + "-FD "
37 PreferredStyles = FNameStyle + "-FD-" + FWeight
38 font.appendSFNTName('English (US)' , 'Preferred Family' , PreferredFamily)
39 font.appendSFNTName('English (US)' , 'Preferred Styles' , PreferredStyles)
40 # font.removeLookup("'ss07' Style Set 7 lookup 24")
41 # font.removeLookup("'ss08' Style Set 8 lookup 25")
42 # font.removeLookup("'ss09' Style Set 9 lookup 26")
43 # font.removeLookup("'ss10' Style Set 10 lookup 27")
44 # font.removeLookup("'ss11' Style Set 11 lookup 28")
45 font.generate(FNameStyle + "-FD-" + FWeight + ".ttf")