Let's Make That Label With CoreText
summary
Builds a UILabel-like view using CoreText that actually works: creates CTLine/CTRun, fixes the flipped coordinate system and baseline by subtracting descent from the text position, and implements truncation with CTLineCreateTruncatedLine using U+2026. Wraps text into arbitrary shapes with CTFramesetter + CGPath, obtains ascent/descent/leading for accurate line spacing, draws glyphs by converting them to paths via CTFontCreatePathForGlyph and fills them, registers downloadable fonts with CTFontManagerRegisterGraphicsFont, and applies pixel-rounding to get crisp edges.
AI-written summary · about
chapters (30)
- 0:00Introduction
- 1:02Who am I
- 1:16Why use CoreText
- 2:04Alternatives
- 3:43API
- 5:35Drawing
- 6:33Font Matrix
- 6:54Baseline
- 7:44Label
- 8:18UI View
- 9:07Draw
- 11:27Text
- 13:09Text Position
- 14:45Text Length
- 15:31Truncation
- 18:41Shapes
- 18:55Lines
- 20:04Transform Origins
- 21:08Style Brand
- 23:42DrawPath
- 23:52CreatePath
- 24:47Custom Layout
- 24:59New Example
- 27:08Typesetter
- 29:20Get Size That Fits
- 31:28Font Management
- 32:39Alignment
- 36:31Where is my label
- 37:53Conclusion
- 38:16Contact
related talks
31mTypography on iOS
47mMagic Words – Harnessing the Power of TextKit
38mHow to Tame Core Animation
18mThe Amazing Race; Performance of Standard iOS Elements & Tech
47mPixel perfect is dead, long live to adaptive and accessible iOS apps
29mHow to Tame Core Animation
36mSwiftUI Everywhere
38mSwiftUI and SVG
