diff --git a/src/bmfont_renderer.rs b/src/bmfont_renderer.rs index 18e714c..550d6ea 100644 --- a/src/bmfont_renderer.rs +++ b/src/bmfont_renderer.rs @@ -56,8 +56,7 @@ impl BMFontRenderer { for chr in iter { if let Some(glyph) = self.font.chars.get(&chr) { - offset_x += ((glyph.width as f32 + glyph.xoffset as f32) * constants.font_scale).floor() - + if chr != ' ' { constants.font_scale } else { constants.font_space_offset }; + offset_x += glyph.xadvance as f32 * constants.font_scale; } } @@ -131,16 +130,15 @@ impl BMFontRenderer { for chr in iter { if let Some(glyph) = self.font.chars.get(&chr) { batch.add_rect_scaled_tinted( - offset_x, - y + (glyph.yoffset as f32 * constants.font_scale).floor(), + offset_x + (glyph.xoffset as f32 * constants.font_scale), + y + (glyph.yoffset as f32 * constants.font_scale), color, constants.font_scale, constants.font_scale, &Rect::new_size(glyph.x as u16, glyph.y as u16, glyph.width as u16, glyph.height as u16), ); - offset_x += ((glyph.width as f32 + glyph.xoffset as f32) * constants.font_scale).floor() - + if chr != ' ' { constants.font_scale } else { constants.font_space_offset }; + offset_x += glyph.xadvance as f32 * constants.font_scale; } } @@ -169,8 +167,8 @@ impl BMFontRenderer { for (chr, glyph) in chars.iter() { if glyph.page == page { batch.add_rect_scaled_tinted( - offset_x, - y + (glyph.yoffset as f32 * constants.font_scale).floor(), + offset_x + (glyph.xoffset as f32 * constants.font_scale), + y + (glyph.yoffset as f32 * constants.font_scale), color, constants.font_scale * scale, constants.font_scale * scale, @@ -178,9 +176,7 @@ impl BMFontRenderer { ); } - offset_x += scale - * (((glyph.width as f32 + glyph.xoffset as f32) * constants.font_scale).floor() - + if *chr != ' ' { constants.font_scale } else { constants.font_space_offset }); + offset_x += scale * (glyph.xadvance as f32 * constants.font_scale); } batch.draw(ctx)?; diff --git a/src/builtin/builtin_font.fnt b/src/builtin/builtin_font.fnt index 7f5fae2..3986e9c 100644 Binary files a/src/builtin/builtin_font.fnt and b/src/builtin/builtin_font.fnt differ diff --git a/src/builtin/builtin_font_0.png b/src/builtin/builtin_font_0.png index 5479ccb..6e588e3 100644 Binary files a/src/builtin/builtin_font_0.png and b/src/builtin/builtin_font_0.png differ diff --git a/src/engine_constants/mod.rs b/src/engine_constants/mod.rs index 259c314..73423e8 100644 --- a/src/engine_constants/mod.rs +++ b/src/engine_constants/mod.rs @@ -1529,7 +1529,6 @@ impl EngineConstants { self.title.logo_rect = Rect { left: 0, top: 0, right: 214, bottom: 50 }; self.font_path = "csfont.fnt".to_owned(); self.font_scale = 0.5; - self.font_space_offset = 3.0; self.soundtracks.insert("Remastered".to_owned(), "/base/Ogg11/".to_owned()); self.soundtracks.insert("New".to_owned(), "/base/Ogg/".to_owned());