API

RoboFont is highly extendable in any direction from subclassing existing classes to adding new features and functionality in a new tool.

There are many levels how to interact with RoboFont and how to handle various parts: font data, UI, user interaction, ...

Scripts

A tiny script using roboFab to add actions/features/functionalities to a menu item or key stroke.

# convert to monospace font
from robofab.interface.all.dialogs import AskString

value = AskString("Monospace width:")

try:
    value = int(value)
except ValueError:
    value = None

if value:
    font = CurrentFont()
    for glyph in font:
        glyph.width = value

Save this script in the default script folder to extend RoboFont Extensions menu. See the preferences to add a short cut to a specific script.

Observers & Tools

RoboFont is being build up around a core that is just sending out notifications. A script can subscribe to one or more notifications and perform an action based on the send notification.

There are three kinds of notifications inside RoboFont

  • Native Cocoa Notifications
    When the app opens, closes, hides; when a window resizes; when a text field changed, ...
  • Font Data Notifications
    Font data notifications are being send out when the font data is being changed. Those notifications are already natively in defcon and extended in RoboFont.
  • RoboFont Notifications
    RoboFont notifications are being send from several places: Glyph Editor, Space Centers, based on users interaction related to adjusting, changing font data.

There are two systems build in to subscribe to notifications:

  • As an Observer
    A class, the observer will subscribe to a specific notification. When the notification is being send it will receive a callback with additional info and objects related to the notification.
  • As a Tool
    A tools receives all the notifications RoboFont has, but it only can be activated when an user selected the tool from the toolbar in the glyph editor.