Add support for setting font features on Linux
Fixes #15752.
- Updated
cosmic_textto 0.14.0 - Made a basic implementation for setting font features.
#12176 is not fixed by this PR.
Release Notes:
- Added initial support for
font_featureson Linux
We require contributors to sign our Contributor License Agreement, and we don't have @peppidesu on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
@cla-bot check
The cla-bot has been summoned, and re-checked this pull request!
Is the CI hanging? edit: nevermind
disclaimer: not familiar with the idea of font features. How come we're caching based on family and features? Are we looking for a font based on family and what features it supports?
If I understand correctly, it's because the same font can provide different glyphs depending on what font-features are enabled.
If I understand correctly, it's because the same font can provide different glyphs depending on what font-features are enabled.
This is indeed the case. If for example the UI and the buffer use the same font, but different feature sets, the buffer would otherwise use the UI font features.
Granted, this is not optimal because the font is loaded multiple times now, but I wanted to wait with making the code "good" until I got some input from the community.
EDIT: The mac implementation seems to use the same strategy for this.
does it resolve also https://github.com/zed-industries/zed/issues/17784 ?
does it resolve also #17784 ?
Yes. Enabling and disabling ligatures works, but the ligatures are not always properly rendered.
Hey, sorry I lost track of this. Is this ready to go @peppidesu?
@probably-neb all good!
Thanks for doing this!
Getting a panic that's likely related to this. Doesn't seem to always happen, but my current workspace state causes it to occur whenever I start a zed debug build.
Looking into it.
Thread "main" panicked with "index out of bounds: the len is 12 but the index is 14" at crates/gpui/src/platform/linux/text_system.rs:401:47
https://github.com/zed-industries/zed/blob/3ea86da16ff786578b295f4b3154960ac0180aa8/src/crates/gpui/src/platform/linux/text_system.rs#L401 (may not be uploaded, line may be incorrect if files modified)
0: zed::reliability::init_panic_hook::{{closure}}
at /home/mgsloan/proj/zed/crates/zed/src/reliability.rs:56:29
1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/alloc/src/boxed.rs:1990:9
std::panicking::rust_panic_with_hook
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/std/src/panicking.rs:839:13
2: std::panicking::begin_panic_handler::{{closure}}
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/std/src/panicking.rs:704:13
3: std::sys::backtrace::__rust_end_short_backtrace
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/std/src/sys/backtrace.rs:168:18
4: rust_begin_unwind
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/std/src/panicking.rs:695:5
5: core::panicking::panic_fmt
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/core/src/panicking.rs:75:14
6: core::panicking::panic_bounds_check
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/core/src/panicking.rs:273:5
7: <usize as core::slice::index::SliceIndex<[T]>>::index
at /home/mgsloan/.rustup/toolchains/1.86-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/index.rs:274:10
8: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
at /home/mgsloan/.rustup/toolchains/1.86-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/index.rs:16:9
<alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
at /home/mgsloan/.rustup/toolchains/1.86-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:3358:9
9: gpui::platform::linux::text_system::CosmicTextSystemState::layout_line
at /home/mgsloan/proj/zed/crates/gpui/src/platform/linux/text_system.rs:401:47
10: <gpui::platform::linux::text_system::CosmicTextSystem as gpui::platform::PlatformTextSystem>::layout_line
at /home/mgsloan/proj/zed/crates/gpui/src/platform/linux/text_system.rs:182:9
11: gpui::text_system::line_layout::LineLayoutCache::layout_line
at /home/mgsloan/proj/zed/crates/gpui/src/text_system/line_layout.rs:561:17
12: gpui::text_system::line_layout::LineLayoutCache::layout_wrapped_line
at /home/mgsloan/proj/zed/crates/gpui/src/text_system/line_layout.rs:503:36
13: gpui::text_system::WindowTextSystem::shape_text::{{closure}}
at /home/mgsloan/proj/zed/crates/gpui/src/text_system.rs:450:26
14: gpui::text_system::WindowTextSystem::shape_text
at /home/mgsloan/proj/zed/crates/gpui/src/text_system.rs:492:13
15: gpui::elements::text::TextLayout::layout::{{closure}}
at /home/mgsloan/proj/zed/crates/gpui/src/elements/text.rs:355:35
16: <alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut
at /home/mgsloan/.rustup/toolchains/1.86-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1983:9
17: gpui::taffy::TaffyLayoutEngine::compute_layout::{{closure}}
at /home/mgsloan/proj/zed/crates/gpui/src/taffy.rs:193:21
Looks like the problem is that font_id_for_cosmic_id is another path that updates loaded_fonts_store but does not push to features_store.
Looks like the problem is that
font_id_for_cosmic_idis another path that updatesloaded_fonts_storebut does not push tofeatures_store.
i see, mb. I'll probably combine these lists into one using a wrapper struct, that way i can locate more bugs of the same nature. can you make/link a new issue for this?
@peppidesu Thanks for taking a look! I decided to go ahead and implement a fix myself
Fix is in #30601