Merge pull request #1254 from fonttools/designspacelib-conditionset-spec
designspaceLib: This adds conditionsets to the rule element.
This commit is contained in:
commit
162ad1c842
@ -83,21 +83,18 @@ dictionary, ``obj.stylename`` and ``obj.localisedStyleName['en']``.
|
|||||||
Rules
|
Rules
|
||||||
*****
|
*****
|
||||||
|
|
||||||
**The ``rule`` element is experimental.** Some ideas behind how rules
|
Rules describe designspace areas in which one glyph should be replaced by another.
|
||||||
could work in designspaces come from Superpolator. Such rules can maybe
|
A rule has a name and a number of conditionsets. The rule also contains a list of glyphname
|
||||||
be used to describe some of the conditional GSUB functionality of
|
pairs: the glyphs that need to be substituted. For a rule to be triggered
|
||||||
OpenType 1.8. The definition of a rule is not that complicated. A rule
|
only one of the conditionsets needs to be true, ``OR``. Within a conditionset all
|
||||||
has a name, and it has a number of conditions. The rule also contains a
|
conditions need to be true, ``AND``.
|
||||||
list of glyphname pairs: the glyphs that need to be substituted.
|
|
||||||
|
|
||||||
Variable font instances
|
Variable fonts
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
- In an variable font the substitution happens at run time: there are
|
- In an variable font the substitution happens at run time: there are
|
||||||
no changes in the font, only in the sequence of glyphnames that is
|
no changes in the font, only in the sequence of glyphnames that is
|
||||||
rendered.
|
rendered.
|
||||||
- The infrastructure to get this rule data in a variable font needs to
|
|
||||||
be built.
|
|
||||||
|
|
||||||
UFO instances
|
UFO instances
|
||||||
=============
|
=============
|
||||||
@ -314,16 +311,16 @@ RuleDescriptor object
|
|||||||
|
|
||||||
- ``name``: string. Unique name for this rule. Will be used to
|
- ``name``: string. Unique name for this rule. Will be used to
|
||||||
reference this rule data.
|
reference this rule data.
|
||||||
- ``conditions``: list of dicts with condition data.
|
- ``conditionSets``: a list conditionsets
|
||||||
- Each condition specifies the axis name it is active on and the values
|
- Each conditionset is a list of conditions.
|
||||||
between which the condition is true.
|
- Each condition is a dict with ``name``, ``minimum`` and ``maximum`` keys.
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
r1 = RuleDescriptor()
|
r1 = RuleDescriptor()
|
||||||
r1.name = "unique.rule.name"
|
r1.name = "unique.rule.name"
|
||||||
r1.conditions.append(dict(name="weight", minimum=-10, maximum=10))
|
r1.conditionsSets.append([dict(name="weight", minimum=-10, maximum=10), dict(...)])
|
||||||
r1.conditions.append(dict(name="width", minimum=-10, maximum=10))
|
r1.conditionsSets.append([dict(...), dict(...)])
|
||||||
|
|
||||||
.. _subclassing-descriptors:
|
.. _subclassing-descriptors:
|
||||||
|
|
||||||
@ -358,6 +355,8 @@ Document xml structure
|
|||||||
- The ``axes`` element contains one or more ``axis`` elements.
|
- The ``axes`` element contains one or more ``axis`` elements.
|
||||||
- The ``sources`` element contains one or more ``source`` elements.
|
- The ``sources`` element contains one or more ``source`` elements.
|
||||||
- The ``instances`` element contains one or more ``instance`` elements.
|
- The ``instances`` element contains one or more ``instance`` elements.
|
||||||
|
- The ``rules`` element contains one or more ``rule`` elements.
|
||||||
|
- The ``lib`` element contains arbitrary data.
|
||||||
|
|
||||||
.. code:: xml
|
.. code:: xml
|
||||||
|
|
||||||
@ -375,6 +374,10 @@ Document xml structure
|
|||||||
<!-- define instances here -->
|
<!-- define instances here -->
|
||||||
<instance../>
|
<instance../>
|
||||||
</instances>
|
</instances>
|
||||||
|
<rules>
|
||||||
|
<!-- define rules here -->
|
||||||
|
<rule../>
|
||||||
|
</rules>
|
||||||
<lib>
|
<lib>
|
||||||
<dict>
|
<dict>
|
||||||
<!-- store custom data here -->
|
<!-- store custom data here -->
|
||||||
@ -840,18 +843,18 @@ Example
|
|||||||
=================
|
=================
|
||||||
|
|
||||||
- Container for ``rule`` elements
|
- Container for ``rule`` elements
|
||||||
|
- The rules are evaluated in this order.
|
||||||
|
|
||||||
.. 51-rule-element:
|
.. 51-rule-element:
|
||||||
|
|
||||||
5.1 rule element
|
5.1 rule element
|
||||||
================
|
================
|
||||||
|
|
||||||
- Defines a named rule with a set of conditions.
|
- Defines a named rule.
|
||||||
- The conditional substitutions specifed in the OpenType specification
|
- Each ``rule`` element contains one or more ``conditionset`` elements.
|
||||||
can be much more elaborate than what it recorded in this element.
|
- Only one ``conditionset`` needs to be true to trigger the rule.
|
||||||
- So while authoring tools are welcome to use the ``sub`` element,
|
- All conditions must be true to make the ``conditionset`` true.
|
||||||
they're intended as preview / example / test substitutions for the
|
- For backwards compatibility a ``rule`` can contain ``condition`` elements outside of a conditionset. These are then understood to be part of a single, implied, ``conditionset``.
|
||||||
rule.
|
|
||||||
|
|
||||||
.. attributes-11:
|
.. attributes-11:
|
||||||
|
|
||||||
@ -861,16 +864,22 @@ Attributes
|
|||||||
- ``name``: required, string. A unique name that can be used to
|
- ``name``: required, string. A unique name that can be used to
|
||||||
identify this rule if it needs to be referenced elsewhere.
|
identify this rule if it needs to be referenced elsewhere.
|
||||||
|
|
||||||
.. 511-condition-element:
|
5.1.1 conditionset element
|
||||||
|
|
||||||
5.1.1 condition element
|
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
- Child element of ``rule``
|
- Child element of ``rule``
|
||||||
|
- Contains one or more ``condition`` elements.
|
||||||
|
|
||||||
|
.. 512-condition-element:
|
||||||
|
|
||||||
|
5.1.2 condition element
|
||||||
|
=======================
|
||||||
|
|
||||||
|
- Child element of ``conditionset``
|
||||||
- Between the ``minimum`` and ``maximum`` this rule is ``true``.
|
- Between the ``minimum`` and ``maximum`` this rule is ``true``.
|
||||||
- If ``minimum`` is not available, assume it is ``axis.minimum``.
|
- If ``minimum`` is not available, assume it is ``axis.minimum``.
|
||||||
- If ``maximum`` is not available, assume it is ``axis.maximum``.
|
- If ``maximum`` is not available, assume it is ``axis.maximum``.
|
||||||
- One or the other or both need to be present.
|
- The condition must contain at least a minimum or maximum or both.
|
||||||
|
|
||||||
.. attributes-12:
|
.. attributes-12:
|
||||||
|
|
||||||
@ -882,9 +891,9 @@ Attributes
|
|||||||
- ``minimum``: number, required*. The low value.
|
- ``minimum``: number, required*. The low value.
|
||||||
- ``maximum``: number, required*. The high value.
|
- ``maximum``: number, required*. The high value.
|
||||||
|
|
||||||
.. 512-sub-element:
|
.. 513-sub-element:
|
||||||
|
|
||||||
5.1.2 sub element
|
5.1.3 sub element
|
||||||
=================
|
=================
|
||||||
|
|
||||||
- Child element of ``rule``.
|
- Child element of ``rule``.
|
||||||
@ -907,6 +916,9 @@ Attributes
|
|||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
Example with an implied ``conditionset``. Here the conditions are not
|
||||||
|
contained in a conditionset.
|
||||||
|
|
||||||
.. code:: xml
|
.. code:: xml
|
||||||
|
|
||||||
<rules>
|
<rules>
|
||||||
@ -917,6 +929,24 @@ Example
|
|||||||
</rule>
|
</rule>
|
||||||
</rules>
|
</rules>
|
||||||
|
|
||||||
|
Example with ``conditionsets``. All conditions in a conditionset must be true.
|
||||||
|
|
||||||
|
.. code:: xml
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
<rule name="named.rule.2">
|
||||||
|
<conditionset>
|
||||||
|
<condition minimum="250" maximum="750" name="weight" />
|
||||||
|
<condition minimum="50" maximum="100" name="width" />
|
||||||
|
</conditionset>
|
||||||
|
<conditionset>
|
||||||
|
<condition ... />
|
||||||
|
<condition ... />
|
||||||
|
</conditionset>
|
||||||
|
<sub name="dollar" byname="dollar.alt"/>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
|
||||||
.. 6-notes:
|
.. 6-notes:
|
||||||
|
|
||||||
6 Notes
|
6 Notes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user