From d1d7c08ce9a911fd958d7c4e46ab5aa6ea008e0f Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Mon, 26 Feb 2024 10:52:59 -0800 Subject: [PATCH] Make sure to call `setHeightOverride` as well on TextStyle and StrutStyle (flutter/engine#50920) This fixes https://github.com/flutter/flutter/issues/143877 We apparently need to call `setHeightOverride(true)` on `TextStyle` and `StrutStyle` objects in order to properly apply the height. --- engine/src/flutter/lib/web_ui/skwasm/text/strut_style.cpp | 1 + engine/src/flutter/lib/web_ui/skwasm/text/text_style.cpp | 1 + engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/engine/src/flutter/lib/web_ui/skwasm/text/strut_style.cpp b/engine/src/flutter/lib/web_ui/skwasm/text/strut_style.cpp index 41f9edf52e7..f3c7ea0d2fa 100644 --- a/engine/src/flutter/lib/web_ui/skwasm/text/strut_style.cpp +++ b/engine/src/flutter/lib/web_ui/skwasm/text/strut_style.cpp @@ -33,6 +33,7 @@ SKWASM_EXPORT void strutStyle_setFontSize(StrutStyle* style, SKWASM_EXPORT void strutStyle_setHeight(StrutStyle* style, SkScalar height) { style->setHeight(height); + style->setHeightOverride(true); } SKWASM_EXPORT void strutStyle_setHalfLeading(StrutStyle* style, diff --git a/engine/src/flutter/lib/web_ui/skwasm/text/text_style.cpp b/engine/src/flutter/lib/web_ui/skwasm/text/text_style.cpp index b520f52a542..c0a50451fb1 100644 --- a/engine/src/flutter/lib/web_ui/skwasm/text/text_style.cpp +++ b/engine/src/flutter/lib/web_ui/skwasm/text/text_style.cpp @@ -96,6 +96,7 @@ SKWASM_EXPORT void textStyle_setWordSpacing(TextStyle* style, SKWASM_EXPORT void textStyle_setHeight(TextStyle* style, SkScalar height) { style->setHeight(height); + style->setHeightOverride(true); } SKWASM_EXPORT void textStyle_setHalfLeading(TextStyle* style, diff --git a/engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart b/engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart index 60b95664787..66813ff44c4 100644 --- a/engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart @@ -68,6 +68,11 @@ Future testMain() async { layoutWidth: 50, paragraphHeight: 1.5); }); + test('text styles - text style height overriding paragraph height', () async { + await testTextStyle('text style height and paragraph style height', + layoutWidth: 50, paragraphHeight: 1.5, height: 2.0); + }); + test('text styles - paragraph text height behavior', () async { await testTextStyle('paragraph text height behavior', layoutWidth: 50,