diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 4693efea9..2e2e0db85 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -621,8 +621,7 @@ impl Ui { #[inline] pub fn text_valign(&self) -> Align { #![allow(clippy::unused_self)] - // We currently always center-align, because that makes emojis and text nice and centered everywhere. - Align::Center + Align::BOTTOM } /// Create a painter for a sub-region of this Ui. diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index 414ee1083..b20019eff 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -604,7 +604,12 @@ fn galley_from_rows( glyph.pos.y = cursor_y + glyph.font_impl_ascent - + format.valign.to_factor() * (row_height - glyph.font_impl_height); + + + format.valign.to_factor() * (row_height - glyph.font_impl_height) + + // When mixing different `FontImpl` (e.g. latin and emojis), + // we always center the difference: + + 0.5 * (glyph.font_impl_height - glyph.size.y); 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 3c3a7699d..c614e6ef6 100644 --- a/crates/epaint/src/text/text_layout_types.rs +++ b/crates/epaint/src/text/text_layout_types.rs @@ -301,7 +301,7 @@ impl Default for TextFormat { italics: false, underline: Stroke::NONE, strikethrough: Stroke::NONE, - valign: Align::Center, + valign: Align::BOTTOM, } } }