leading distribution docs (#78581)
This commit is contained in:
@@ -853,6 +853,13 @@ class TextPainter {
|
||||
/// A given selection might have more than one rect if this text painter
|
||||
/// contains bidirectional text because logically contiguous text might not be
|
||||
/// visually contiguous.
|
||||
///
|
||||
/// Leading or trailing newline characters will be represented by zero-width
|
||||
/// `Textbox`es.
|
||||
///
|
||||
/// The method only returns `TextBox`es of glyphs that are entirely enclosed by
|
||||
/// the given `selection`: a multi-code-unit glyph will be excluded if only
|
||||
/// part of its code units are in `selection`.
|
||||
List<TextBox> getBoxesForSelection(
|
||||
TextSelection selection, {
|
||||
ui.BoxHeightStyle boxHeightStyle = ui.BoxHeightStyle.tight,
|
||||
|
||||
@@ -150,6 +150,47 @@ const double _kDefaultFontSize = 14.0;
|
||||
///
|
||||
/// See [StrutStyle] for further control of line height at the paragraph level.
|
||||
///
|
||||
/// ### Leading Distribution and Trimming
|
||||
///
|
||||
/// [Leading](https://en.wikipedia.org/wiki/Leading) is the vertical space
|
||||
/// between glyphs from adjacent lines. Quantitatively, it is the line height
|
||||
/// (see the previous section) subtracted by the font's ascent and descent.
|
||||
/// It's possible to have a negative `Leading` if [height] is sufficiently
|
||||
/// small.
|
||||
///
|
||||
/// When the [height] multiplier is null, `leading` and how it is distributed
|
||||
/// is up to the font's
|
||||
/// [metrics](https://en.wikipedia.org/wiki/Typeface#Font_metrics).
|
||||
/// When the [height] multiplier is specified, the exact behavior can be
|
||||
/// configured via [leadingDistribution] and [TextPainter.textHeightBehavior].
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// Above is a side-by-side comparison of different [leadingDistribution] and
|
||||
/// [TextPainter.textHeightBehavior] combinations.
|
||||
///
|
||||
/// * Configuration 1: The default. [leadingDistribution] is set to [TextLeadingDistribution.proportional].
|
||||
/// * Configuration 2: same as Configuration 1, except [TextHeightBehavior.applyHeightToFirstAscent] is set to false.
|
||||
/// * Configuration 3: [leadingDistribution] is set to [TextLeadingDistribution.even].
|
||||
/// * Configuration 4: same as Configuration 3, except [TextHeightBehavior.applyHeightToLastDescent] is set to false.
|
||||
///
|
||||
/// The [leadingDistribution] property controls how leading is distributed over
|
||||
/// and under the text. With [TextLeadingDistribution.proportional]
|
||||
/// (Configuration 1), `Top Leading : Bottom Leading = Font Ascent : Font
|
||||
/// Descent`, which also means the alphabetic baseline divides the line height
|
||||
/// into 2 parts proportional to the font's ascent and descent. With
|
||||
/// [TextLeadingDistribution.even] (Configuration 3), `Top Leading` equals
|
||||
/// `Bottom Leading`, and the glyphs are roughly centered within the allotted
|
||||
/// line height.
|
||||
///
|
||||
/// The [TextPainter.textHeightBehavior] is a property that controls leading at
|
||||
/// the paragraph level. The `applyHeightToFirstAscent` property is applied
|
||||
/// **after** [height] and [leadingDistribution]. Setting it to false trims the
|
||||
/// "Top Leading" of the text box to match the font's ascent if it's on the
|
||||
/// first line (see Configuration 2). Similarly setting
|
||||
/// `applyHeightToLastDescent` to false reduces "Bottom Leading" to 0 for the
|
||||
/// last line of text (Configuration 4).
|
||||
///
|
||||
/// ### Wavy red underline with black text
|
||||
///
|
||||
/// {@tool snippet}
|
||||
@@ -578,7 +619,8 @@ class TextStyle with Diagnosticable {
|
||||
/// When a non-null [height] is specified, after accommodating the glyphs of
|
||||
/// the text, the remaining vertical space from the allotted line height will
|
||||
/// be distributed over and under the text, according to the
|
||||
/// [leadingDistribution] property.
|
||||
/// [leadingDistribution] property. See the [TextStyle] class's documentation
|
||||
/// for an example.
|
||||
///
|
||||
/// When [height] is null, [leadingDistribution] does not affect the text
|
||||
/// layout.
|
||||
|
||||
Reference in New Issue
Block a user