diff options
Diffstat (limited to 'pixel-client/src/render')
-rw-r--r-- | pixel-client/src/render/font.rs | 20 |
1 files changed, 11 insertions, 9 deletions
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 |