# Analyzing Variation Models

I am surprised that nobody actually did a mathematical analysis of the variation model in OpenType. They are simply reusing the concepts of the old MM system, and complicating the things they need.

## Standard variations

For almost all places in a current variable font, anything that varies (coordinates, lengths, parameters, etc.) could be expressed in the following model:

{x̂(v)} | {= x̄ +{ {∑}m ∈ x}} D{x}[m]W(mv)} | {(1)} |

{W(mv)} | {={ {∏}a ∈ m[a]v[a])} | {(2)} |

The notation `x̂` denotes a variable quantity (VQ), which responds to an instance tuple `v`. `x̄` is the default value of `x̂`. `x`} represents the region set of `x̂`, and `D`{`x`}[`m`] is the delta associated with this master `m`. Binary function `W`(`m``v`) computes the weight of master `m` under instance `v`, which is defined as a product of axis weights.

We can easily conclude that VQs form a linear space, since scalar product and sum can be defined in such manner:

{(s ⋅ x̂)(v)} | {= (sx̄) +{ {∑}m ∈ x}}(sD{x}[m])W(mv)} | {(3)} |

{(x̂ + ŷ)(v)} | {= (x̄ + ȳ) +{ {∑}m ∈ x} ∪ y}}(D{x}[m] + D{y}[m])W(mv)} | {(4)} |

One thing we could not define yet is the product of two VQs, we’d like to discuss them later.

You’ve noticed that the entire variation model is a *sum*, instead of *blending* values across masters. However, conversion from blending into VQ could be easily achieved by solving a linear system.

## Nested variations

One interesting special case happens in CFF2: in theory, the `blend`

operators in CFF2 could be nested, so equation (1) would be modified into this form:

{x̂(v)} | {= x̄ +{ {∑}m ∈ x}} D̂{x}[m](v)W(mv)} | {(5)} |

The only difference is that the factor `D̂`{`x`}[`m`](`v`) is now a VQ instead of a number. However the property that VQs form a linear space still holds, since we can recursively scale or sum VQs in (5).

## Products of variations

One thing we’d like to extend current standard is allowing products (`x̂` ⋅ `ŷ`) be representable in the variation system, and that is surprisingly simple by allowing axes to repeat in masters (variation regions). The product

{(x̂ ⋅ ŷ)(v)} | {= x̄ ⋅ ȳ} | {(6)} |

{} | {+ (x̄ ⋅ ŷ)(v)} | {(7)} |

{} | {+ (ȳ ⋅ x̂)(v)} | {(8)} |

{} | {+{ {∑}m{x} ∈ x}} { {∑}m{y} ∈ x}}(D{x}[m{x}] ⋅ D{y}[m{y}])W(m{x}v)W(m{y}v)} | {(9)} |

The term (6), (7), (8) are simply scales of VQs, but term (9) contains product of weight functions that is not representable in the current standard. However releasing this restriction is surprisingly simple: we can allow masters to contain an axis list, which may have duplicate axes, and associate a “tent” (start-peak-end triplet) to each axis item. In the current standard, the axis list is a fixed list shared across the entire font.

In other terms, the form of (2) would be modified into this form:

{W(mv)} | {={ {∏}(aτ) ∈ m]} Λ(τv[a])} | {(10)} |

Notation `m`] denotes the “axis-tent” list that forms this master, and we do the same product just like the old definition. Then the product of two weighting functions could be defined as:

{W(m{x}v)W(m{y}v)} | {={ {∏}(aτ) ∈ m{x}]m{y}]} Λ(τv[a])} | {(11)} |

where notation `m`{`x`}]`m`{`y`}] denotes we simply concatenate the axis-tent lists together.

## Mutatormath, etc.

Mutatormath and libraries similar to that defines how we convert a set of *peak tuples* into a master set, where each master requires each axis’ record having a *start* and an *end*, as well as the *peak* already given. Once the master set is decided, the interpolation part could be easily done by solving linear systems.