Skip to content

Instantly share code, notes, and snippets.

@LettError
Created October 22, 2021 10:13
Show Gist options
  • Save LettError/53efd29382f232a5051ace8fac422a96 to your computer and use it in GitHub Desktop.
Save LettError/53efd29382f232a5051ace8fac422a96 to your computer and use it in GitHub Desktop.
Generate instances from a designspace or superpolator document. This will work in RF3 and RF4. Note that if you have complex substitutions as Superpolator allowed, these can not always be converted variable font style rules.
import ufoProcessor
from mojo.UI import PutFile, GetFile
import os
"""
Open a .sp3 or .designspace document and generate the instances.
No reporting, no editing, no debugging.
"""
def convertSuperpolatorToDesignSpace(path):
# this a superpolator path and needs to be converted first
newPathName = path.replace(".sp3", "_converted.designspace")
newPathName = PutFile(message="Save this Superpolator document as Designspace:", fileName=os.path.basename(newPathName))
if newPathName:
ufoProcessor.sp3.sp3_to_designspace(path, newPathName)
return newPathName
def generateInstances():
path = GetFile("Open a Desingspace or Superpolator file to generate:", fileTypes=['sp3', 'designspace'])
if path is None:
return
if os.path.splitext(path)[-1] == ".sp3":
path = convertSuperpolatorToDesignSpace(path)
if path is None:
return
ufoProcessor.build(path)
generateInstances()
print('done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment