diff --git a/crates/egui/src/containers/window.rs b/crates/egui/src/containers/window.rs index 438d562ede7..90b28a1d399 100644 --- a/crates/egui/src/containers/window.rs +++ b/crates/egui/src/containers/window.rs @@ -470,7 +470,7 @@ impl<'open> Window<'open> { let (title_bar_height, title_content_spacing) = if with_title_bar { let style = ctx.style(); let spacing = window_margin.top + window_margin.bottom; - let height = ctx.fonts(|f| title.font_height(f, &style)) + spacing; + let height = ctx.fonts(|f| title.font_height(f, &style)).round() + spacing; window_frame.rounding.ne = window_frame.rounding.ne.clamp(0.0, height / 2.0); window_frame.rounding.nw = window_frame.rounding.nw.clamp(0.0, height / 2.0); (height, spacing) diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index ee77888f811..f0a30ee2fcf 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -708,6 +708,7 @@ impl Ui { /// The height of text of this text style pub fn text_style_height(&self, style: &TextStyle) -> f32 { self.fonts(|f| f.row_height(&style.resolve(self.style()))) + .round() } /// Screen-space rectangle for clipping what we paint in this ui. diff --git a/crates/egui/src/widget_text.rs b/crates/egui/src/widget_text.rs index 03b8cbb9751..b7a44083005 100644 --- a/crates/egui/src/widget_text.rs +++ b/crates/egui/src/widget_text.rs @@ -269,7 +269,7 @@ impl RichText { if let Some(family) = &self.family { font_id.family = family.clone(); } - fonts.row_height(&font_id) + fonts.row_height(&font_id).round() } /// Append to an existing [`LayoutJob`] diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 28a578ee694..a3f72c089a6 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -204,7 +204,9 @@ impl Widget for Button<'_> { } let space_available_for_image = if let Some(text) = &text { - let font_height = ui.fonts(|fonts| text.font_height(fonts, ui.style())); + let font_height = ui + .fonts(|fonts| text.font_height(fonts, ui.style())) + .round(); Vec2::splat(font_height) // Reasonable? } else { ui.available_size() - 2.0 * button_padding diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 7bd4e8db8e5..5f355e13983 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -487,7 +487,7 @@ impl<'t> TextEdit<'t> { let prev_text = text.as_str().to_owned(); let font_id = font_selection.resolve(ui.style()); - let row_height = ui.fonts(|f| f.row_height(&font_id)); + let row_height = ui.fonts(|f| f.row_height(&font_id)).round(); const MIN_WIDTH: f32 = 24.0; // Never make a [`TextEdit`] more narrow than this. let available_width = (ui.available_width() - margin.sum().x).at_least(MIN_WIDTH); let desired_width = desired_width.unwrap_or_else(|| ui.spacing().text_edit_width); diff --git a/crates/egui_demo_lib/src/demo/scrolling.rs b/crates/egui_demo_lib/src/demo/scrolling.rs index 7a2ca4d7c9f..75deb90e6e6 100644 --- a/crates/egui_demo_lib/src/demo/scrolling.rs +++ b/crates/egui_demo_lib/src/demo/scrolling.rs @@ -191,7 +191,7 @@ fn huge_content_painter(ui: &mut egui::Ui) { ui.add_space(4.0); let font_id = TextStyle::Body.resolve(ui.style()); - let row_height = ui.fonts(|f| f.row_height(&font_id)) + ui.spacing().item_spacing.y; + let row_height = ui.fonts(|f| f.row_height(&font_id)).round() + ui.spacing().item_spacing.y; let num_rows = 10_000; ScrollArea::vertical() diff --git a/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs b/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs index 17d3858f7a7..13702fb3027 100644 --- a/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs +++ b/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs @@ -162,7 +162,7 @@ fn bullet_point(ui: &mut Ui, width: f32) -> Response { fn numbered_point(ui: &mut Ui, width: f32, number: &str) -> Response { let font_id = TextStyle::Body.resolve(ui.style()); - let row_height = ui.fonts(|f| f.row_height(&font_id)); + let row_height = ui.fonts(|f| f.row_height(&font_id)).round(); let (rect, response) = ui.allocate_exact_size(vec2(width, row_height), Sense::hover()); let text = format!("{number}."); let text_color = ui.visuals().strong_text_color();