Skip to content

fontique: add persistent cache for system font scans on macOS - #4

Open
nicoburns wants to merge 3 commits into
devin/1785890299-parallel-font-scanfrom
devin/1785891021-scan-cache
Open

fontique: add persistent cache for system font scans on macOS#4
nicoburns wants to merge 3 commits into
devin/1785890299-parallel-font-scanfrom
devin/1785891021-scan-cache

Conversation

@nicoburns

Copy link
Copy Markdown
Member

Summary

Stacked on #3. Adds a persistent scan cache so warm app startups skip parsing font files entirely.

New scan_cache module stores, per scanned file, a FileStamp { mtime_secs, mtime_nanos, size } plus the extracted FontRecords (family names, postscript name, index, width/style/weight, variation axes, CharmapIndex). ScannedCollection::from_paths_cached(paths, max_depth, cache_path) stats each discovered file, reuses cached records when the stamp matches, parses only new/changed files in parallel, and rewrites the cache when anything was parsed or a cached file disappeared:

cache hit  = stamp(path) == cached.stamp  -> reuse records (fresh SourceId per run)
cache miss -> parse in parallel           -> records added to rewritten cache

Format is a hand-rolled little-endian binary encoding (no new dependencies) with a magic number + version; any decode failure falls back to a full rescan that rewrites the cache. Writes go to a temp file + rename so readers never see a partial cache. Runtime IDs (SourceId/FamilyId) are never persisted — they're regenerated on load. attr_axes is recomputed from the cached axes rather than stored.

The CoreText backend now uses ~/Library/Caches/fontique/font-scan-cache.bin (falling back to an uncached scan if home_dir() is unavailable). Open question for review: whether the cache path should instead be configurable via API (e.g. on CollectionOptions, which is currently Copy) — happy to change the plumbing.

Includes a hermetic test (using parley_dev font assets) verifying every cached attribute round-trips identically and that changed files are re-parsed.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/60a3d833a0894a73945c806adff1cbf3
Requested by: @nicoburns

@nicoburns nicoburns self-assigned this Aug 5, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant