Application defaults

RoboFont’s default settings can be edited manually using the Preferences Window or the Preferences Editor.

The application defaults can also be edited with a script:

from mojo.UI import getDefault, setDefault, preferencesChanged

# get current value
value = getDefault("glyphViewGridx")
print(f"previous value: {value}")

# set a new value
setDefault("glyphViewGridx", 40)
value = getDefault("glyphViewGridx")
print(f"new value: {value}")

# tell the app that preferences were changed

To find out how a default value is named, look at the keys in the Preferences Editor.

Extension defaults

Your own tools and extensions can also store defaults using a separate API.

Value names (keys) should be created using the reverse domain name scheme.

from mojo.extensions import getExtensionDefault, setExtensionDefault

key = 'com.mydomain.mytool.avalue'

value = getExtensionDefault(key, fallback=10)
print(f"previous value: {value}")

setExtensionDefault(key, 50)
value = getExtensionDefault(key)
print(f"new value: {value}")

  • validation?
Last edited on 02/06/2020