From 8a1a433f99d3578662878f2112ef6edda2795a3e Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 5 Apr 2022 22:49:34 +0100 Subject: [PATCH] Replace returning number of lines printed to x width --- agb/examples/text_render.rs | 2 +- agb/src/display/font.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/agb/examples/text_render.rs b/agb/examples/text_render.rs index fd4d2a37..602f4267 100644 --- a/agb/examples/text_render.rs +++ b/agb/examples/text_render.rs @@ -35,7 +35,7 @@ fn main(mut gba: agb::Gba) -> ! { vram.remove_dynamic_tile(background_tile); - FONT.render_text(3, 3, "Hello, World!", 1, 2, 100, &mut bg, &mut vram); + FONT.render_text(3, 3, "Hello, World!", 1, 2, &mut bg, &mut vram); bg.commit(); bg.show(); diff --git a/agb/src/display/font.rs b/agb/src/display/font.rs index 72ec062f..ac0ab5c4 100644 --- a/agb/src/display/font.rs +++ b/agb/src/display/font.rs @@ -59,7 +59,6 @@ impl Font { text: &str, foreground_colour: u8, background_colour: u8, - _max_width: i32, bg: &mut RegularMap, vram_manager: &mut VRamManager, ) -> i32 { @@ -89,13 +88,12 @@ impl Font { }; let mut current_x_pos = 0i32; - let current_y_pos = 0i32; for c in text.chars() { let letter = self.letter(c); let xmin = (current_x_pos + letter.xmin as i32).max(0); - let y_start = current_y_pos + self.ascent - letter.height as i32 - letter.ymin as i32; + let y_start = self.ascent - letter.height as i32 - letter.ymin as i32; for letter_y in 0..(letter.height as i32) { for letter_x in 0..(letter.width as i32) { @@ -125,6 +123,6 @@ impl Font { } } - 1 + current_x_pos } }