Contents

kerning(_:)

Sets the spacing, or kerning, between characters.

Declaration

nonisolated func kerning(_ kerning: CGFloat) -> Text

Parameters

  • kerning:

    The spacing to use between individual characters in this text. Value of 0 sets 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.

[Image]

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:

[Image]

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.

[Image]

See Also

Styling the view’s text