.. _document-xml-structure:
**********************
Document XML structure
**********************
.. sectnum::
:start: 2
.. Note: impossible with Sphinx to avoid numbering the document title
.. See this issue: https://github.com/sphinx-doc/sphinx/issues/4628
.. contents:: Table of contents (levels match the document structure)
:local:
========
Overview
========
.. code:: xml
==================
```` element
==================
The ```` element contains one or more ```` elements.
.. rubric:: Attributes
- ``elidedfallbackname``: optional, string.
STAT Style Attributes Header field ``elidedFallbackNameID``.
See: `OTSpec STAT Style Attributes Header
`_
.. versionadded:: 5.0
```` element
==================
- Define a single axis
- Child element of ``axes``
- The axis can be either continuous (as in version 4.0) or discrete (new in version 5.0).
Discrete axes have a list of values instead of a range minimum and maximum.
.. rubric:: Attributes
- ``name``: required, string. Name of the axis that is used in the
location elements.
- ``tag``: required, string, 4 letters. Some axis tags are registered
in the OpenType Specification.
- ``default``: required, number. The default value for this axis, in user space coordinates.
- ``hidden``: optional, 0 or 1. Records whether this axis needs to be
hidden in interfaces.
For a continuous axis:
- ``minimum``: required, number. The minimum value for this axis, in user space coordinates.
- ``maximum``: required, number. The maximum value for this axis, in user space coordinates.
For a discrete axis:
- ``values``: required, space-separated numbers. The exhaustive list of possible values along this axis.
.. versionadded:: 5.0
.. rubric:: Example
.. code:: xml
.. _labelname:
```` element (axis)
------------------------------
- Defines a human readable name for UI use.
- Optional for non-registered axis names.
- Can be localised with ``xml:lang``
- Child element of ```` or ````
.. rubric:: Attributes
- ``xml:lang``: required, string. `XML language
definition `__
.. rubric:: Value
- The natural language name of this axis or STAT label.
.. rubric:: Example
.. code:: xml
قطر
Wéíght
```` element
-----------------
- Defines a single node in a series of input value (user space coordinate)
to output value (designspace coordinate) pairs.
- Together these values transform the designspace.
- Child of ```` element.
.. rubric:: Example
.. code:: xml
```` element (axis)
---------------------------
The ```` element contains one or more ```` elements, and can
indicate this axis' STAT ordering.
.. versionadded:: 5.0
.. rubric:: Attributes
- ``ordering``: optional, int, default: natural position of this axis in the list
of axes. STAT table field ``axisOrdering`` for this axis.
See: `OTSpec STAT Axis Record `_
```` element (axis)
..........................
- Define STAT format 1, 2, 3 labels for the locations on this axis.
- The axis can have several child ```` elements, one for each STAT entry.
- This ```` element can have several ```` child elements,
to provide translations of its ``name`` attribute.
.. versionadded:: 5.0
.. rubric:: Attributes
- ``name``: required, string. the name of this label
- ``elidable``: optional, boolean, default: false. STAT flag ``ELIDABLE_AXIS_VALUE_NAME``.
- ``oldersibling``: optional, boolean, default: false. STAT flag ``OLDER_SIBLING_FONT_ATTRIBUTE``.
See: `OTSpec STAT Flags `_
Depending on the intended target STAT format, use a combination of the following
field, all in user coordinates. Check the following table for the format
correspondences.
- ``uservalue``: (required) STAT field ``value`` (format 1, 3) or ``nominalValue`` (format 2).
- ``userminimum``: STAT field ``rangeMinValue`` (format 2).
- ``usermaximum``: STAT field ``rangeMaxValue`` (format 2).
- ``linkeduservalue``: STAT field ``linkedValue`` (format 3).
=========== ========= =========== =========== ===============
STAT Format uservalue userminimum usermaximum linkeduservalue
=========== ========= =========== =========== ===============
1 ✅ ❌ ❌ ❌
2 ✅ ✅ ✅ ❌
3 ✅ ❌ ❌ ✅
=========== ========= =========== =========== ===============
.. rubric:: Example
.. code:: xml
Extraleicht
Extra léger
```` element (axis STAT label)
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
User-facing translations of this STAT label. Keyed by ``xml:lang`` code.
.. versionadded:: 5.0
Same attribute and value as :ref:`the axis' \ element `.
Example of all axis elements together
=====================================
.. code:: xml
قطر
Wéíght
Extraleicht
Extra léger
```` element
======================
- Define an axis mappings group.
- Child element of ``axes``
.. rubric:: Attributes
- ``description``: optional, string. the description of this mappings group
.. versionadded:: 5.2
```` element
---------------------
- Defines an axis mapping.
- Child element of ````
.. rubric:: Attributes
- ``description``: optional, string. the description of this mapping
.. versionadded:: 5.2
`` `` element
...................
- Defines the input location of an axis mapping.
- Child element of ````
- Contains one or more ```` elements with designspace locations.
.. versionadded:: 5.1
```` element
....................
- Defines the output location of an axis mapping.
- Child element of ````
- Contains one or more ```` elements with designspace locations.
.. versionadded:: 5.1
Example of all mappings elements together
=========================================
.. code:: xml
================================
```` element (top-level)
================================
The ```` element contains one or more ```` elements.
.. versionadded:: 5.0
```` element (top-level)
===============================
- Define STAT format 4 labels for a free-standing location.
- The designspace can have several top-level ```` elements, one for each
STAT format 4 entry.
- This ```` element must have a child ```` element that
represents the location to which the label applies.
- This ```` element may have several child ```` elements to
provide translations of its ``name`` attribute.
See: `OTSpec STAT Axis value table, format 4 `_
.. versionadded:: 5.0
.. rubric:: Attributes
- ``name``: required, string. the name of this label
- ``elidable``: optional, boolean, default: false. STAT flag ``ELIDABLE_AXIS_VALUE_NAME``.
- ``oldersibling``: optional, boolean, default: false. STAT flag ``OLDER_SIBLING_FONT_ATTRIBUTE``.
See: `OTSpec STAT Flags `_
.. _location:
```` element (top-level STAT label)
---------------------------------------------
- Defines a coordinate in either user or design space.
- Encodes a dictionary of ``{ axisname: axisvalue }``.
- Also used in ````, ```` and ```` elements.
- This ```` element must have one or more child ````
elements.
.. _dimension:
```` element
.......................
- Child element of ````, ``input``, or ``output`` elements
.. rubric:: Attributes
- ``name``: required, string. Name of the axis.
Depending on whether you're representing a location in user or design coordinates,
provide one of the attributes below.
For user-space coordinates:
- ``uservalue``: required, number. The value on this axis in user coordinates.
.. versionadded:: 5.0
For design-space coordinates:
- ``xvalue``: required, number. The value on this axis in design coordinates.
- ``yvalue``: optional, number. Separate value for anisotropic interpolations.
.. rubric:: Example
.. code:: xml
```` element (top-level STAT label)
----------------------------------------------
User-facing translations of this STAT label. Keyed by ``xml:lang`` code.
.. versionadded:: 5.0
Same attribute and value as :ref:`the axis' \ element `.
.. _rules-element:
===================
```` element
===================
The ```` element contains one or more ```` elements.
The rules are evaluated in this order.
Rules describe designspace areas in which one glyph should be replaced by another.
A rule has a name and a number of conditionsets. The rule also contains a list of
glyphname pairs: the glyphs that need to be substituted. For a rule to be triggered
**only one** of the conditionsets needs to be true, ``OR``. Within a conditionset
**all** conditions need to be true, ``AND``.
.. rubric:: Attributes
- ``processing``: flag, optional. Valid values are [``first``, ``last``]. This
flag indicates whether the substitution rules should be applied before or after
other glyph substitution features.
- If no ``processing`` attribute is given, interpret as ``first``, and put
the substitution rule in the ``rvrn`` feature.
- If ``processing`` is ``last``, put it in ``rclt``.
- The default is ``first``. For new projects, you probably want ``last``.
See the following issues for more information:
`fontTools#1371 `__
`fontTools#2050 `__
- If you want to use a different feature(s) altogether, e.g. ``calt``,
use the lib key ``com.github.fonttools.varLib.featureVarsFeatureTag``.
.. code:: xml
com.github.fonttools.varLib.featureVarsFeatureTag
calt
This can also take a comma-separated list of feature tags, e.g. ``salt,ss01``,
if you wish the same rules to be applied with several features.
```` element
==================
- Defines a named rule.
- Each ```` element contains one or more ```` elements.
- **Only one** ```` needs to be true to trigger the rule (logical OR). An empty condition set is considered to be true, as in, the rule will be always-on.
- **All** conditions in a ```` must be true to make the ```` true. (logical AND)
- For backwards compatibility a ```` can contain ```` elements outside of a conditionset. These are then understood to be part of a single, implied, ````. Note: these conditions should be written wrapped in a conditionset.
- A rule element needs to contain one or more ```` elements in order to be compiled to a variable font.
- Rules without sub elements should be ignored when compiling a font.
- For authoring tools it might be necessary to save designspace files without ```` elements just because the work is incomplete.
.. rubric:: Attributes
- ``name``: optional, string. A unique name that can be used to
identify this rule if it needs to be referenced elsewhere. The name
is not important for compiling variable fonts.
```` element
--------------------------
- Child element of ````
- Contains zero or more ```` elements.
```` element
.......................
- Child element of ````
- Between the ``minimum`` and ``maximum`` this condition is ``True``.
- ``minimum`` and ``maximum`` are in designspace coordinates.
- If ``minimum`` is not available, assume it is ``axis.minimum``, mapped to designspace coordinates.
- If ``maximum`` is not available, assume it is ``axis.maximum``, mapped to designspace coordinates.
- The condition must contain at least a minimum or maximum or both.
.. rubric:: Attributes
- ``name``: string, required. Must match one of the defined ``axis``
name attributes.
- ``minimum``: number, required*. The low value, in design coordinates.
- ``maximum``: number, required*. The high value, in design coordinates.
.. If you want to specify the condition limits in design coordinates:
.. If you want to specify the condition limits in user coordinates:
.. - ``userminimum``: number, required*. The low value, in design coordinates.
.. - ``usermaximum``: number, required*. The high value, in design coordinates.
```` element
-----------------
- Child element of ````.
- Defines which glyph to replace when the rule evaluates to **True**.
- The ```` element contains a pair of glyphnames. The ``name`` attribute is the glyph that should be visible when the rule evaluates to **False**. The ``with`` attribute is the glyph that should be visible when the rule evaluates to **True**.
.. rubric:: Attributes
- ``name``: string, required. The name of the glyph this rule looks
for.
- ``with``: string, required. The name of the glyph it is replaced
with.
.. rubric:: Example
Example with an implied ````. Here the conditions are not
contained in a conditionset.
.. code:: xml
Example with ````. All conditions in a conditionset must be true.
.. code:: xml
=====================
```` element
=====================
The ```` element contains one or more ```` elements.
```` element
====================
- Defines a single font or layer that contributes to the designspace.
- Child element of ````
- Location in designspace coordinates.
.. rubric:: 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``: optional, 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.
- ``layer``: optional, string. The name of the layer in the source file.
If no layer attribute is given assume the foreground layer should be used.
```` element: localised names for sources
-----------------------------------------------------
Localised family names for sources can be included with this ````
element with an ``xml:lang`` attribute:
`XML language definition `__
.. versionadded:: 5.0
.. rubric:: Example
.. code:: xml
Montserrat
モンセラート
```` element (source)
-------------------------------
Defines the coordinates of this source in the design space.
.. seealso:: :ref:`Full documentation of the \ element `
```` element (source)
................................
.. seealso:: :ref:`Full documentation of the \ element `
```` element (source)
--------------------------
- Example: `` ``
- Child element of ````
- Defines if the instances can inherit the data in the lib of this source.
- MutatorMath only.
.. deprecated:: 5.0
.. note::
Don't confuse with other ```` elements which allow storing
arbitrary data. Sources don't have such a ```` because usually the
backing UFO file has one itself.
```` element
------------------
- Example: `` ``
- Child element of ````
- Defines if the instances can inherit the non-interpolating font info
from this source.
- MutatorMath only.
.. deprecated:: 5.0
```` element
----------------------
- Example: `` ``
- Defines if the instances can inherit opentype feature text from this
source.
- Child element of ````
- MutatorMath only.
.. deprecated:: 5.0
```` element (source)
----------------------------
- Example: `` ``
- In a ```` element this states if a glyph is to be excluded from
the calculation.
- MutatorMath only.
.. rubric:: Attributes
- ``mute``: optional attribute, number 1 or 0. Indicate if this glyph
should be ignored as a master.
.. note::
Do not confuse with the ```` element in instances, which achieves
something different.
.. _kerning_source:
```` element (source)
------------------------------
- Example: `` ``
- Can appear in ```` as well as in ```` elements.
- MutatorMath only.
.. rubric:: Attributes
- ``mute``: required attribute, number 1 or 0. Indicate if the kerning
data from this source is to be excluded from the calculation.
- If the kerning element is not present, assume ``mute=0``, yes,
include the kerning of this source in the calculation.
.. rubric:: Example
.. code:: xml
============================
```` element
============================
The ```` element contains one or more ```` elements.
.. versionadded:: 5.0
```` element
===========================
- Child of ````
- Describe a variable font that can be built from an interpolating subset of
the design space.
- The document may have zero to many variable fonts.
- If no variable fonts are defined, and all the axes are continuous, then we
assume, as in version 4 of the format, that the whole document describes
one variable font covering the whole space.
- Each variable font covers a subset of the whole designspace, defined using
```` elements.
- Each variable font can have custom associated data using a ```` element.
.. versionadded:: 5.0
.. rubric:: Attributes
- ``name``: string, required. Each variable font has a name, that can be
used by build tools to refer to the font that gets built from this element.
- ``filename``: string, optional. This filename will be used by tools to decide
where to store the built font on the disk. If not given, a filename can be
computed from the ``name``. The filename may include an extension (e.g.
`.ttf`) and the build tools can replace that extension with another (e.g.
`.otf` or `.woff2`) as needed.
.. rubric:: Example
.. code:: xml
```` element
--------------------------
- Child of ````
- Defines the portion of the design space that this variable font covers.
- Each axis that you want to include in the VF needs to be mentioned here.
- Not mentioning an axis is equivalent to slicing the space at the default
value of that axis.
.. versionadded:: 5.0
```` element
.........................
- Child of ````
- Defines the subset of one axis, by ``name=""``, that the variable font covers.
- If this axis is continuous, the VF can either cover:
1. the whole axis
.. code:: xml
2. a sub-range of the full axis
.. code:: xml
3. a specific value along that axis; then the axis is not functional in the VF
but the design space is sliced at the given location. *Note:* While valid to have a
specific value that doesn’t have a matching ```` at that value, currently there
isn’t an implentation that supports this. See `this fontmake issue
`_.
.. code:: xml
- If this axis is discrete, then only the third option above is possible:
give one value along the axis.
.. code:: xml
.. versionadded:: 5.0
.. rubric:: Attributes
- ``name``: required, string. Name of the axis to subset.
When defining a range:
- ``userminimum``: optional, number.
Lower end of the range, in user coordinates.
If not mentioned, assume the axis's minimum.
- ``usermaximum``: optional, number.
Upper end of the range, in user coordinates.
If not mentioned, assume the axis's maximum.
- ``userdefault``: optional, number.
New default value of subset axis, in user coordinates.
If not mentioned, assume the axis's default.
If the axis's default falls outside of the subset range, then the new default
will be the extremum that is closest to the full axis's default.
When defining a single value:
- ``uservalue``: required, number.
Single value, in user coordinates, at which to snapshot the design space
while building this VF.
```` element (variable font)
---------------------------------
Arbitrary data about this variable font.
.. versionadded:: 5.0
.. seealso:: :ref:`lib`
Here is an example of using the ``public.fontInfo`` lib key to gain more granular
control over the font info of a variable font, in this case setting some names to
reflect the fact that this is a Narrow variable font subset from the larger designspace.
This lib key allows font info in variable fonts to be more specific than the font
info of the sources.
.. rubric:: Example
.. code:: xml
public.fontInfo
familyName
My Font Narrow VF
styleName
Regular
postscriptFontName
MyFontNarrVF-Regular
trademark
My Font Narrow VF is a registered trademark...
Instances included in the variable font
---------------------------------------
.. figure:: v5_variable_fonts_vs_instances.png
:width: 650px
:alt: A designspace version 5 lists many instances and variable fonts. Each
variable font gets in its fvar table whichever instances fall within
the bounds of the variable font's subset axes.
Illustration of instances included in a variable font.
=======================
```` element
=======================
The ```` element contains one or more ```` elements.
```` element
======================
- Defines a single font that can be calculated with the designspace.
- Child element of ````
- For use in varLib the instance element really only needs the names
and the location. The ```` element is not required.
- MutatorMath uses the ```` element to describe how certain
glyphs need different masters, mainly to describe the effects of
conditional rules in Superpolator.
- Location in designspace coordinates.
.. rubric:: 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``
- ``location``: string. Optional. Describes the location of this instance,
taking it from the root level ```` (STAT format 4) element with the
same name as the string.
.. versionadded:: 5.0
```` element (instance)
---------------------------------
Defines the coordinates of this instance in the design space.
.. seealso:: :ref:`Full documentation of the \ element `
```` element (instance)
..................................
.. seealso:: :ref:`Full documentation of the \ element `
```` element (instance)
----------------------------
Arbitrary data about this instance.
.. seealso:: :ref:`lib`
````, ````, ````, ```` elements: localised names for instances
----------------------------------------------------------------------------------------------------------------------------
Localised names for instances can be included with these simple elements
with an ``xml:lang`` attribute:
`XML language definition `__
- ````
- ````
- ````
- ````
.. rubric:: Example
.. code:: xml
Demigras
半ば
Montserrat
モンセラート
Standard
Montserrat Halbfett
モンセラート SemiBold
Example for varLib
------------------
.. code:: xml
com.coolDesignspaceApp.specimenText
Hamburgerwhatever
Here is an example using STAT format 4 labels to define the location of the
instance directly.
.. code:: xml
Here is an example of using the ``public.fontInfo`` lib key to gain more granular
control over the font info of the instances.
``openTypeNameWWSFamilyName`` and ``openTypeNameWWSSubfamilyName`` are not able to
be set by attributes on the ```` element. The ``openTypeOS2WeightClass``
key is superseding the value that would have been set by the ``weight`` axis value.
The ``trademark`` key is superseding the value that would have been set by UFO source
at the origin. If the designer wishes to set name records for other encodings,
platforms or laguages, they should do so using the ``openTypeNameRecords`` key, like
they would in a UFO source.
See `UFO3 fontinfo.plist specification `_.
.. code:: xml
public.fontInfo
openTypeNameWWSFamilyName
My Font Text
openTypeNameWWSSubfamilyName
Light
openTypeOS2WeightClass
300
trademark
My Font Text Light is a registered trademark...
openTypeNameRecords
encodingID
1
languageID
1031
nameID
7
platformID
3
string
Meine Schrift Text Leicht ist eine registrierte Marke...
```` element (instance)
-------------------------------
- Container for ```` elements.
- Optional
- MutatorMath only.
.. deprecated:: 5.0
```` element (instance)
..............................
- Child element of ````
- May contain a ```` element.
.. deprecated:: 5.0
.. rubric:: Attributes
- ``name``: string. The name of the glyph.
- ``unicode``: string. Unicode values for this glyph, in hexadecimal.
Multiple values should be separated with a space.
- ``mute``: optional attribute, number 1 or 0. Indicate if this glyph
should be supressed in the output.
```` element
,,,,,,,,,,,,,,,,,,
- String. The value corresponds to glyph.note in UFO.
.. deprecated:: 5.0
```` element
,,,,,,,,,,,,,,,,,,,,,
- Container for ```` elements
- These ```` elements define an alternative set of glyph masters
for this glyph.
.. deprecated:: 5.0
```` element
++++++++++++++++++++
- Defines a single alternative master for this glyph.
.. deprecated:: 5.0
.. rubric:: Attributes
- ``glyphname``: the name of the alternate master glyph.
- ``source``: the identifier name of the source this master glyph needs
to be loaded from
Example for MutatorMath
.......................
.. code:: xml
A note about this glyph
com.coolDesignspaceApp.specimenText
Hamburgerwhatever
.. _lib:
=============================
```` element (top-level)
=============================
The ```` element contains arbitrary data.
- Child element of ````, ```` and ````
- If present, content must be an XML Property List (plist).
__
- Contains arbitrary data about the whole document or about a specific
variable font or instance.
- Items in the dict need to use **reverse domain name notation**
__
.. rubric:: Example:
.. code:: xml
com.company.fontEditor.myString
The contents use the PLIST format.