Contents

tracking(_:)

Sets the tracking for the text.

Declaration

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

Parameters

  • tracking:

    The amount of additional space, in points, that the view should add to each character cluster after layout. Value of 0 sets the tracking to the system default value.

Return Value

Text with the specified amount of tracking.

Discussion

Tracking adds space, measured in points, between the characters in the text view. A positive value increases the spacing between characters, while a negative value brings the characters closer together.

VStack(alignment: .leading) {
    Text("ABCDEF").tracking(-3)
    Text("ABCDEF")
    Text("ABCDEF").tracking(3)
}

The code above uses an unusually large amount of tracking to make it easy to see the effect.

[Image]

The effect of tracking resembles that of the kerning(_:) modifier, but adds or removes trailing whitespace, rather than changing character offsets. Also, using any nonzero amount of tracking disables nonessential ligatures, whereas kerning attempts to maintain ligatures.

See Also

Styling the view’s text