Repository navigation
fix(text): share Linux fontconfig collection process-wide and add prewarm_system_fonts - #2660
Merged
Merged
Conversation
…warm_system_fonts
pascalandr
added a commit
to NeuralNomadsAI/rune
that referenced
this pull request
Nov 27, 2026
Upstream merged the first Android slice (anomalyco#2662, closing anomalyco#2647): the winit activity feature, the getloadavg gate and an android workflow. Taken from upstream: runq.rs, the Android target section of rune's Cargo.toml (the fork's JNI, NDK and AccessKit dependencies now sit in it), android.yml and the changelog entry; the fork's own S0 entry goes. Also from upstream since the last merge: - Cx::touch_controls and hover_none read the host's primary pointer (anomalyco#2638). The fork's cfg(android) constants go; the Android LayerHost calls set_touch_controls(true), as the iOS one does. - rune-text's prewarm_system_fonts (anomalyco#2660): Android's backend answers it with nothing to build ahead. - rav1d without assembly (anomalyco#2641): an x86_64 library with avif links without -Wl,-Bsymbolic, so ANDROID.md's note about it goes. Kept over upstream in android.yml: the android/** push trigger and the apk job, which builds the Kotlin host with the example. Checked: clippy for both Android targets (let_underscore_must_use allowed, as rune-core fails it upstream), an x86_64 cdylib with avif links, check-wasm, cargo check, file-size, rune lib tests 4087 passed with the 4 failures upstream dev has on Windows (and one more that passes alone).
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.
Fixes #2657.
Problem
On Linux/Unix,
crates/rune-text/src/fonts/system_fonts/fontconfig.rsstoredfontique::Collectionin athread_local!, so every thread that hit a character absent from bundled fonts built its own fontconfig collection (~240–400 ms on the UI/layout thread) and apps had no way to warm fontconfig ahead of time on a background thread.Changes
WarmSlot<Collection>): Replaced thethread_local!fontconfig collection incrates/rune-text/src/fonts/system_fonts/fontconfig.rswith a single process-wideOnceLock<Mutex<Collection>>(WarmSlotincrates/rune-text/src/fonts/system_fonts/warm.rs). Concurrent callers coalesce onto one initialization and share the resulting collection and caches across all threads.rune::text::prewarm_system_fonts()): Addedrune_text::prewarm_system_fonts()(re-exported asrune::text::prewarm_system_fonts()). Calling it frommain,on_ready, or any thread returns immediately and builds fontconfig's shared collection on a background thread ("rune-font-prewarm"). Repeated calls are idempotent; layout waiting on an in-flight warm-up waits for that single build rather than starting a second one. RespectsRUNE_SYSTEM_FONTS=offandset_system_fonts(false)(no thread spawned, no fontconfig init), and is a no-op on macOS/iOS, Windows, Android, andwasm32.fontconfig::family_fileswhennamesis empty and infontconfig::fallback_family_fileswhen no non-Common/Inherited/Unknown scripts are present.crates/rune-text/src/fonts/system_fonts/warm_tests.rscovering cross-thread sharing, non-blocking background warm-up, single-build coalescing, disabled-switch gating, andCollectionsharing; extendedcrates/rune-text/tests/no_system_fonts.rs; updatedcrates/rune/README.mdand added a changelog entry.Verification
cargo test -p rune-text --lib system_fonts(33 passed, including 5 newwarmtests)cargo test -p rune-text --test no_system_fonts(1 passed)cargo check -p rune --libcargo check -p rune-text --target wasm32-unknown-unknownfontconfig_empty_queries_do_not_initialize_or_fail, and real Linux frame-timing measurements rely on Linux CI / real Linux hosts.