fontique: enumerate macOS system fonts via CTFontManagerCopyAvailableFontURLs - #2
Open
nicoburns wants to merge 1 commit into
Open
fontique: enumerate macOS system fonts via CTFontManagerCopyAvailableFontURLs#2nicoburns wants to merge 1 commit into
nicoburns wants to merge 1 commit into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Speeds up system font enumeration in the CoreText backend on macOS.
scan_system_fonts()previously didCTFontCollection::from_available_fonts()→matching_font_descriptors()→ per-descriptorkCTFontURLAttributelookup, which materializes a font descriptor for every face just to recover file URLs. On macOS this is replaced withCTFontManagerCopyAvailableFontURLs()(already exposed byobjc2-core-textbehind theCTFontManagerfeature), which returns the font file URLs directly.The enumeration is factored into
system_font_files() -> Option<HashSet<PathBuf>>:#[cfg(target_os = "macos")]:CTFontManagerCopyAvailableFontURLs→ POSIX paths → dedupe.#[cfg(not(target_os = "macos"))](iOS etc.): the previous descriptor-based path, unchanged —CTFontManagerCopyAvailableFontURLsis macOS-only and referencing it on other Apple targets would fail to link.Behavior is otherwise unchanged: paths are deduped into a
HashSet<PathBuf>, still extended withlibrary_font_files()(Apple hides SFNS.ttf etc. from these APIs), andscan_system_fonts()still returnsNoneon failure/empty so the caller falls back.Deliberately narrow: parallel scanning and caching are being done separately.
Verified with
cargo check/clippy -p fontique --features systemforaarch64-apple-darwinandaarch64-apple-ios, pluscargo fmt --check.Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/5893bf8aee24455699895691e86d1c32
Requested by: @nicoburns