diff options
Diffstat (limited to 'src/font.rs')
-rw-r--r-- | src/font.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/font.rs b/src/font.rs index 1dddd20..7041634 100644 --- a/src/font.rs +++ b/src/font.rs @@ -1,5 +1,3 @@ -use std::sync::LazyLock; - use sdl2::{ pixels::{Color, PixelFormatEnum}, rect::{Point, Rect}, @@ -17,8 +15,8 @@ pub struct RenderableCharacter { pub data: &'static [u8], /** The offset to draw the character at */ pub offset: Point, - /** The amount to advance the x position of the cursor when drawing */ - pub advance_width: f32, + /** The amount to advance the x position of the cursor when drawing - f64 due to internally being used as a f64, despite being stored as f32 (only f64 to save some cpu cycles converting f32->f64) */ + pub advance_width: f64, } /** A trait describing a generated font. @@ -34,9 +32,9 @@ pub trait BakedFont { let width = u16::from_le_bytes(bytes[0..2].try_into().unwrap()); let offset_x = i32::from_le_bytes(bytes[2..6].try_into().unwrap()); let offset_y = i32::from_le_bytes(bytes[6..10].try_into().unwrap()); - let advance_width = f32::from_le_bytes(bytes[10..14].try_into().unwrap()); + let advance_width = f64::from(f32::from_le_bytes(bytes[10..14].try_into().unwrap())); let data = &bytes[14..]; - let height = if data.len() == 0 { + let height = if data.is_empty() { 0 } else { data.len() as u16 / width |