-
Notifications
You must be signed in to change notification settings - Fork 4
/
ReportAnchorsOffMetrics.py
50 lines (41 loc) · 1.33 KB
/
ReportAnchorsOffMetrics.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
#MenuTitle: Report anchors off metrics
# -*- coding: utf-8 -*-
__doc__="""
Print in the console a list with the gliphs and anchors off the metrics.
This script is a modification of a mekkablue's script.
"""
Glyphs.clearLog()
Glyphs.showMacroWindow()
font = Glyphs.font
selectedLayers = font.selectedLayers
def checkAnchors (thisLayer):
try:
# Glyphs 3
metricsPosition = []
for metric in thisLayer.metrics():
metricsPosition.append(metric.position())
except:
# Glyphs 2
thisMaster = thisLayer.associatedFontMaster()
metricsPosition = [0.0, thisMaster.xHeight, thisMaster.descender, thisMaster.ascender, thisMaster.capHeight]
try:
thisMasterSmallheight = float(thisMaster.customParameters['smallCapHeight'])
metricsPosition.append(thisMasterSmallheight)
except:
pass
anchorList = []
for thisAnchor in thisLayer.anchors:
posy = thisAnchor.position.y
if posy not in metricsPosition:
anchorList.append(thisAnchor.name)
if len(anchorList) != 0:
print (thisLayer.parent.name + ":" + "%s" % ", ".join(anchorList))
return True
listOfGlyphs = []
for thisLayer in selectedLayers:
if checkAnchors (thisLayer) is True:
listOfGlyphs.append(thisLayer.parent.name)
if listOfGlyphs:
print ("\nGlyphs with off anchors in this master:\n/%s" % "/".join(listOfGlyphs))
else:
print ("\nAll anchors on metric lines.")