1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Minor tweaks

This commit is contained in:
Emil Ernerfeldt
2024-09-19 10:57:23 +02:00
parent fee27cf796
commit cada7d2be2
3 changed files with 9 additions and 6 deletions

View File

@@ -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;

View File

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

View File

@@ -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`]