diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 8f12e4e0a..f5425980c 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -251,9 +251,9 @@ impl Widget for Button<'_> { if image.is_some() && galley.is_some() { desired_size.x += ui.spacing().icon_spacing; } - if let Some(text) = &galley { - desired_size.x += text.size().x; - desired_size.y = desired_size.y.max(text.size().y); + if let Some(galley) = &galley { + desired_size.x += galley.size().x; + desired_size.y = desired_size.y.max(galley.size().y); } if let Some(shortcut_galley) = &shortcut_galley { desired_size.x += gap_before_shortcut_text + shortcut_galley.size().x; diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index 8399b22cd..caf146120 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -607,7 +607,7 @@ fn galley_from_rows( } max_row_height = point_scale.round_to_pixel(max_row_height); - // Now position each glyph: + // Now position each glyph vertically: for glyph in &mut row.glyphs { let format = &job.sections[glyph.section_index as usize].format; @@ -619,7 +619,7 @@ fn galley_from_rows( // When mixing different `FontImpl` (e.g. latin and emojis), // we always center the difference: - + 0.5 * (glyph.line_height - glyph.font_impl_height); + + 0.5 * (glyph.font_height - glyph.font_impl_height); glyph.pos.y = point_scale.round_to_pixel(glyph.pos.y); } diff --git a/crates/epaint/src/text/text_layout_types.rs b/crates/epaint/src/text/text_layout_types.rs index 856bd1edf..9f87c3e62 100644 --- a/crates/epaint/src/text/text_layout_types.rs +++ b/crates/epaint/src/text/text_layout_types.rs @@ -610,7 +610,10 @@ pub struct Glyph { pub advance_width: f32, - /// Height of this row + /// Height of this row of text. + /// + /// Usually same as [`Self::font_height`], + /// unless explicitly overriden by [`TextFormat::line_height`]. pub line_height: f32, /// [`Font::ascent`]