-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd-feature_code-to-selected_fonts.py
52 lines (38 loc) · 1.43 KB
/
add-feature_code-to-selected_fonts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from vanilla.dialogs import *
inputFonts = getFile("select masters to add feature code to", allowsMultipleSelection=True, fileTypes=["ufo"])
feaText = """languagesystem DFLT dflt;
languagesystem latn dflt;
@defaultletters = [a f g i l r y ];
@slopedroman = [a.roman f.roman g.roman i.roman l.roman r.roman y.roman];
@trueitalics = [a.italic f.italic g.italic i.italic l.italic r.italic y.italic];
feature ss01 {
featureNames {
name 3 1 0x0409 "italic a, f, g, i, l, r, y"; # Win / Unicode / English US
name 1 0 0 "italic a, f, g, i, l, r, y"; # Mac / Roman / English
};
sub @defaultletters by @trueitalics;
} ss01;
feature ss02 {
featureNames {
name 3 1 0x0409 "roman a, f, g, i, l, r, y"; # Win / Unicode / English US
name 1 0 0 "roman a, f, g, i, l, r, y"; # Mac / Roman / English
};
sub @defaultletters by @slopedroman;
} ss02;
feature locl {
script latn;
language NLD exclude_dflt;
lookup DutchIJ {
sub I J by IJ;
} DutchIJ;
} locl;
"""
def addFeatureCode(f):
f.features.text = feaText
for fontPath in inputFonts:
f = OpenFont(fontPath, showInterface=False)
addFeatureCode(f)
fontName = f.info.familyName + " " + f.info.styleName
print("feature code added to " + fontName)
f.save()
f.close()