From 8a87928fca249630c8028435113102ac9129a6c7 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sat, 17 Sep 2022 13:35:52 +0200 Subject: [PATCH] Fixes baseline of text after inverting Y axis for UI --- crates/bevy_text/src/glyph_brush.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/bevy_text/src/glyph_brush.rs b/crates/bevy_text/src/glyph_brush.rs index 592cd0c26dc61..d0227648b6301 100644 --- a/crates/bevy_text/src/glyph_brush.rs +++ b/crates/bevy_text/src/glyph_brush.rs @@ -73,15 +73,11 @@ impl GlyphBrush { }) .collect::, _>>()?; - let mut max_y = std::f32::MIN; let mut min_x = std::f32::MAX; for sg in &glyphs { let glyph = &sg.glyph; - let scaled_font = sections_data[sg.section_index].3; - max_y = max_y.max(glyph.position.y - scaled_font.descent()); min_x = min_x.min(glyph.position.x); } - max_y = max_y.floor(); min_x = min_x.floor(); let mut positioned_glyphs = Vec::new(); @@ -119,7 +115,7 @@ impl GlyphBrush { let size = Vec2::new(glyph_rect.width(), glyph_rect.height()); let x = bounds.min.x + size.x / 2.0 - min_x; - let y = max_y - bounds.max.y + size.y / 2.0; + let y = bounds.max.y - size.y / 2.0; let position = adjust.position(Vec2::new(x, y)); positioned_glyphs.push(PositionedGlyph {