Include paragraph height in the top-level text style. (flutter/engine#25659)
* Include paragraph height in the top-level text style. * Update test comment * Update goldens lock
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
repository: https://github.com/flutter/goldens.git
|
||||
revision: ca0a1f0b1274f895590fbc31a25c90eee693d914
|
||||
revision: 5bef90a33a3a06924de81236ff7902c3e4e64659
|
||||
|
||||
@@ -36,6 +36,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
|
||||
_textDirection = textDirection ?? ui.TextDirection.ltr,
|
||||
_fontFamily = fontFamily,
|
||||
_fontSize = fontSize,
|
||||
_height = height,
|
||||
_fontWeight = fontWeight,
|
||||
_fontStyle = fontStyle;
|
||||
|
||||
@@ -43,12 +44,14 @@ class CkParagraphStyle implements ui.ParagraphStyle {
|
||||
final ui.TextDirection? _textDirection;
|
||||
final String? _fontFamily;
|
||||
final double? _fontSize;
|
||||
final double? _height;
|
||||
final ui.FontWeight? _fontWeight;
|
||||
final ui.FontStyle? _fontStyle;
|
||||
|
||||
static SkTextStyleProperties toSkTextStyleProperties(
|
||||
String? fontFamily,
|
||||
double? fontSize,
|
||||
double? height,
|
||||
ui.FontWeight? fontWeight,
|
||||
ui.FontStyle? fontStyle,
|
||||
) {
|
||||
@@ -61,6 +64,10 @@ class CkParagraphStyle implements ui.ParagraphStyle {
|
||||
skTextStyle.fontSize = fontSize;
|
||||
}
|
||||
|
||||
if (height != null) {
|
||||
skTextStyle.heightMultiplier = height;
|
||||
}
|
||||
|
||||
skTextStyle.fontFamilies = _getEffectiveFontFamilies(fontFamily);
|
||||
|
||||
return skTextStyle;
|
||||
@@ -131,8 +138,9 @@ class CkParagraphStyle implements ui.ParagraphStyle {
|
||||
}
|
||||
|
||||
if (textHeightBehavior != null) {
|
||||
properties.textHeightBehavior = (textHeightBehavior.applyHeightToFirstAscent ? 0 : 1 << 0)
|
||||
| (textHeightBehavior.applyHeightToLastDescent ? 0 : 1 << 1);
|
||||
properties.textHeightBehavior =
|
||||
(textHeightBehavior.applyHeightToFirstAscent ? 0 : 1 << 0) |
|
||||
(textHeightBehavior.applyHeightToLastDescent ? 0 : 1 << 1);
|
||||
}
|
||||
|
||||
if (ellipsis != null) {
|
||||
@@ -144,7 +152,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
|
||||
}
|
||||
|
||||
properties.textStyle =
|
||||
toSkTextStyleProperties(fontFamily, fontSize, fontWeight, fontStyle);
|
||||
toSkTextStyleProperties(fontFamily, fontSize, height, fontWeight, fontStyle);
|
||||
|
||||
return canvasKit.ParagraphStyle(properties);
|
||||
}
|
||||
@@ -153,6 +161,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
|
||||
return CkTextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: _fontSize,
|
||||
height: _height,
|
||||
fontWeight: _fontWeight,
|
||||
fontStyle: _fontStyle,
|
||||
);
|
||||
|
||||
@@ -258,8 +258,6 @@ void testMain() {
|
||||
await testTextStyle('paragraph font size', paragraphFontSize: 22);
|
||||
});
|
||||
|
||||
// TODO(yjbanov): paragraphHeight seems to have no effect, but maybe I'm using it wrong.
|
||||
// https://github.com/flutter/flutter/issues/74337
|
||||
test('text styles - paragraph height', () async {
|
||||
await testTextStyle('paragraph height', layoutWidth: 50, paragraphHeight: 1.5);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user