mojo.tools
registerFileExtension(fileExtension)
Register a file extension, and set RoboFont as the default application to open it.
IntersectGlyphWithLine(glyph, line, canHaveComponent=False, addSideBearings=False)
Intersect a glyph with a line. Returns a list of intersections.
IntersectGlyphWithLine(myGlyph, ((100, 50), (800, 50)), canHaveComponent=True, addSideBearings=True)
union(glyph, subjectContours, clipContours, roundCoordinates=None)
Draw the union between subjectContours and clipContours into the destination glyph.
union(glyph, subjectContours, clipContours, roundCoordinates=None)
Both subjectContours and clipContours can be a list of contour objects or a glyph object.
If roundCoordinates is None, the default rounding value in the Preferences will be used.
difference(glyph, subjectContours, clipContours, roundCoordinates=None)
Draw the difference between subjectContours and clipContours into the destination glyph.
difference(glyph, subjectContours, clipContours, roundCoordinates=None)
Both subjectContours and clipContours can be a list of contour objects or a glyph object.
If roundCoordinates is None, the default rounding value in the Preferences will be used.
intersection(glyph, subjectContours, clipContours, roundCoordinates=None)
Draw the intersection between subjectContours and clipContours into the destination glyph.
intersection(glyph, subjectContours, clipContours, roundCoordinates=None)
Both subjectContours and clipContours can be a list of contour objects or a glyph object.
If roundCoordinates is None, the default rounding value in the Preferences will be used.
xor(glyph, subjectContours, clipContours, roundCoordinates=None)
Draw the exclusive or (XOR) between subjectContours and clipContours into the destination glyph.
xor(glyph, subjectContours, clipContours, roundCoordinates=None)
Both subjectContours and clipContours can be a list of contour objects or a glyph object.
If roundCoordinates is None, the default rounding value in the Preferences will be used.
walkDirectoryForFile(dir, ext='.py')
Walk a given folder recursively and collect the paths of all files with a given extension ext.
roboFontUnitTest(classes=[], modules=[])
Perform a unit test inside RoboFont.
Optionally, provide a list of classes or a list of module paths to run the test on.
timerFunction(func, repeat=1000, **kwargs)
Timer a function reapeatitly.
def myFunc(foo, bar):
foo ** bar
timerFunction(myFunc, repeat=300, foo=10, bar=20)
profile(func, *args, **kwargs)
Print out a profile of a function.
def myFunc(foo, bar):
for f in range(foo):
for b in range(bar):
f * b
profile(myFunc, foo=10, bar=20)
ScriptRunner(text=None, path=None, stdout=None, stderr=None, namespace=None, checkSyntaxOnly=False, threaded=False)
Excecute a text or a python file path inside RoboFont.
Optionally provide a stdout, stderr, namespace.
Be carefull when setting threaded to True.
class BooleanGlyph()
A glyph-like object that can be used for handling boolean operations with glyph contours.
union
result = BooleanGlyph(glyph) + BooleanGlyph(glyph2)
# or
result = BooleanGlyph(glyph) | BooleanGlyph(glyph2)
difference
result = BooleanGlyph(glyph) - BooleanGlyph(glyph2)
intersection
result = BooleanGlyph(glyph) & BooleanGlyph(glyph2)
xor
result = BooleanGlyph(glyph) ^ BooleanGlyph(glyph2)