-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathClone Glyph.py
40 lines (35 loc) · 1021 Bytes
/
Clone Glyph.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
# RoboFont Script
# Dublicate selected glyphs and rename them to NameGlyph.ver.XXX
# XXX ( XXX - 001, 002 ... 999 )
# Alexander Lubovenko
# http://github.com/typedev
from robofab.world import CurrentFont, CurrentGlyph
from mojo.UI import *
from time import asctime
font = CurrentFont()
glyphslist = font.selection
def cloneGlyph(glyph,name=''):
if name == '':
oldname = glyph.name
else:
oldname = name
for i in range(1,1000):
oldname = oldname.replace('.ver','')
newName = '%s.ver.%03d' % (oldname, i)
if newName not in font.keys():
font.insertGlyph(glyph,newName)
font.update()
font[newName].note = asctime()
break
for i in glyphslist:
glyph = font[i]
lname = glyph.name.split('.')
if len(lname) == 1:
cloneGlyph(glyph)
else:
gnumber = lname[-1]
if gnumber.isdigit():
lname.pop()
sname='.'.join(lname)
cloneGlyph(glyph,sname)
font.update()