9.6 · TextKit 1 and 2, and Text in SwiftUI

Text is the most complicated thing a UI draws: scripts, directions, fonts, wrapping, selection. TextKit is the engine under almost every text view.

Mental model. A text view is a storage (the characters), a layout engine (lines and glyphs) and a container (the shape to fill). Change one of the three, and the others follow.

The text system

TextKit 1 and 2, and how SwiftUI relates.

  1. How is TextKit structured, how do TextKit 1 and 2 differ, and how do UILabel, UITextView and SwiftUI Text relate? 9.6.1 · L5
    TextKit separates three roles. The text storage (NSTextStorage, an NSMutableAttributedString) holds the characters and attributes (font, colour, paragraph…

More in Layout, rendering & animation