From 2cb5b24b029739c18d0415f468f10e827ba8fc2a Mon Sep 17 00:00:00 2001 From: Gary Qian Date: Thu, 30 May 2019 10:13:17 -0700 Subject: [PATCH] Fix text scaling of strut style (#33462) --- packages/flutter/lib/src/painting/text_style.dart | 2 +- packages/flutter/test/painting/text_style_test.dart | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index 285d2dbccb..e36edcf746 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -959,7 +959,7 @@ class TextStyle extends Diagnosticable { strutStyle: strutStyle == null ? null : ui.StrutStyle( fontFamily: strutStyle.fontFamily, fontFamilyFallback: strutStyle.fontFamilyFallback, - fontSize: strutStyle.fontSize, + fontSize: strutStyle.fontSize == null ? null : strutStyle.fontSize * textScaleFactor, height: strutStyle.height, leading: strutStyle.leading, fontWeight: strutStyle.fontWeight, diff --git a/packages/flutter/test/painting/text_style_test.dart b/packages/flutter/test/painting/text_style_test.dart index 233ec86a29..c88f6fd104 100644 --- a/packages/flutter/test/painting/text_style_test.dart +++ b/packages/flutter/test/painting/text_style_test.dart @@ -354,4 +354,14 @@ void main() { expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25).background.color, red); expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .75).background.color, blue); }); + + test('TextStyle strut textScaleFactor', () { + const TextStyle style0 = TextStyle(fontSize: 10); + final ui.ParagraphStyle paragraphStyle0 = style0.getParagraphStyle(textScaleFactor: 2.5); + + const TextStyle style1 = TextStyle(fontSize: 25); + final ui.ParagraphStyle paragraphStyle1 = style1.getParagraphStyle(textScaleFactor: 1); + + expect(paragraphStyle0 == paragraphStyle1, true); + }); }