A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
font: build the built-in font database once per process
RoversX505c9a6239dd
diff --git a/wezterm-font/src/db.rs b/wezterm-font/src/db.rsindex 047dc671..adb8beb7 100644--- a/wezterm-font/src/db.rs+++ b/wezterm-font/src/db.rs@@ -6,11 +6,15 @@ use anyhow::Context;use config::{Config, FontAttributes};use rangeset::RangeSet;use std::collections::{HashMap, HashSet};+use std::sync::{Arc, OnceLock};pub struct FontDatabase {by_full_name: HashMap<String, Vec<ParsedFont>>,}+/// Process-wide built-in font database; see [`FontDatabase::shared_built_in`].+static BUILT_IN: OnceLock<Result<Arc<FontDatabase>, String>> = OnceLock::new();+impl FontDatabase {pub fn new() -> Self {Self {@@ -77,6 +81,34 @@ impl FontDatabase {Ok(db)}+ /// The built-in database, built once per process.+ ///+ /// `with_built_in` takes no arguments and reads only `include_bytes!`+ /// data, so its result cannot vary by config, DPI or window -- yet every+ /// `FontConfiguration` used to build its own, paying ~30 FreeType face+ /// opens and name-table walks each time. That sits on an interactive path:+ /// the terminal-preview fit loop constructs up to `MAX_PREVIEW_SCALE_STEPS`+ /// configurations in a single layout pass, each a cache miss.+ ///+ /// Sharing also shares each `ParsedFont`'s lazily computed `coverage`+ /// (guarded by its own `Mutex`), which each instance would otherwise+ /// recompute for itself.+ ///+ /// Note the one behavioural change: a failure here is cached, so it is+ /// permanent for the process rather than retried per configuration. The+ /// inputs are compiled-in bytes, so a failure is deterministic and a retry+ /// could not have succeeded anyway.+ pub fn shared_built_in() -> anyhow::Result<Arc<Self>> {+ match BUILT_IN.get_or_init(|| {+ Self::with_built_in()+ .map(Arc::new)+ .map_err(|err| format!("{err:#}"))+ }) {+ Ok(db) => Ok(Arc::clone(db)),+ Err(err) => anyhow::bail!("{err}"),+ }+ }+pub fn resolve_multiple(&self,fonts: &[FontAttributes],diff --git a/wezterm-font/src/lib.rs b/wezterm-font/src/lib.rsindex a4bcbb0d..2e0e7c98 100644--- a/wezterm-font/src/lib.rs+++ b/wezterm-font/src/lib.rs@@ -604,7 +604,7 @@ impl FontConfigInner {dpi: RefCell::new(dpi),config: RefCell::new(config.clone()),font_dirs: RefCell::new(Arc::new(FontDatabase::with_font_dirs(&config)?)),- built_in: RefCell::new(Arc::new(FontDatabase::with_built_in()?)),+ built_in: RefCell::new(FontDatabase::shared_built_in()?),fallback_channel: RefCell::new(None),})}