-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompareTwoGlyphs.py
62 lines (54 loc) · 1.66 KB
/
CompareTwoGlyphs.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
53
54
55
56
57
58
59
60
61
62
#MenuTitle: Compare Two (selected) Glyphs
# -*- coding: utf-8 -*-
__doc__="""
Will compare two selected glyphs.
"""
font = Glyphs.font
def pathsMatch(A,B):
match = "False"
looksGood = "False"
print "matching paths of %s and %s" % (A[0].parent.name,B[0].parent.name)
for layerIndex in range(len(A)):
if len(A[layerIndex].paths) == 0:
for component in A[layerIndex].components:
if component.componentName == B[layerIndex].parent.name:
looksGood = True
else:
return False
elif len(B[layerIndex].paths) == 0:
for component in B[layerIndex].components:
if component.componentName == A[layerIndex].parent.name:
looksGood = True
else:
return False
else:
if A[layerIndex].compareString() == B[layerIndex].compareString():
looksGood = True
else: looksGood = False
#iterate trought paths and nodes here is propably more reliable
match = looksGood
return match
def glyphsComparation(A,B):
match = False
looksGood = False
if len(A.layers) == len(B.layers):
for i in range(len(A.layers)):
if A.layers[i].name == B.layers[i].name:
looksGood = pathsMatch(A.layers,B.layers)
else:
looksGood = False
break
match = looksGood
return match
countSelection = len(font.selection)
if countSelection <= 1:
print "At least two glyphs need to be selected for script to run."
else:
print "Working with %s \n" % font.familyName
GlyphA = font.selection[0]
GlyphB = font.selection[1]
if countSelection > 2: print "Too many selected glyphs. Just first two will be compared."
match = glyphsComparation(GlyphA,GlyphB)
print match
if match == True: print "are same"
else: print "not same"