| 1 |
####################################### |
| 2 |
varLib: Support for OpenType Variations |
| 3 |
####################################### |
| 4 |
|
| 5 |
.. contents:: On this page: |
| 6 |
:local: |
| 7 |
|
| 8 |
.. rubric:: Overview |
| 9 |
:heading-level: 2 |
| 10 |
|
| 11 |
The :py:mod:`fontTools.varLib` package contains a number of classes and routines |
| 12 |
for handling, building and interpolating variable font data. These routines |
| 13 |
rely on a common set of concepts, many of which are equivalent to concepts |
| 14 |
in the OpenType Specification, but some of which are unique to :py:mod:`varLib`. |
| 15 |
|
| 16 |
|
| 17 |
Supporting modules |
| 18 |
------------------ |
| 19 |
|
| 20 |
.. toctree:: |
| 21 |
:maxdepth: 1 |
| 22 |
|
| 23 |
builder |
| 24 |
cff |
| 25 |
errors |
| 26 |
featureVars |
| 27 |
instancer |
| 28 |
interpolatable |
| 29 |
interpolate_layout |
| 30 |
iup |
| 31 |
merger |
| 32 |
models |
| 33 |
mutator |
| 34 |
mvar |
| 35 |
plot |
| 36 |
varStore |
| 37 |
|
| 38 |
|
| 39 |
Terminology |
| 40 |
----------- |
| 41 |
|
| 42 |
axis |
| 43 |
"A designer-determined variable in a font face design that can be used to |
| 44 |
derive multiple, variant designs within a family." (OpenType Specification) |
| 45 |
An axis has a minimum value, a maximum value and a default value. |
| 46 |
|
| 47 |
designspace |
| 48 |
The n-dimensional space formed by the font's axes. (OpenType Specification |
| 49 |
calls this the "design-variation space") |
| 50 |
|
| 51 |
scalar |
| 52 |
A value which is able to be varied at different points in the designspace: |
| 53 |
for example, the horizontal advance width of the glyph "a" is a scalar. |
| 54 |
However, see also *support scalar* below. |
| 55 |
|
| 56 |
default location |
| 57 |
A point in the designspace whose coordinates are the default value of |
| 58 |
all axes. |
| 59 |
|
| 60 |
location |
| 61 |
A point in the designspace, specified as a set of coordinates on one or |
| 62 |
more axes. In the context of ``varLib``, a location is a dictionary with |
| 63 |
the keys being the axis tags and the values being the coordinates on the |
| 64 |
respective axis. A ``varLib`` location dictionary may be "sparse", in the |
| 65 |
sense that axes defined in the font may be omitted from the location's |
| 66 |
coordinates, in which case the default value of the axis is assumed. |
| 67 |
For example, given a font having a ``wght`` axis ranging from 200-1000 |
| 68 |
with default 400, and a ``wdth`` axis ranging 100-300 with default 150, |
| 69 |
the location ``{"wdth": 200}`` represents the point ``wght=400,wdth=200``. |
| 70 |
|
| 71 |
master |
| 72 |
The value of a scalar at a given location. **Note that this is a |
| 73 |
considerably more general concept than the usual type design sense of |
| 74 |
the term "master".** |
| 75 |
|
| 76 |
normalized location |
| 77 |
While the range of an axis is determined by its minimum and maximum values |
| 78 |
as set by the designer, locations are specified internally to the font binary |
| 79 |
in the range -1 to 1, with 0 being the default, -1 being the minimum and |
| 80 |
1 being the maximum. A normalized location is one which is scaled to the |
| 81 |
range (-1,1) on all of its axes. Note that as the range from minimum to |
| 82 |
default and from default to maximum on a given axis may differ (for |
| 83 |
example, given ``wght min=200 default=500 max=1000``, the difference |
| 84 |
between a normalized location -1 of a normalized location of 0 represents a |
| 85 |
difference of 300 units while the difference between a normalized location |
| 86 |
of 0 and a normalized location of 1 represents a difference of 700 units), |
| 87 |
a location is scaled by a different factor depending on whether it is above |
| 88 |
or below the axis' default value. |
| 89 |
|
| 90 |
support |
| 91 |
While designers tend to think in terms of masters - that is, a precise |
| 92 |
location having a particular value - OpenType Variations specifies the |
| 93 |
variation of scalars in terms of deltas which are themselves composed of |
| 94 |
the combined contributions of a set of triangular regions, each having |
| 95 |
a contribution value of 0 at its minimum value, rising linearly to its |
| 96 |
full contribution at the *peak* and falling linearly to zero from the |
| 97 |
peak to the maximum value. The OpenType Specification calls these "regions", |
| 98 |
while ``varLib`` calls them "supports" (a mathematical term used in real |
| 99 |
analysis) and expresses them as a dictionary mapping each axis tag to a |
| 100 |
tuple ``(min, peak, max)``. |
| 101 |
|
| 102 |
box |
| 103 |
``varLib`` uses the term "box" to denote the minimum and maximum "corners" of |
| 104 |
a support, ignoring its peak value. |
| 105 |
|
| 106 |
delta |
| 107 |
The term "delta" is used in OpenType Variations in two senses. In the |
| 108 |
more general sense, a delta is the difference between a scalar at a |
| 109 |
given location and its value at the default location. Additionally, inside |
| 110 |
the font, variation data is stored as a mapping between supports and deltas. |
| 111 |
The delta (in the first sense) is computed by summing the product of the |
| 112 |
delta of each support by a factor representing the support's contribution |
| 113 |
at this location (see "support scalar" below). |
| 114 |
|
| 115 |
support scalar |
| 116 |
When interpolating a set of variation data, the support scalar represents |
| 117 |
the scalar multiplier of the support's contribution at this location. For |
| 118 |
example, the support scalar will be 1 at the support's peak location, and |
| 119 |
0 below its minimum or above its maximum. |
| 120 |
|
| 121 |
|
| 122 |
Package contents |
| 123 |
---------------- |
| 124 |
|
| 125 |
.. automodule:: fontTools.varLib |
| 126 |
:members: |
| 127 |
:undoc-members: |