Declaration
compose().kerning(kerning: number)nonisolated func kerning(_ kerning: CGFloat) -> TextParameters
kerning*numberThe spacing to use between individual characters in this text. Value of
0sets the kerning to the system default value.
Return value
Text with the specified amount of kerning.
Discussion
Kerning defines the offset, in points, that a text view should shift characters from the default spacing. Use positive kerning to widen the spacing between characters. Use negative kerning to tighten the spacing between characters.
VStack(alignment: .leading) {
Text("ABCDEF").kerning(-3)
Text("ABCDEF")
Text("ABCDEF").kerning(3)
}The last character in the first case, which uses negative kerning, experiences cropping because the kerning affects the trailing edge of the text view as well.
Kerning attempts to maintain ligatures. For example, the Hoefler Text font uses a ligature for the letter combination ffl, as in the word raffle, shown here with a small negative and a small positive kerning:
The ffl letter combination keeps a constant shape as the other letters move together or apart. Beyond a certain point in either direction, however, kerning does disable nonessential ligatures.
See also
More in Text modifiers.
- accessibilityHeadingSets the accessibility level of this heading.
- accessibilityLabelAdds a label to the view that describes its contents.
- accessibilityTextContentTypeSets an accessibility text content type.
- baselineOffsetSets the vertical offset for the text relative to its baseline.
- boldApplies a bold font weight to the text.
- fontSets the default font for text in the view.
- fontDesignSets the font design of the text.
- fontWeightSets the font weight of the text.
- fontWidthSets the font width of the text.
- foregroundStyleSets the style of the text displayed by this view.
- italicApplies italics to the text.
- monospacedModifies the font of the text to use the fixed-width variant of the current font, if possible.