-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck-anchors-for-consistency-in-all-open-fonts.py
39 lines (33 loc) · 2 KB
/
check-anchors-for-consistency-in-all-open-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
################################################################################################
##################### Check anchors for consistency across all open fonts. #####################
################################################################################################
g = CurrentGlyph()
for font in AllFonts():
for g in font:
for anchor in g.anchors:
# for each font in all open fonts
for otherFont in AllFonts():
if g.name in otherFont:
# make list of anchor names
anchorsInGlyph = []
# add anchor names to that list
for eachAnchor in otherFont[g.name].anchors:
anchorsInGlyph.append(eachAnchor.name)
# check that the current anchor name matches an anchor name in the list
if anchor.name not in anchorsInGlyph:
print("anchor '" + anchor.name + "' from '" + font.info.styleName + "' in glyph '" + g.name + "'")
print("…is not present in '" + otherFont.info.styleName + "' in glyph '" + g.name + "'")
print("***************\n")
## Check that no anchors are duplicates within the same glyph
for font in AllFonts():
for glyph in font:
if len(glyph.anchors) > 1:
anchorsInGlyph = []
for eachAnchor in glyph.anchors:
anchorsInGlyph.append(eachAnchor.name)
# check if there are duplicates in the list by checking the list against a set of the same items
if len(anchorsInGlyph) != len(set(anchorsInGlyph)):
print(font.info.styleName + " |||| Glyph '" + glyph.name + "' contains duplicates in its anchors: \n" + str(anchorsInGlyph))
print("✨🌟✴️ delete the duplicates to make your world a better place ✴️🌟✨")
print("***************\n")
print("done")