From ea8da43c6bb620d78bf0d96dec65d76f4492dd1b Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Wed, 12 Feb 2025 20:17:00 +0100 Subject: [PATCH] ui: Fix keybind sizing for non-default UI font sizes (#24708) Closes #24597 This fixes the regression from https://github.com/zed-industries/zed/commit/00971fbe415fdc4695307f192134093c7bcd138c which removed the `text_ui(cx)` - call from the keybinding render. The removal caused improperly scaled font rendering as shown in the images below. This PR reintroduces this behaviour for all cases where `size` is not set. | | `main` | With this patch | Parent of https://github.com/zed-industries/zed/commit/00971fbe415fdc4695307f192134093c7bcd138c | --- | ---- | ---- | --- | | Small font size (10px) | cur_small | pr_small | prev_small | | Large font size | cur_big | pr_big | prev_big | Release Notes: - Fixed keybind hints being improperly scaled for custom ui font sizes --- crates/ui/src/components/keybinding.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui/src/components/keybinding.rs b/crates/ui/src/components/keybinding.rs index 4391c9061b..50083c251a 100644 --- a/crates/ui/src/components/keybinding.rs +++ b/crates/ui/src/components/keybinding.rs @@ -230,7 +230,9 @@ pub struct Key { impl RenderOnce for Key { fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { let single_char = self.key.len() == 1; - let size = self.size.unwrap_or(px(14.).into()); + let size = self + .size + .unwrap_or_else(|| TextSize::default().rems(cx).into()); div() .py_0()