-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappendGroupsFromFiles.py
More file actions
42 lines (37 loc) · 1.32 KB
/
Copy pathappendGroupsFromFiles.py
File metadata and controls
42 lines (37 loc) · 1.32 KB
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
from vanilla.dialogs import getFile, putFile
def appendGroupsFromFiles (host):
paths = getFile(messageText = 'Import Groups from file', title = 'title', allowsMultipleSelection = True)
if paths:
for filepath in paths:
# groups2kill = []
# for groupname, content in host.font.groups.items():
# if groupname.startswith(host.groupPrefix):
# groups2kill.append(groupname)
# for groupname in groups2kill:
# del host.font.groups[groupname]
f = open(filepath, mode = 'r')
host.hashKernDic.setFont(host.font, host.langSet)
for line in f:
line = line.strip()
groupname = line.split('=')[0]
# print('Making group', groupname)
if len(line.split('='))==2:
glist = []
content = line.split('=')[1].split(',')
for gname in content:
if gname in host.font:
glist.append(gname)
report = host.hashKernDic.addGlyphsToGroup(groupname,glist)
# print (report)
f.close()
print('Groups imported..')
host.hashKernDic.setFont(host.font, host.langSet)
host.setFontView(animated = 'left')
host.setGroupsView(animated = 'left')
# self.w.g1.contentView.setSceneItems( # scene = self.sceneGroupContent,
# items = list(self.font.groups[self.selectedGroup]), # len(self.kern), #
# animated = 'left'
# )
def main(host):
if not host: return
appendGroupsFromFiles(host)