You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Introduces a sentinel value `kTextHeightNone` for `ui.TextStyle.height` which can be used to "unset" the current `TextStyle.height` (and for consistency, it applies to `StructStyle.height` and `ParagraphStyle.height` too). Documentation of `TextStyle.height` can be found [here](https://main-api.flutter.dev/flutter/painting/TextStyle/height.html) (the one from `painting` library not `dart:ui`).
part of flutter/flutter#58765: currently `TextStyle.height` uses `null` as the sentinel value for "no height multiplier specified, use the font height", which has conflicting semantics: it means the height multiplier is not set (so the span height is determined by font metrics) but in reality it also means the height should inherit from its parent span (or in `copyWith` context, it means do not override the height).
The new sentinel value `kTextHeightNone` is currently set to `0.0`. This is because skparagraph internally uses 0 for "no height multiplier", so using 0 should minimize the behavior change:
https://github.com/google/skia/blob/62f369c759947272dfdd2d8f060afadbcc361e79/modules/skparagraph/src/Run.cpp#L65-L67
This MAY still change the current behavior: for consistency setting `StructStyle.height` / `ParagraphStyle.height` to the sentinel value also unsets the height multiplier which may not be the current behavior.
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Copy file name to clipboardExpand all lines: lib/ui/text.dart
+30-16Lines changed: 30 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,12 @@
3
3
// found in the LICENSE file.
4
4
part of dart.ui;
5
5
6
+
/// A [TextStyle.height] value that indicates the text span should take
7
+
/// the height defined by the font, which may not be exactly the height of
8
+
/// [TextStyle.fontSize].
9
+
// To change the sentinel value, search for "kTextHeightNone" in the source code.
10
+
constdouble kTextHeightNone =0.0;
11
+
6
12
/// Whether to use the italic type variation of glyphs in the font.
7
13
///
8
14
/// Some modern fonts allow this to be selected in a more fine-grained manner.
@@ -1687,10 +1693,10 @@ class TextStyle {
1687
1693
/// * `letterSpacing`: The amount of space (in logical pixels) to add between each letter.
1688
1694
/// * `wordSpacing`: The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word).
1689
1695
/// * `textBaseline`: The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.
1690
-
/// * `height`: The height of this text span, as a multiplier of the font size. Omitting `height` will allow the line height
1696
+
/// * `height`: The height of this text span, as a multiplier of the font size. Setting the `height` to `kTextHeightNone` will allow the line height
1691
1697
/// to take the height as defined by the font, which may not be exactly the height of the fontSize.
1692
-
/// * `leadingDistribution`: When `height` is specified, how the extra vertical space should be distributed over and under the text. Defaults
1693
-
/// to the paragraph's [TextHeightBehavior] if left unspecified.
1698
+
/// * `leadingDistribution`: When `height` is set to a non-null that is not `kTextHeightNone`, how the extra vertical space should be distributed over and under the text.
1699
+
/// Defaults to the paragraph's [TextHeightBehavior] if left unspecified.
1694
1700
/// * `locale`: The locale used to select region-specific glyphs.
1695
1701
/// * `background`: The paint drawn as a background for the text.
1696
1702
/// * `foreground`: The paint used to draw the text. If this is specified, `color` must be null.
0 commit comments