Apple Text Measurement

0•

Measures rendered text sizes and per-line metrics for Apple's TextKit and UI frameworks to ensure pixel-perfect layouts.

This skill provides precise guidance on measuring strings, attributed strings, and view dimensions within Apple's text stack (TextKit 1 and 2). It helps developers navigate the complexities of boundingRect, sizeThatFits, and intrinsicContentSize while accounting for specific rendering details like lineFragmentPadding and textContainerInset. Use this skill to solve common layout issues where text clips by a few pixels, multi-line strings don't size correctly, or when you need to extract specific line-by-line metrics for custom UI components in iOS and macOS applications.

Key Features

010 GitHub stars
02Multi-line measurement using boundingRect with usesLineFragmentOrigin
03Handling auto-shrink logic with NSStringDrawingContext
04TextKit 1 and 2 per-line metrics and fragment enumeration
05Automatic view sizing for UITextView and UILabel
06Correcting for padding and inset arithmetic in measurements

Use Cases

01Calculating the exact height needed for self-sizing table view cells containing UITextView
02Debugging pixel-level text clipping issues in complex typography layouts
03Implementing custom 'Read More' logic by calculating accurate line counts