diff --git a/agb/src/display/object/font/preprocess.rs b/agb/src/display/object/font/preprocess.rs index e07356a2..71435074 100644 --- a/agb/src/display/object/font/preprocess.rs +++ b/agb/src/display/object/font/preprocess.rs @@ -86,8 +86,12 @@ impl Preprocessor { ); self.width_in_sprite = 0; } - if self.width_in_sprite != 0 { - self.width_in_sprite += letter.xmin as i32; + self.width_in_sprite += letter.xmin as i32; + if self.width_in_sprite < 0 { + if let Some(back) = widths.back_mut() { + back.0 -= (-self.width_in_sprite).try_into().unwrap_or(0); + } + self.width_in_sprite = 0; } self.width_in_sprite += letter.advance_width as i32; } diff --git a/agb/src/display/object/font/renderer.rs b/agb/src/display/object/font/renderer.rs index bbd0628b..ac1f8f77 100644 --- a/agb/src/display/object/font/renderer.rs +++ b/agb/src/display/object/font/renderer.rs @@ -99,9 +99,8 @@ impl WordRender { None }; - if self.working.x_offset != 0 { - self.working.x_offset += font_letter.xmin as i32; - } + self.working.x_offset += font_letter.xmin as i32; + self.working.x_offset = self.working.x_offset.max(0); let y_position = font.ascent() - font_letter.height as i32 - font_letter.ymin as i32;