boring-expansion-spec icon indicating copy to clipboard operation
boring-expansion-spec copied to clipboard

VarFonts2.0 variation model

Open behdad opened this issue 4 years ago • 0 comments

As referenced in https://github.com/be-fonts/boring-expansion-spec/issues/17:

struct GenerailzedRegion {
  Array15Of<BEOffset16To<Hill> hills;
};

struct Hill {
  uint8 version;
  Array8Of<BEOffset16To<Base>> bases;
  F2DOT14 scale; // only if version >= 1;
};

struct Base {
  uint8 version;
  F2DOT14 peakCoord;
  F2DOT14 startCoord; // only if version >= 1
  F2DOT14 endCoord; // only if version >= 1
  uint8 baseFuncs; // only if version >= 2
};

The Array15Of is intentional, meaning that the top bit of the uint16 count is reserved for future. All offsets are relative; that is, they are based off of their own start address; As per https://github.com/be-fonts/boring-expansion-spec/issues/45.

struct Base { uint8 version; F2DOT14 peakCoord; F2DOT14 startCoord; // only if version >= 1 F2DOT14 endCoord; // only if version >= 1 uint8 baseFuncs; // only if version >= 2 };

If startCoord is not available, it will be assumed to be the lesser of peakCoord and 0. If endCoord is not available, it will be assumed to be the greater of peakCoord and 0. If baseFuncs is not available, it will be assumed to be 0.

Interpolation algorithm

Interpolation algorithm for each base differs from VarFonts1.0, in many ways:

In VarFonts1.0, peakCoord cannot be zero (that is, peakCoord of zero has special meaning). Moreover, startCoord and endCoord must both be non-positive or both non-negative. None of these requirements and interpretations carry to VarFonts2.0.

The scalar value for a base is 1.0 at peakCoord.

If startCoord is the special value 0x8000 (-2.0), then the scalar value will be 1.0 for any coordinate less than peakCoord as well. Otherwise, the scalar will be 0.0 for coordinates less than startCoord, and will transition from 0.0 to 1.0 from startCoord to peakCoord according to the basis function specified in baseFuncs (default linear).

TODO hash out base funcs after https://github.com/be-fonts/boring-expansion-spec/issues/43 is filled in.

TODO: Add extrapolation.

The situation is symmetrical for endCoord.

TODO: baseFuncs.

behdad avatar Sep 22 '21 13:09 behdad