Skip to content

Commit

Permalink
fewer false positives, compare with LC too
Browse files Browse the repository at this point in the history
  • Loading branch information
mekkablue committed Sep 24, 2018
1 parent 417448b commit fca80d6
Showing 1 changed file with 51 additions and 10 deletions.
61 changes: 51 additions & 10 deletions Smallcaps/Check Small Cap Consistency.py
Expand Up @@ -10,8 +10,22 @@
thisFontMaster = thisFont.selectedFontMaster # active master

smallCapSuffix = ".sc"
listOfSmallCaps = [ g for g in thisFont.glyphs if smallCapSuffix in g.name ]
listOfCaps = [ g for g in thisFont.glyphs if g.glyphInfo and g.glyphInfo.category == "Letter" and g.glyphInfo.subCategory == "Uppercase" ]
listOfSmallCaps = [ g for g in thisFont.glyphs
if smallCapSuffix in g.name
and g.export
]
listOfCaps = [ g for g in thisFont.glyphs
if g.glyphInfo
and g.glyphInfo.category == "Letter"
and g.glyphInfo.subCategory == "Uppercase"
and g.export
]
listOfLowercase = [ g for g in thisFont.glyphs
if g.glyphInfo
and g.glyphInfo.category == "Letter"
and g.glyphInfo.subCategory == "Lowercase"
and g.export
]

# brings macro window to front and clears its log:
Glyphs.clearLog()
Expand Down Expand Up @@ -61,31 +75,58 @@ def smallcapVsCap( smallCap ):
if isALetter(smallCapName):
capName = makeCapName( smallCapName )
cap = thisFont.glyphs[ capName ]
if cap:
if cap in listOfCaps:
SCleft = turnNoGroupIntoDash(smallCap.leftKerningGroup)
SCright = turnNoGroupIntoDash(smallCap.rightKerningGroup)
CAPleft = turnNoGroupIntoDash(cap.leftKerningGroup)
CAPright = turnNoGroupIntoDash(cap.rightKerningGroup)

if CAPleft != makeCapName(SCleft):
print "-- %s: left group inconsistent (SC: %s, Cap: %s)" % ( smallCapName, SCleft, CAPleft )
print "--- %s: left group inconsistent (SC: %s, Cap: %s)" % ( smallCapName, SCleft, CAPleft )
if CAPright != makeCapName(SCright):
print "-- %s: right group inconsistent (SC: %s, Cap: %s)" % ( smallCapName, SCright, CAPright )
print "--- %s: right group inconsistent (SC: %s, Cap: %s)" % ( smallCapName, SCright, CAPright )
else:
print "-- no corresponding cap found for: %s" % smallCapName
print "-- WARNING: no corresponding cap found for: %s" % smallCapName

def smallcapVsLowercase( smallCap ):
smallCapName = smallCap.name

if isALetter(smallCapName):
posOfFirstDot = smallCapName.find(".")
if posOfFirstDot != -1:
lcName = smallCapName[:posOfFirstDot].lower()
lc = thisFont.glyphs[ lcName ]
if not lc or not lc in listOfLowercase:
print "-- WARNING: no corresponding lowercase found for: %s" % smallCapName
else:
print "--- could not process SC name: %s" % smallCapName

def capVsSmallcap( cap ):
capName = cap.name
smallCapName = "%s%s" % ( capName.lower(), smallCapSuffix )
capNameParts = cap.name.split(".")
capNameParts[0] = capNameParts[0].lower()
capName = ".".join(capNameParts)
smallCapName = "%s%s" % ( capName, smallCapSuffix )
smallCap = thisFont.glyphs[ smallCapName ]
if not smallCap or not smallCap in listOfSmallCaps:
print "-- WARNING: no corresponding small cap found for: %s" % capName

def lowercaseVsSmallcap( lc ):
lcName = lc.name
smallCapName = "%s%s" % ( lcName, smallCapSuffix )
smallCap = thisFont.glyphs[ smallCapName ]
if not smallCap:
print "-- no corresponding small cap found for: %s" % capName
if not smallCap or not smallCap in listOfSmallCaps:
print "-- WARNING: no corresponding small cap found for: %s" % lcName

print "\nChecking small caps..."
for smallcap in listOfSmallCaps:
smallcapVsCap( smallcap )
smallcapVsLowercase( smallcap )

print "\nChecking caps..."
for cap in listOfCaps:
capVsSmallcap( cap )

print "\nChecking lowercase..."
for lc in listOfLowercase:
lowercaseVsSmallcap( lc )

0 comments on commit fca80d6

Please sign in to comment.