wInheritedFontSize function

double wInheritedFontSize(
  1. BuildContext context
)

Returns the font size text under context inherits, in logical pixels.

The ambient DefaultTextStyle's size when it sets one, else kDefaultFontSize, which is what Flutter paints unsized text at. The theme's base is not consulted: no widget paints at it unless a DefaultTextStyle says so, and an em resolved against a size the glyphs are not drawn at would be wrong by the ratio. An em tracking-* on a className with no text-* size resolves against this.

Example:

final style = WindParser.parse('tracking-wide', context);
final textStyle = style.toTextStyle(
  inheritedFontSize: wInheritedFontSize(context),
);

Implementation

double wInheritedFontSize(BuildContext context) {
  final double? ambient = DefaultTextStyle.of(context).style.fontSize;
  WindPerfCounters.recordInheritedRead(WindInheritedRead.defaultTextStyle);

  return ambient ?? kDefaultFontSize;
}