Skip to content

Instantly share code, notes, and snippets.

@LettError
Created September 6, 2019 19:45
Show Gist options
  • Save LettError/7cd3cab97b7081e2380ce86acf450987 to your computer and use it in GitHub Desktop.
Save LettError/7cd3cab97b7081e2380ce86acf450987 to your computer and use it in GitHub Desktop.
RoboFont: temporary designspace + designspaceChecker to report on glyph compatibility issues.
"""
test all open fonts on compatibility
create temp designspace file
align all fonts on a temp axis
order does not matter
run designspaceProblems
present the data somehow
Result:
comparing:
geometryMaster2.ufo
geometryMaster1.ufo
geometryMaster1_no_kerning.ufo
geometryMaster3.ufo
glyphs:
broken_component
different components in glyph
different number of contours in glyph
incompatible constructions for glyph
extra.glyph.for.neutral
default glyph is empty
glyphFive
incompatible constructions for glyph
glyph_with_many_contours
different anchors in glyph
different number of contours in glyph
incompatible constructions for glyph
narrow.component
different components in glyph
incompatible constructions for glyph
"""
import os
import designspaceProblems
from designspaceProblems import DesignSpaceChecker
from designspaceProblems.problems import DesignSpaceProblem
from ufoProcessor import DesignSpaceProcessor, getUFOVersion, AxisDescriptor, SourceDescriptor
doc = DesignSpaceProcessor()
a1 = AxisDescriptor()
a1.name = "snap"
a1.minimum = 0
a1.maximum = 1000
a1.default = 0
a1.tag = 'snap'
masters = []
print('comparing:')
for i, f in enumerate(AllFonts()):
print('\t', os.path.basename(f.path))
s1 = SourceDescriptor()
s1.location = dict(snap=i*100)
s1.path = os.path.join(f.path)
doc.addSource(s1)
a1.maximum += 100
doc.addAxis(a1)
#tp = "prrr.designspace"
#doc.write(tp)
dc = DesignSpaceChecker(doc)
dc.checkEverything()
print('glyphs:')
glyphs = {}
for p in dc.problems:
if p.category == 4:
if not p.data['glyphName'] in glyphs:
glyphs[p.data['glyphName']] = []
glyphs[p.data['glyphName']].append('\t\t{}'.format(p.getDescription()[1]))
problemGlyphs = list(glyphs.keys())
problemGlyphs.sort()
for name in problemGlyphs:
print('\t{}'.format(name))
for desc in glyphs[name]:
print(desc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment