tornikegomareli

Swift port of chenglou/pretext, pure arithmetic text measurement & layout engine for Apple platforms

25
1
100% credibility
Found Apr 03, 2026 at 25 stars -- GitGems finds repos before they trend. Get early access to the next one.
Sign Up Free
AI Analysis
Swift
AI Summary

PretextKit is a Swift library for Apple platforms that precomputes expensive text measurements to enable instant reflow and sizing in dynamic UIs like feeds, games, and editorial layouts.

How It Works

1
🔍 Discover smooth text magic

You hear about a tool that makes text in apps wrap and resize super smoothly, even around moving shapes or in fast-scrolling lists.

2
🎮 Play with fun demos

Run the example app to watch text flow around bouncing balls, Tetris pieces, or game paddles in real time without lag.

3
Add it to your app

Bring this magic into your own project with a simple copy-paste link, and it starts working right away.

4
📝 Share your text and style

Tell it once about your words and how they should look, like the font size and feel.

5
Resize instantly forever

Now ask how tall the text is at any screen width—answers come back in a blink, perfect for rotations or dynamic layouts.

6
📱 Drop into feeds or games

Use ready-made text boxes in lists, chats, or creative designs where text dances around images or obstacles.

🚀 App scrolls like butter

Your app now feels incredibly responsive with text that reflows smoothly everywhere, delighting users.

Sign up to see the full architecture

5 more

Sign Up Free

Star Growth

See how this repo grew from 25 to 25 stars Sign Up Free
Repurpose This Repo

Repurpose is a Pro feature

Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.

Unlock Repurpose
AI-Generated Review

What is swift-pretextkit?

This Swift GitHub repo ports Cheng Lou's Pretext to Apple platforms, delivering a text measurement engine that does heavy CoreText shaping once upfront, then handles all reflows with pure arithmetic math. iOS and macOS devs get instant height queries and line breaking for any width—sub-microsecond speeds after prep—solving the jank from repeated UILabel sizing or NSAttributedString bounding rects in dynamic UIs. Drop it into UIKit labels or SwiftUI views for feeds, chats, or layouts that resize constantly.

Why is it gaining traction?

It crushes standard text APIs on reflow perf: 500 texts layout in 0.05ms vs 8ms for native calls, with demos like Tetris and bouncing orbs proving 60fps text flowing around obstacles. Handles CJK, Arabic RTL, Thai, and emoji ZWJ intact, plus UIKit prefetch caching and SwiftUI auto-sizing views—real wins for international apps without custom engines. Early traction from those benchmarks and playable stress tests in the repo.

Who should use this?

iOS table/collection view devs prefetching cell heights for social feeds or messaging apps; SwiftUI builders doing masonry grids or editorial spreads with floating images; anyone on Apple platforms fighting scroll jank from text measurement in virtualized lists. Skip if your text is static or changes every frame.

Verdict

Grab it for perf-critical text UIs—demos and accuracy tests (99%+ match to CoreText) show promise despite 25 stars and 1.0% credibility signaling early days. Solid docs and MIT license make it low-risk to prototype, but watch for attributed string support.

(198 words)

Sign up to read the full AI review Sign Up Free

Similar repos coming soon.