From 5bf5a200ada9ba03ca2a12c1503318a97166d7c7 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 25 Jul 2024 17:37:49 +0200 Subject: pc: show fps --- pixel-client/src/render/font.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (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 43df9ca7..95cb3fab 100644 --- a/pixel-client/src/render/font.rs +++ b/pixel-client/src/render/font.rs @@ -42,20 +42,22 @@ impl FontTextures { } impl<'a> Renderer<'a> { - pub fn draw_text(&mut self, position: Vec2, text: &str) -> Vec2 { + pub fn draw_text( + &mut self, + position: Vec2, + text: &str, + scale: f32, + tint: Option<[u8; 4]>, + ) -> 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]; - self.draw_ui(SpriteDraw::overlay( - r, - cursor, - Vec2::new(r.width() as f32, r.height() as f32), - None, - )); - cursor.x += r.width() as f32; - line_height = line_height.max(r.height() as f32) + let size = Vec2::new(r.width() as f32, r.height() as f32) * scale; + self.draw_ui(SpriteDraw::overlay(r, cursor, size, tint)); + cursor.x += size.x; + line_height = line_height.max(size.y) } } (cursor - position.y) + Vec2::Y * line_height -- cgit v1.2.3-70-g09d2