-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup-sloped-fonts.py
50 lines (32 loc) · 1.61 KB
/
setup-sloped-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
from vanilla.dialogs import *
import os
import math
from mojo.UI import AskYesNoCancel
files = getFile("Select files to print family name", allowsMultipleSelection=True, fileTypes=["ufo"])
separator = "---------------------------------------------------------------"
print(separator)
# def checkIfOkay(masterToSendToName):
# proceedWithSloping = AskYesNoCancel("This will overwrite italic info and skew all chars in " + masterToSendToName+"." +" Proceed?")
# print(proceedWithSloping)
# return proceedWithSloping
# checkIfOkay()
for file in files:
font = OpenFont(file)
print("file name: \t \t '" + os.path.split(file)[1] + "'")
print("family name: \t \t '" + font.info.familyName + "'")
print("style name: \t \t '" + font.info.styleName + "'")
font.info.italicAngle = -14.04
print("italic angle: \t \t '" + str(font.info.italicAngle) + "'")
italicSlantOffset = math.tan(font.info.italicAngle * math.pi / 180) * (font.info.xHeight * 0.5)
print("italic offset should be: \t \t '" + str(round(italicSlantOffset)) + "'")
font.lib['com.typemytype.robofont.italicSlantOffset'] = round(italicSlantOffset)
print(separator)
for g in font:
font[g.name].decompose()
for g in font:
# g.decompose()
font[g.name].skewBy(-font.info.italicAngle)
font[g.name].moveBy((italicSlantOffset, 0))
# italicSlantOffset = math.tan(f.info.italicAngle * math.pi / 180) * (f.info.xHeight * 0.5)
# # set the italic slant offset in font
# font.lib['com.typemytype.robofont.italicSlantOffset'] = round(italicSlantOffset)