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