Unverified Commit 9c1783e9 authored by Gary Qian's avatar Gary Qian Committed by GitHub

Update TextStyle and StrutStyle height docs (#33281)

parent aae50f54
...@@ -106,18 +106,38 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a ...@@ -106,18 +106,38 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a
/// ///
/// ### Line height /// ### Line height
/// ///
/// By default, text will layout with line height as defined by the font.
/// Font-metrics defined line height may be taller or shorter than the font size.
/// The [height] property allows manual adjustment of the height of the line as
/// a multiple of [fontSize]. For most fonts, setting [height] to 1.0 is not
/// the same as omitting or setting height to null. The following diagram
/// illustrates the difference between the font-metrics defined line height and
/// the line height produced with `height: 1.0` (also known as the EM-square):
///
/// ![Text height diagram](https://flutter.github.io/assets-for-api-docs/assets/painting/text_height_diagram.png)
///
/// {@tool sample} /// {@tool sample}
/// The [height] property can be used to change the line height. Here, the line /// The [height] property can be used to change the line height. Here, the line
/// height is set to 5 times the font size, so that the text is very spaced out. /// height is set to 5 times the font size, so that the text is very spaced out.
/// Since the `fontSize` is set to 10, the final height of the line is
/// 50 pixels.
/// ///
/// ```dart /// ```dart
/// Text( /// Text(
/// 'Don\'t act surprised, you guys, cuz I wrote \'em!', /// 'Don\'t act surprised, you guys, cuz I wrote \'em!',
/// style: TextStyle(height: 5.0), /// style: TextStyle(fontSize: 10, height: 5.0),
/// ) /// )
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
/// ///
/// {@tool sample}
///
/// Examples of the resulting heights from different values of `TextStyle.height`:
///
/// ![Text height comparison diagram](https://flutter.github.io/assets-for-api-docs/assets/painting/text_height_comparison_diagram.png)
///
/// {@end-tool}
///
/// ### Wavy red underline with black text /// ### Wavy red underline with black text
/// ///
/// {@tool sample} /// {@tool sample}
...@@ -439,9 +459,28 @@ class TextStyle extends Diagnosticable { ...@@ -439,9 +459,28 @@ class TextStyle extends Diagnosticable {
/// The height of this text span, as a multiple of the font size. /// The height of this text span, as a multiple of the font size.
/// ///
/// If applied to the root [TextSpan], this value sets the line height, which /// When [height] is null or omitted, the line height will be determined
/// is the minimum distance between subsequent text baselines, as multiple of /// by the font's metrics directly, which may differ from the fontSize.
/// the font size. /// When [height] is non-null, 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 omitting or
/// setting height to null 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):
///
/// ![Text height diagram](https://flutter.github.io/assets-for-api-docs/assets/painting/text_height_diagram.png)
///
/// {@tool sample}
///
/// Examples of the resulting line heights from different values of `TextStyle.height`:
///
/// ![Text height comparison diagram](https://flutter.github.io/assets-for-api-docs/assets/painting/text_height_comparison_diagram.png)
///
/// {@end-tool}
final double height; final double height;
/// The locale used to select region-specific glyphs. /// The locale used to select region-specific glyphs.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment