variations method
Variation-axis settings, clamped to this font's ranges; axes the font
does not have are omitted. weight defaults to Regular 400 (clamped,
so Space Grotesk never renders at its Light default by accident).
opticalSize defaults to fontSize when given (auto optical sizing).
Implementation
List<FontVariation> variations({
double weight = 400,
double? width,
double? grade,
double? opticalSize,
double? fontSize,
}) {
final out = <FontVariation>[];
final w = this.weight;
if (w != null) out.add(w.variation(weight));
final wd = this.width;
if (wd != null && width != null) out.add(wd.variation(width));
final g = this.grade;
if (g != null && grade != null) out.add(g.variation(grade));
final o = this.opticalSize;
final opsz = opticalSize ?? fontSize;
if (o != null && opsz != null) out.add(o.variation(opsz));
return out;
}