Override gpui-component theme font so the Input picks up Geist
Found the actual root cause of "fonts still wrong" by reading gpui-component source. Input, tooltip, context menu, search popover, notification, and inspector all set `font_family(cx.theme().font_family)` on their root div directly — they don't inherit from the parent's text style. Default theme value is `.SystemUIFont` (SF Pro on macOS), so the omnibar Input the user actually types into was rendering in SF Pro while every chrome surface around it rendered Geist. After fonts register, mutate the theme global so its `font_family` is `"Geist"`. Now every gpui-component sub-element uses the same sans as the rest of the app. cargo test --workspace: 440 passed, 0 failed.
This commit is contained in:
@@ -63,6 +63,17 @@ fn main() {
|
||||
if let Err(error) = shell::chrome::register_serif_fonts(cx) {
|
||||
eprintln!("ELY: failed to register serif fonts: {error}");
|
||||
}
|
||||
// gpui-component's Input, tooltip, context menu, search popover,
|
||||
// notification surface, etc. all read their font from
|
||||
// `cx.theme().font_family` directly instead of inheriting from
|
||||
// the parent. Default theme value is `.SystemUIFont` (SF Pro on
|
||||
// macOS), so without this override the user types into the
|
||||
// omnibar in SF Pro while every other surface renders Geist —
|
||||
// exactly the "fonts still wrong" the screenshot showed.
|
||||
// Override the theme so every gpui-component sub-element uses
|
||||
// Geist too.
|
||||
gpui_component::Theme::global_mut(cx).font_family =
|
||||
shell::chrome::SANS_FAMILY.into();
|
||||
cx.on_action(quit);
|
||||
bind_shortcuts(cx);
|
||||
cx.on_action(open_private_window);
|
||||
|
||||
Reference in New Issue
Block a user