Repository navigation
SkParagraph doesn't account for applyHeightToFirstAscent applyHeightToLastDescent on empty paragraphs with strut enabled #112123
Description
Activity
- addeddependency: skiaSkia team may need to help usSkia team may need to help usa: typographyText rendering, possibly libtxtText rendering, possibly libtxt
on Sep 21, 2022 I tried the example in SkParagraph and the old Libtxt text layout library:
Libtxt
Text painter.height painter. preferredLineHeight painter.size simple 77.0 77.0 (4.0, 77.0) emptyString 77.0 77.0 (0.0, 77.0) emptyParagraph 77.0 77.0 (0.0, 77.0) SkParagraph
Text painter.height painter. preferredLineHeight painter.size simple 8.0 8.0 (4.0, 8.0) emptyString 77.0 8.0 (0.0, 77.0) emptyParagraph 77.0 8.0 (0.0, 77.0) I think that Libtxt's results are correct in this case. SkParagraph does not appear to be applying the strut as intended.
The strut defines a minimum line height that applies to all lines in the paragraph (see https://api.flutter.dev/flutter/painting/StrutStyle-class.html). But for some of these paragraphs SkParagraph is calculating height and preferredLineHeight that is less than the strut height.
SkParagraph does produce results similar to Libtxt if the app does not set the
TextHeightBehavior(applyHeightToFirstAscent: false, applyHeightToLastDescent: false)parameter. So it looks like SkParagraph is improperly allowing theTextHeightBehaviorto override the strut height.Filed a Skia bug: https://bugs.chromium.org/p/skia/issues/detail?id=13766
- addeda: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
on Sep 28, 2022 The fix has landed on the Flutter master branch
(see https://skia.googlesource.com/skia/+/d0ee294bc90fe676458b32417737ecae409a4c21)This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Oct 25, 2022
Steps to Reproduce
"real height" should always be the same as "preferred height" (8 px) in all 3 cases. However right now for both "emptyString" and "emptyParagraph" the reported "real height" is 77.0.