withFontLineHeight function
style with the line height of its own font family, as createTextTheme
sets it for its text styles (docs/design/ADR_font_line_height.md in
telosnex).
A style that sets a different font family than the theme must set its own height. Otherwise it inherits the height of the theme font from DefaultTextStyle, sized for another font.
fit is MonetThemeData.compactLineHeights: true for
lineHeightForFontFamily at clearance, false for the font's own box.
Implementation
TextStyle withFontLineHeight(
TextStyle style, {
required bool fit,
required double clearance,
}) {
final height = fit
? lineHeightForFontFamily(style.fontFamily, clearance: clearance)
: naturalLineHeightForFontFamily(style.fontFamily);
if (height == null) return style;
return style.copyWith(
height: height,
leadingDistribution: TextLeadingDistribution.even,
);
}