For some fonts, the built-in line spacing is unpleasantly large.
SwiftUI gives us the Text
modifier .lineSpacing()
to adjust the spacing between lines of text (also called the leading, unrelated to leading/trailing). Its value specifies the number of points of additional spacing to place between consecutive lines of text, so that .lineSpacing(0)
results in no change. Unfortunately, it does not appear to respond to negative values; .lineSpacing(-10)
yields the same result as lineSpacing(0)
.
Does anyone know of a way to reduce line spacing in SwiftUI without resorting to UIKit?
While I don't think it's possible to gain free control over negative line spacing in SwiftUI atm — as of Fall '22 all negative values create the same, only marginally tighter leading, no matter the value — you can reduce the leading of the Font itself, by applying .leading(.tight) to the Font. This did tighten a quick test example beyond what the negative value cap of .lineSpacing(-X) seems to achieve.