instance method
This font at axis values (tag → value in the axis's own units, as
in {'wght': 700, 'wdth': 75}), with its own outline and advance
caches. Axes left out take their defaults; values are clamped to
the axis range; tags the font has no axis for are ignored. Always
made from the default instance, so values do not add up. Instances
are cached, and one at the default coordinates is the default font
itself (as is any instance of a font that does not vary).
Implementation
OpenTypeFont instance(Map<String, double> values) {
final root = _root;
final axes = root._axes;
if (axes == null) return root;
final coords = axes.normalize(values);
if (coords.every((c) => c == 0)) return root;
return root._instances[coords.join(
',',
)] ??= OpenTypeFont._(bytes, _r, _tables, root, List.unmodifiable(coords), {
for (final a in axes.axes)
if (values[a.tag] case final v?)
a.tag: v.clamp(a.minValue, a.maxValue).toDouble(),
});
}