height property

double? height
final

The height of this text span, as a multiple of the font size.

When height is kTextHeightNone, the line height will be determined by the font's metrics directly, which may differ from the fontSize. Otherwise the line height of the span of text will be a multiple of fontSize, and be exactly fontSize * height logical pixels tall.

For most fonts, setting height to 1.0 is not the same as setting height to kTextHeightNone because the fontSize sets the height of the EM-square, which is different than the font provided metrics for line height. The following diagram illustrates the difference between the font-metrics defined line height and the line height produced with height: 1.0 (which forms the upper and lower edges of the EM-square):

With the font-metrics-defined line height, there is space between lines appropriate for the font, whereas the EM-square is only the height required to hold most of the characters.

Examples of the resulting line heights from different values of TextStyle.height:

Since the explicit line height is applied as a scale factor on the font-metrics-defined line height, the gap above the text grows faster, as the height grows, than the gap below the text.

See StrutStyle and TextHeightBehavior for further control of line height at the paragraph level.

Implementation

final double? height;