From ecb6ff15c24841dc08ab8f5c3b347c8080720ac4 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 25 Jul 2024 13:50:09 +0200 Subject: pc: main menu background --- pixel-client/src/render/font.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pixel-client/src/render/font.rs') diff --git a/pixel-client/src/render/font.rs b/pixel-client/src/render/font.rs index ff4abade..392c1d66 100644 --- a/pixel-client/src/render/font.rs +++ b/pixel-client/src/render/font.rs @@ -25,8 +25,9 @@ impl FontTextures { } impl<'a> Renderer<'a> { - pub fn draw_text(&mut self, position: Vec2, text: &str) { + pub fn draw_text(&mut self, position: Vec2, text: &str) -> Vec2 { let mut cursor = position; + let mut line_height = 0f32; for c in text.chars() { if (c as u32) < 128 { let r = self.font_textures.glyphs[c as usize]; @@ -37,7 +38,9 @@ impl<'a> Renderer<'a> { None, )); cursor.x += r.width() as f32; + line_height = line_height.max(r.height() as f32) } } + cursor + Vec2::Y * line_height } } -- cgit v1.2.3-70-g09d2