Text does not render negative line spacing values

Number:rdar://FB9842474 Date Originated:1/12/2022
Status:Open Resolved:
Product:SwiftUI Framework Product Version:iOS 15
Classification:Incorrect/Unexpected Behavior Reproducible:Yes
There is no public API in SwiftUI for rendering Text with a precise negative line spacing, which is a very common design requirement.

When a negative line spacing is provided to the `.lineSpacing(…)` view modifier, the `Text` does not respect it, and instead renders with a zero line spacing.

There is a view modifier that enables "tight" line spacing, `.leading(.tight)`, but it does not allow fine-grained control of the line spacing in `Text`, preventing you from achieving pixel-perfect designs.

Finally there is a private/underscore-prefixed API that enables this behavior on `View`, `_lineHeightMultiple(…)`, but it is only visible in the SwiftUI `swiftinterface` and is furthermore marked as deprecated, so it doesn't seem advisable to rely on it.


_lineHeightMultiple is available as an environment key, so environment(._lineHeightMultiple) helps in iOS 17.

Still would love to have an option for negative space

By agapov.one at Feb. 19, 2024, 9:31 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!