button: Fix Button text to align vertical center. (#286)

<img width="1188" alt="image"
src="https://github.com/user-attachments/assets/084727c3-5822-4325-9bbf-374b357b670f">

The point is add `.font_family(".SystemUIFont")` to root view.
This commit is contained in:
Jason Lee 2024-09-27 20:44:23 +08:00 committed by GitHub
parent 2b134e47a1
commit baa45173d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 14 deletions

View file

@ -284,6 +284,7 @@ impl Render for StoryWorkspace {
let notifications_count = cx.notifications().len();
div()
.font_family(".SystemUIFont")
.relative()
.size_full()
.flex()

View file

@ -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)
})