I have a variable font to demonstrate a type historical project with a custom history axis from 0-1000. For some glyphs i have as many as 90 alternative layers.
So what exactly is it you want to count? The maximum number of alternate layers in any glyph? The combined number of alternate layers in all glyphs? A list overview of the number of layers in each glyph? The number of (or a list overview of) glyphs that have alternate layers?
count_of_alternates = 0
for g in Font.glyphs:
for l in g.layers:
if not l.isMasterLayer and l.isSpecialLayer:
if l.attributes["axisRules"]:
count_of_alternates += 1
print(count_of_alternates)
for g in Font.glyphs:
count_of_alternates = 0
for l in g.layers:
if not l.isMasterLayer and l.isSpecialLayer:
if l.attributes["axisRules"]:
count_of_alternates += 1
if count_of_alternates > 0:
print(g.name, count_of_alternates)