From baa45173d191f4f63a0aad70ffa9f296223b1ca8 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 27 Sep 2024 20:44:23 +0800 Subject: [PATCH] button: Fix Button text to align vertical center. (#286) image The point is add `.font_family(".SystemUIFont")` to root view. --- crates/app/src/story_workspace.rs | 1 + crates/ui/src/button.rs | 15 +-------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/crates/app/src/story_workspace.rs b/crates/app/src/story_workspace.rs index eda08fa9..8c83bcec 100644 --- a/crates/app/src/story_workspace.rs +++ b/crates/app/src/story_workspace.rs @@ -284,6 +284,7 @@ impl Render for StoryWorkspace { let notifications_count = cx.notifications().len(); div() + .font_family(".SystemUIFont") .relative() .size_full() .flex() diff --git a/crates/ui/src/button.rs b/crates/ui/src/button.rs index 5c0e0173..6db5c000 100644 --- a/crates/ui/src/button.rs +++ b/crates/ui/src/button.rs @@ -314,13 +314,6 @@ impl RenderOnce for Button { _ => self.size, }; - // Hotfix the font vertical center for macOS. - let text_offset_top = if cfg!(target_os = "windows") { - px(0.) - } else { - px(2.) - }; - self.base .id(self.id) .flex() @@ -443,13 +436,7 @@ impl RenderOnce for Button { ) }) .when_some(self.label, |this, label| { - this.child( - div() - .flex_none() - .mt(text_offset_top) - .line_height(relative(1.)) - .child(label), - ) + this.child(div().flex_none().line_height(relative(1.)).child(label)) }) .children(self.children) })