MutatorMath started out with its own reader and writer for designspaces. Since then the use of designspace has broadened and it would be useful to have a reader and writer that are independent of a specific system.
The DesignSpaceDocument object can read and write .designspace data. It imports the axes, sources and instances to very basic **descriptor** objects that store the data in attributes. Data is added to the document by creating such descriptor objects, filling them with data and then adding them to the document. This makes it easy to integrate this object in different contexts.
* If the `axes` element is available in the document then all locations will check their dimensions against the defined axes. If a location uses an axis that is not defined it will be ignored.
* If there are no `axes` in the document, locations will accept all axis names, so that we can..
* Use `doc.checkAxes()` to reconstruct axes definitions based on the `source.location` values. If you save the document the axes will be there.
### Default font
* The source with the `copyInfo` flag indicates this is the default font.
* In mutatorMath the default font is selected automatically. A warning is printed if the mutatorMath default selection differs from the one set by `copyInfo`. But the `copyInfo` source will be used.
* If no source has a `copyInfo` flag, mutatorMath will be used to select one. This source gets its `copyInfo` flag set. If you save the document this flag will be set.
* Use `doc.checkDefault()` to set the default font.
*`copyInfo` bool. Indicates if the non-interpolating font.info needs to be copied to the instances. Also indicates this source is expected to be the default font. MutatorMath + Varlib
*`name`: string. Unique identifier name of the instance, used to identify it if it needs to be referenced from elsewhere in the document.
*`location`: dict. Axis values for this source. MutatorMath + Varlib.
*`familyName`: string. Family name of this instance. MutatorMath + Varlib.
*`styleName`: string. Style name of this source. MutatorMath + Varlib.
*`postScriptFontName`: string. Postscript FontName for this instance. MutatorMath.
*`styleMapFamilyName`: string. StyleMap FamilyName for this instance. MutatorMath.
*`styleMapStyleName`: string. StyleMap StyleName for this instance. MutatorMath.
*`glyphs`: dict for special master definitions for glyphs. If glyphs need special masters (to record the results of executed rules for example). MutatorMath.
*`kerning`: bool. Indicates if this instance needs its kerning calculated. MutatorMath.
*`info`: bool. Indicated if this instance needs the interpolating font.info calculated.
*`tag`: string. Four letter tag for this axis. Some might be registered at the OpenType specification.
*`name`: string. Name of the axis as it is used in the location dicts. MutatorMath + Varlib.
*`labelNames`: dict. When defining a non-registered axis, it will be necessary to define user-facing readable names for the axis. Keyed by xml:lang code. Varlib.
*`minimum`: number. The minimum value for this axis. MutatorMath + Varlib.
*`maximum`: number. The maximum value for this axis. MutatorMath + Varlib.
*`default`: number. The default value for this axis, i.e. when a new location is created, this is the value this axis will get. MutatorMath + Varlib.
*`map`: list of input / output values that can describe a warp of user space to designspace coordinates. If no map values are present, it is assumed it is [(minimum, minimum), (maximum, maximum)]. Varlib.
The DesignSpaceDocument can take subclassed Reader and Writer objects. This allows you to work with your own descriptors. You could subclass the descriptors. But as long as they have the basic attributes the descriptor does not need to be a subclass.
* Defines a single font that contributes to the designspace.
* Child element of `sources`
### Attributes
*`familyname`: optional, string. The family name of the source font. While this could be extracted from the font data itself, it can be more efficient to add it here.
*`stylename`: optional, string. The style name of the source font.
*`name`: required, string. A unique name that can be used to identify this font if it needs to be referenced elsewhere.
*`filename`: required, string. A path to the source file, relative to the root path of this document. The path can be at the same level as the document or lower.
* Defines a single font that can be calculated with the designspace.
* Child element of `instances`
* For use in Varlib the instance element really only needs the names and the location. The `glyphs` element is not required.
* MutatorMath uses the `glyphs` element to describe how certain glyphs need different masters, mainly to describe the effects of conditional rules in Superpolator.
### Attributes
*`familyname`: required, string. The family name of the instance font. Corresponds with `font.info.familyName`
*`stylename`: required, string. The style name of the instance font. Corresponds with `font.info.styleName`
*`name`: required, string. A unique name that can be used to identify this font if it needs to be referenced elsewhere.
*`filename`: string. Required for MutatorMath. A path to the instance file, relative to the root path of this document. The path can be at the same level as the document or lower.
*`postscriptfontname`: string. Optional for MutatorMath. Corresponds with `font.info.postscriptFontName`
*`stylemapfamilyname`: string. Optional for MutatorMath. Corresponds with `styleMapFamilyName`
*`stylemapstylename `: string. Optional for MutatorMath. Corresponds with `styleMapStyleName`