fix the overflow bug on kerning / xmin on a new sprite (#725)

- [x] Changelog updated
This commit is contained in:
Corwin 2024-06-12 17:40:46 +01:00 committed by GitHub
commit 5ca9cd5480
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View file

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Affine background center position didn't work outside of the upper left quadrant of the gba's screen. - Affine background center position didn't work outside of the upper left quadrant of the gba's screen.
- Fixed backtrace pointing to the wrong line of code (being out by one). - Fixed backtrace pointing to the wrong line of code (being out by one).
- Fixes overflow caused by certain font characteristics on boundaries of sprites in the object text renderer.
## [0.20.2] - 2024/05/25 ## [0.20.2] - 2024/05/25

View file

@ -86,8 +86,12 @@ impl Preprocessor {
); );
self.width_in_sprite = 0; 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; self.width_in_sprite += letter.advance_width as i32;
} }

View file

@ -99,9 +99,8 @@ impl WordRender {
None 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; let y_position = font.ascent() - font_letter.height as i32 - font_letter.ymin as i32;