Update cosmic text to 0.13.2 (#27362)

Related #14222

Release Notes:

- This PR updates `cosmic-text` dependency on `gpui` crate from `0.11.2`
to 0.13.2`. This decreases RAM usage zed depending on the amount of
monospace fonts installed on the system. On Arch Linux with `nerd-fonts`
package installed (which provides around 2000 monospaced fonts), it
decreases ram usage from ~800mb to around ~300mb.

- Updated `cosmic-text` to `0.13.2` on `gpui` crate
This commit is contained in:
Alvaro Parker 2025-03-24 10:37:41 -03:00 committed by GitHub
parent 7db9077835
commit ddf8d07f02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 24 deletions

53
Cargo.lock generated
View file

@ -1045,7 +1045,7 @@ dependencies = [
"serde_path_to_error", "serde_path_to_error",
"serde_qs 0.10.1", "serde_qs 0.10.1",
"smart-default", "smart-default",
"smol_str", "smol_str 0.1.24",
"thiserror 1.0.69", "thiserror 1.0.69",
"tokio", "tokio",
] ]
@ -3420,17 +3420,18 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-text" name = "cosmic-text"
version = "0.11.2" version = "0.13.2"
source = "git+https://github.com/pop-os/cosmic-text?rev=542b20c#542b20ca4376a3b5de5fa629db1a4ace44e18e0c" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e418dd4f5128c3e93eab12246391c54a20c496811131f85754dc8152ee207892"
dependencies = [ dependencies = [
"bitflags 2.8.0", "bitflags 2.8.0",
"fontdb 0.18.0", "fontdb 0.16.2",
"log", "log",
"rangemap", "rangemap",
"rayon",
"rustc-hash 1.1.0", "rustc-hash 1.1.0",
"rustybuzz 0.14.1", "rustybuzz 0.14.1",
"self_cell", "self_cell",
"smol_str 0.2.2",
"swash", "swash",
"sys-locale", "sys-locale",
"ttf-parser 0.21.1", "ttf-parser 0.21.1",
@ -5102,9 +5103,9 @@ dependencies = [
[[package]] [[package]]
name = "font-types" name = "font-types"
version = "0.7.3" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3971f9a5ca983419cdc386941ba3b9e1feba01a0ab888adf78739feb2798492" checksum = "d868ec188a98bb014c606072edd47e52e7ab7297db943b0b28503121e1d037bd"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
] ]
@ -5120,16 +5121,16 @@ dependencies = [
[[package]] [[package]]
name = "fontdb" name = "fontdb"
version = "0.18.0" version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e32eac81c1135c1df01d4e6d4233c47ba11f6a6d07f33e0bba09d18797077770" checksum = "b0299020c3ef3f60f526a4f64ab4a3d4ce116b1acbf24cdd22da0068e5d81dc3"
dependencies = [ dependencies = [
"fontconfig-parser", "fontconfig-parser",
"log", "log",
"memmap2", "memmap2",
"slotmap", "slotmap",
"tinyvec", "tinyvec",
"ttf-parser 0.21.1", "ttf-parser 0.20.0",
] ]
[[package]] [[package]]
@ -11218,9 +11219,9 @@ dependencies = [
[[package]] [[package]]
name = "read-fonts" name = "read-fonts"
version = "0.22.5" version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a04b892cb6f91951f144c33321843790c8574c825aafdb16d815fd7183b5229" checksum = "f6f9e8a4f503e5c8750e4cd3b32a4e090035c46374b305a15c70bad833dca05f"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"font-types", "font-types",
@ -12840,9 +12841,9 @@ checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
[[package]] [[package]]
name = "skrifa" name = "skrifa"
version = "0.22.3" version = "0.26.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e1c44ad1f6c5bdd4eefed8326711b7dbda9ea45dfd36068c427d332aa382cbe" checksum = "8cc1aa86c26dbb1b63875a7180aa0819709b33348eb5b1491e4321fae388179d"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"read-fonts", "read-fonts",
@ -12919,6 +12920,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "smol_str"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead"
[[package]] [[package]]
name = "snippet" name = "snippet"
version = "0.1.0" version = "0.1.0"
@ -13564,9 +13571,9 @@ dependencies = [
[[package]] [[package]]
name = "swash" name = "swash"
version = "0.1.19" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbd59f3f359ddd2c95af4758c18270eddd9c730dde98598023cdabff472c2ca2" checksum = "13d5bbc2aa266907ed8ee977c9c9e16363cc2b001266104e13397b57f1d15f71"
dependencies = [ dependencies = [
"skrifa", "skrifa",
"yazi", "yazi",
@ -14886,6 +14893,12 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "ttf-parser"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
[[package]] [[package]]
name = "ttf-parser" name = "ttf-parser"
version = "0.21.1" version = "0.21.1"
@ -17235,9 +17248,9 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
[[package]] [[package]]
name = "yazi" name = "yazi"
version = "0.1.6" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c94451ac9513335b5e23d7a8a2b61a7102398b8cca5160829d313e84c9d98be1" checksum = "e01738255b5a16e78bbb83e7fbba0a1e7dd506905cfc53f4622d89015a03fbb5"
[[package]] [[package]]
name = "yeslogic-fontconfig-sys" name = "yeslogic-fontconfig-sys"
@ -17568,9 +17581,9 @@ dependencies = [
[[package]] [[package]]
name = "zeno" name = "zeno"
version = "0.2.3" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd15f8e0dbb966fd9245e7498c7e9e5055d9e5c8b676b95bd67091cd11a1e697" checksum = "cc0de2315dc13d00e5df3cd6b8d2124a6eaec6a2d4b6a1c5f37b7efad17fcc17"
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"

View file

@ -153,7 +153,7 @@ blade-graphics = { workspace = true, optional = true }
blade-macros = { workspace = true, optional = true } blade-macros = { workspace = true, optional = true }
blade-util = { workspace = true, optional = true } blade-util = { workspace = true, optional = true }
bytemuck = { version = "1", optional = true } bytemuck = { version = "1", optional = true }
cosmic-text = { git = "https://github.com/pop-os/cosmic-text", rev = "542b20c", optional = true } cosmic-text = { version = "0.13.2", optional = true }
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "40391b7", features = [ font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "40391b7", features = [
"source-fontconfig-dlopen", "source-fontconfig-dlopen",
], optional = true } ], optional = true }

View file

@ -376,15 +376,13 @@ impl CosmicTextSystemState {
); );
offs += run.len; offs += run.len;
} }
let mut line = ShapeLine::new_in_buffer( let mut line = ShapeLine::new(
&mut self.scratch,
&mut self.font_system, &mut self.font_system,
text, text,
&attrs_list, &attrs_list,
cosmic_text::Shaping::Advanced, cosmic_text::Shaping::Advanced,
4, 4,
); );
let mut layout = Vec::with_capacity(1); let mut layout = Vec::with_capacity(1);
line.layout_to_buffer( line.layout_to_buffer(
&mut self.scratch, &mut self.scratch,