A .designspace file is an XML-based description of a multi-dimensional interpolation space.

Creating designspace files with DesignSpaceEditor

DesignSpaceEditor is a RoboFont extension which provides a simple interface to create and edit designspace data – without any interactive preview, map etc. DesignSpaceEditor is open-source and can be installed with Mechanic 2. If you want to navigate and visualize your design space you can use Skateboard for RoboFont.

  1. Design your designspace using DesignSpaceEditor’s interface.
  2. Click on the Save button to save the data to a .designspace file.

Creating designspace files with designSpaceLib

Designspace files can also be created with code: FontToolsAn open-source library for manipulating font files with Python. supports reading & writing .designspace files using the designSpaceLib.

DesignspaceLib started as DesignSpaceDocument, a separate library, and was later incorporated into fontTools.

The script below will create a .designspace file for MutatorSans. To try it out, save it in the MutatorSans folder next to the UFOs.

import os
from fontTools.designspaceLib import DesignSpaceDocument

root = os.getcwd()
doc = DesignSpaceDocument()

familyName = "MutatorMathTest"

#------
# axes
#------

doc.addAxisDescriptor(
    maximum=1000,
    minimum=0,
    default=0,
    name="width",
    tag="wdth",
)


doc.addAxisDescriptor(
    maximum = 1000,
    minimum = 0,
    default = 0,
    name = "weight",
    tag = "wght",
)

#---------
# masters
#---------

doc.addSourceDescriptor(
    path="MutatorSansLightCondensed.ufo",
    name="master.MutatorMathTest.LightCondensed.0",
    familyName=familyName,
    styleName="LightCondensed",
    location=dict(weight=0, width=0),
    copyLib=True,
    copyInfo=True,
    copyGroups=True,
    copyFeatures=True,
)

doc.addSourceDescriptor(
    path="MutatorSansBoldCondensed.ufo",
    name="master.MutatorMathTest.BoldCondensed.1",
    familyName=familyName,
    styleName="BoldCondensed",
    location=dict(weight=1000, width=0),
)

doc.addSourceDescriptor(
    path="MutatorSansLightWide.ufo",
    name="master.MutatorMathTest.LightWide.2",
    familyName=familyName,
    styleName="LightWide",
    location=dict(weight=0, width=1000),
)

doc.addSourceDescriptor(
    path="MutatorSansBoldWide.ufo",
    name="master.MutatorMathTest.BoldWide.3",
    familyName=familyName,
    styleName="BoldWide",
    location=dict(weight=1000, width=1000),
)

#-----------
# instances
#-----------

doc.addInstanceDescriptor(
    name='instance_LightCondensed',
    familyName=familyName,
    styleName="Medium",
    path=os.path.join(root, "instances", "MutatorSansTest-Medium.ufo"),
    location=dict(weight=500, width=327),
    kerning=True,
    info=True,
)

#-------
# rules
#-------

doc.addRuleDescriptor(
    name='fold_I_serifs',
    conditionSets = [[{'name': "width", 'minimum': 0, 'maximum': 328 }]],
    subs = [("I", "I.narrow"),],
)

doc.addRuleDescriptor(
    name='fold_S_terminals',
    conditionSets = [[
        {'name': "width",  'minimum': 0, 'maximum': 1000 },
        {'name': "weight", 'minimum': 0, 'maximum': 500  },
    ]],
    subs = [("S", "S.closed")]
)

#--------
# saving
#--------

path = os.path.join(root, "MutatorSans_test_.designspace")
doc.write(path)

Last edited on 01/09/2021