Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1843fce

Browse files
review
1 parent 45964a1 commit 1843fce

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

lib/ui/text.dart

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,8 +1565,8 @@ enum TextDecorationStyle {
15651565
wavy
15661566
}
15671567

1568-
/// {@macro dart.ui.leadingDistribution}
1569-
enum LeadingDistribution {
1568+
/// {@macro dart.ui.textLeadingDistribution}
1569+
enum TextLeadingDistribution {
15701570
/// Distributes the [leading](https://en.wikipedia.org/wiki/Leading)
15711571
/// of the text proportionally above and below the text, to the font's
15721572
/// ascent/discent ratio.
@@ -1623,7 +1623,7 @@ class TextHeightBehavior {
16231623
const TextHeightBehavior({
16241624
this.applyHeightToFirstAscent = true,
16251625
this.applyHeightToLastDescent = true,
1626-
this.leadingDistribution = LeadingDistribution.proportional,
1626+
this.leadingDistribution = TextLeadingDistribution.proportional,
16271627
});
16281628

16291629
/// Creates a new TextHeightBehavior object from an encoded form.
@@ -1632,7 +1632,7 @@ class TextHeightBehavior {
16321632
TextHeightBehavior.fromEncoded(int encoded)
16331633
: applyHeightToFirstAscent = (encoded & 0x1) == 0,
16341634
applyHeightToLastDescent = (encoded & 0x2) == 0,
1635-
leadingDistribution = LeadingDistribution.values[encoded >> 2];
1635+
leadingDistribution = TextLeadingDistribution.values[encoded >> 2];
16361636

16371637
/// Whether to apply the [TextStyle.height] modifier to the ascent of the first
16381638
/// line in the paragraph.
@@ -1658,17 +1658,17 @@ class TextHeightBehavior {
16581658
/// Defaults to true (height modifications applied as normal).
16591659
final bool applyHeightToLastDescent;
16601660

1661-
/// {@template dart.ui.leadingDistribution}
1661+
/// {@template dart.ui.textLeadingDistribution}
16621662
/// How the ["leading"](https://en.wikipedia.org/wiki/Leading) is distributed
16631663
/// over and under the text.
16641664
///
16651665
/// Does not affect layout when [TextStyle.height] is not specified. The
1666-
/// leading can become negative, for example, when [LeadingDistribution.even]
1666+
/// leading can become negative, for example, when [TextLeadingDistribution.even]
16671667
/// is used with a [TextStyle.height] much smaller than 1.0.
16681668
/// {@endtemplate}
16691669
///
1670-
/// Defaults to [LeadingDistribution.proportional],
1671-
final LeadingDistribution leadingDistribution;
1670+
/// Defaults to [TextLeadingDistribution.proportional],
1671+
final TextLeadingDistribution leadingDistribution;
16721672

16731673
/// Returns an encoded int representation of this object.
16741674
int encode() {
@@ -1765,7 +1765,7 @@ Int32List _encodeTextStyle(
17651765
double? letterSpacing,
17661766
double? wordSpacing,
17671767
double? height,
1768-
LeadingDistribution? leadingDistribution,
1768+
TextLeadingDistribution? leadingDistribution,
17691769
Locale? locale,
17701770
Paint? background,
17711771
Paint? foreground,
@@ -1903,7 +1903,7 @@ class TextStyle {
19031903
double? letterSpacing,
19041904
double? wordSpacing,
19051905
double? height,
1906-
LeadingDistribution? leadingDistribution,
1906+
TextLeadingDistribution? leadingDistribution,
19071907
Locale? locale,
19081908
Paint? background,
19091909
Paint? foreground,
@@ -2006,7 +2006,7 @@ class TextStyle {
20062006
'letterSpacing: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_letterSpacing}x" : "unspecified"}, '
20072007
'wordSpacing: ${ _encoded[0] & 0x02000 == 0x02000 ? "${_wordSpacing}x" : "unspecified"}, '
20082008
'height: ${ _encoded[0] & 0x04000 == 0x04000 ? "${_height}x" : "unspecified"}, '
2009-
'leadingDistribution: ${_encoded[0] & 0x0100 == 0x0100 ? "${LeadingDistribution.values[_encoded[8]]}" : "unspecified"}, '
2009+
'leadingDistribution: ${_encoded[0] & 0x0100 == 0x0100 ? "${TextLeadingDistribution.values[_encoded[8]]}" : "unspecified"}, '
20102010
'locale: ${ _encoded[0] & 0x08000 == 0x08000 ? _locale : "unspecified"}, '
20112011
'background: ${ _encoded[0] & 0x10000 == 0x10000 ? _background : "unspecified"}, '
20122012
'foreground: ${ _encoded[0] & 0x20000 == 0x20000 ? _foreground : "unspecified"}, '
@@ -2259,7 +2259,7 @@ ByteData _encodeStrut(
22592259
List<String>? fontFamilyFallback,
22602260
double? fontSize,
22612261
double? height,
2262-
LeadingDistribution? leadingDistribution,
2262+
TextLeadingDistribution? leadingDistribution,
22632263
double? leading,
22642264
FontWeight? fontWeight,
22652265
FontStyle? fontStyle,
@@ -2350,10 +2350,12 @@ class StrutStyle {
23502350
/// be provided for this property to take effect.
23512351
///
23522352
/// * `leading`: The minimum amount of leading between lines as a multiple of
2353-
/// the font size. `fontSize` must be provided for this property to take effect.
2353+
/// the font size. `fontSize` must be provided for this property to take
2354+
/// effect. The leading added by this property is distributed evenly over
2355+
/// and under the text, regardless of `leadingDistribution`.
23542356
///
2355-
/// * `leadingDistribution`: Specifies how the extra vertical space added by
2356-
/// the `height` multiplier should be distributed over and under the text,
2357+
/// * `leadingDistribution`: how the extra vertical space added by the
2358+
/// `height` multiplier should be distributed over and under the text,
23572359
/// independent of `leading` (which is always distributed evenly over and
23582360
/// under text).
23592361
///
@@ -2375,7 +2377,7 @@ class StrutStyle {
23752377
List<String>? fontFamilyFallback,
23762378
double? fontSize,
23772379
double? height,
2378-
LeadingDistribution? leadingDistribution,
2380+
TextLeadingDistribution? leadingDistribution,
23792381
double? leading,
23802382
FontWeight? fontWeight,
23812383
FontStyle? fontStyle,

third_party/txt/src/txt/paragraph_style.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum class TextDirection {
4848
// the line will use the default font metric provided ascent/descent and
4949
// ParagraphStyle.height or TextStyle.height will not take effect.
5050
//
51-
// kHalfLeading determines how the leading is distributed over and under the
51+
// kEvenLeading determines how the leading is distributed over and under the
5252
// text. When true, half of the leading is added to the top of the text and the
5353
// other half is added to the bottom of the text. Otherwise, instead of
5454
// distributing the space evenly, it's distributed proportionally to the font's
@@ -66,7 +66,7 @@ enum TextHeightBehavior {
6666
kDisableFirstAscent = 0x1,
6767
kDisableLastDescent = 0x2,
6868
kDisableAll = 0x1 | 0x2,
69-
kHalfLeading = 0x1 << 2,
69+
kEvenLeading = 0x1 << 2,
7070
};
7171

7272
class ParagraphStyle {

third_party/txt/src/txt/paragraph_txt.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ void ParagraphTxt::ComputeStrut(StrutMetrics* strut, SkFont& font) {
570570
paragraph_style_.strut_has_leading_distribution_override
571571
? paragraph_style_.strut_half_leading
572572
: paragraph_style_.text_height_behavior &
573-
TextHeightBehavior::kHalfLeading;
573+
TextHeightBehavior::kEvenLeading;
574574

575575
const double available_height =
576576
half_leading_enabled ? metrics_height : strut_height;
@@ -1215,7 +1215,7 @@ void ParagraphTxt::UpdateLineMetrics(const SkFontMetrics& metrics,
12151215
style.has_leading_distribution_override
12161216
? style.half_leading
12171217
: paragraph_style_.text_height_behavior &
1218-
TextHeightBehavior::kHalfLeading;
1218+
TextHeightBehavior::kEvenLeading;
12191219

12201220
// Scale the ascent and descent such that the sum of ascent and
12211221
// descent is `style.height * style.font_size`.

third_party/txt/tests/paragraph_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1892,7 +1892,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(HeightOverrideHalfLeadingParagraph)) {
18921892

18931893
txt::ParagraphStyle paragraph_style;
18941894
paragraph_style.max_lines = 10;
1895-
paragraph_style.text_height_behavior = TextHeightBehavior::kHalfLeading;
1895+
paragraph_style.text_height_behavior = TextHeightBehavior::kEvenLeading;
18961896
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
18971897

18981898
txt::TextStyle text_style;

0 commit comments

Comments
 (0)