Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Use static keyword with `LazyLock` when loading system fonts (#34555)

tidely7e3fd7bb0200
diff --git a/crates/gpui/src/svg_renderer.rs b/crates/gpui/src/svg_renderer.rs
index 08d281b850c..0107624bc8d 100644
--- a/crates/gpui/src/svg_renderer.rs
+++ b/crates/gpui/src/svg_renderer.rs
@@ -27,7 +27,7 @@ pub enum SvgSize {
impl SvgRenderer {
pub fn new(asset_source: Arc<dyn AssetSource>) -> Self {
- let font_db = LazyLock::new(|| {
+ static FONT_DB: LazyLock<Arc<usvg::fontdb::Database>> = LazyLock::new(|| {
let mut db = usvg::fontdb::Database::new();
db.load_system_fonts();
Arc::new(db)
@@ -36,7 +36,7 @@ impl SvgRenderer {
let font_resolver = Box::new(
move |font: &usvg::Font, db: &mut Arc<usvg::fontdb::Database>| {
if db.is_empty() {
- *db = font_db.clone();
+ *db = FONT_DB.clone();
}
default_font_resolver(font, db)
},