ZIm/crates/gpui/src/platform/linux
Alvaro Parker 83ad28dfe7
Remove duplicate load_system_fontscall (#19374)
Related comment on issue
https://github.com/zed-industries/zed/issues/14222#issuecomment-2418375056

On `crates/gpui/src/platform/linux/text_system.rs` on method
`CosmicTextSystem::new` `load_system_fonts` is being called twice:
```rust
    pub(crate) fn new() -> Self {
        let mut font_system = FontSystem::new();

        // todo(linux) make font loading non-blocking
        font_system.db_mut().load_system_fonts();

        Self(RwLock::new(CosmicTextSystemState {
            font_system,
            swash_cache: SwashCache::new(),
            scratch: ShapeBuffer::default(),
            loaded_fonts_store: Vec::new(),
            font_ids_by_family_cache: HashMap::default(),
            postscript_names: HashMap::default(),
        }))
    }
```

First one on `FontSystem::new()` and second one is explicit on
`font_system.db_mut().load_system_fonts()`. The first call
`FontSystem::new()` is defined as:
```
    pub fn new() -> Self {
        Self::new_with_fonts(core::iter::empty())
    }
```
And `new_with_fonts`: 
```rust
    /// Create a new [`FontSystem`] with a pre-specified set of fonts.
    pub fn new_with_fonts(fonts: impl IntoIterator<Item = fontdb::Source>) -> Self {
        let locale = Self::get_locale();
        log::debug!("Locale: {}", locale);

        let mut db = fontdb::Database::new();

        //TODO: configurable default fonts
        db.set_monospace_family("Fira Mono");
        db.set_sans_serif_family("Fira Sans");
        db.set_serif_family("DejaVu Serif");

        Self::load_fonts(&mut db, fonts.into_iter());

        Self::new_with_locale_and_db(locale, db)
    }
```
Finally `Self::load_fonts(&mut db, fonts.into_iter())` calls
`load_system_fonts`:
```rust
    #[cfg(feature = "std")]
    fn load_fonts(db: &mut fontdb::Database, fonts: impl Iterator<Item = fontdb::Source>) {
        #[cfg(not(target_arch = "wasm32"))]
        let now = std::time::Instant::now();

        db.load_system_fonts();

        for source in fonts {
            db.load_font_source(source);
        }
        ...
```

Release Notes:

- Remove duplicate font loading on Linux
2024-11-05 12:43:22 +02:00
..
headless zed: Persist window stack order across restarts (#15419) 2024-07-29 17:05:56 +02:00
wayland Revert "Fix blurry cursor on Wayland at a scale other than 100%" (#18642) 2024-10-02 10:44:16 -07:00
x11 gpui: Fix crash caused by ownership leak (#19185) 2024-10-14 12:46:04 -07:00
dispatcher.rs x11 calloop 2 (#13955) 2024-07-08 18:38:36 -06:00
headless.rs WIP: remoting (#10085) 2024-04-11 15:36:35 -06:00
platform.rs Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
text_system.rs Remove duplicate load_system_fontscall (#19374) 2024-11-05 12:43:22 +02:00
wayland.rs Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
x11.rs x11: Add XIM support (#11657) 2024-05-16 15:13:51 -07:00
xdg_desktop_portal.rs Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00