RoboFont’s primary scripting environment is the Scripting Window, a code editor which allows you to write, open, edit and run Python scripts.
The output of scripts which are run in the Scripting Window appear in the bottom part of the window.
Font objects out-of-the-box
When writing code in the Scripting Window, the main font objects are available out-of-the-box – so you can use
CurrentGlyph etc. directly, without the need to import them at the top of your scripts.
print("hello world!") print(CurrentFont()) print(CurrentGlyph())
>>> hello world! >>> <RFont 'RoboType Roman' at 4864862160> >>> <RGlyph 'G' ('foreground') at 4872730960>
The FontParts objects are available only to scripts which are run in the Scripting Window. If your main script calls a function from an external module, you’ll need to import the font objects explicitly from
mojo.roboFont in that file:
# getFont.py from mojo.roboFont import CurrentFont def getFont(): return CurrentFont()
from getFont import getFont print(getFont())
>>> <RFont 'RoboType Roman' at 4853462928>
Like DrawBot’s code editor, RoboFont’s Scripting Window offers special ways to interact with values in your program. When selected, some kinds of Python objects can be modified interactively by pressing the ⌘ key and using the mouse or arrow keys.
The interaction depends on the type of object:
- boolean values behave like an on/off switch
- integers behave like sliders
- pairs of numbers behave like movement in x/y space
|⌘||Turn value on/off.|
|⌘ + ⌥||+0.1||-0.1|
|⌘ + ⇧||+10||-10|
|⌘ + ⌥ + ⇧||+0.01||-0.01|
|pairs of numbers|
|⌘||x +1||x -1||y +1||y -1|
|⌘ + ⌥||x +0.1||x -0.1||y +0.1||y -0.1|
|⌘ + ⇧||x +10||x -10||y +10||y -10|
|⌘ + ⌥ + ⇧||x +0.01||x -0.01||y +0.01||y -0.01|
The Output Window is also important while developing your tools or debugging someone else’s tools: this is where print statements and tracebacks appear when a script is not running from the Scripting Window.