diff options
Diffstat (limited to 'src/font.rs')
-rw-r--r-- | src/font.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/font.rs b/src/font.rs index d4e8d88..7df0545 100644 --- a/src/font.rs +++ b/src/font.rs @@ -16,7 +16,11 @@ fn insert_value(arr: &mut Vec<*const Glyph>, idx: usize, glyph: *const Glyph) { } pub struct RenderableCharacter { + /** The width of the character, indicating where to break into a newline */ pub width: u16, + /** The height of the character, derived from data's length divided by width */ + pub height: u16, + /** The raw alpha layer of the character */ pub data: &'static [u8], } /** @@ -26,9 +30,12 @@ pub trait BakedFont { fn get_char_bytes(character: char) -> &'static [u8]; fn get_char(character: char) -> RenderableCharacter { let bytes = Self::get_char_bytes(character); + let width = (bytes[0] as u16) | (bytes[1] as u16 >> 8); + let data = &bytes[2..]; RenderableCharacter { - width: (bytes[0] as u16) | (bytes[1] as u16 >> 8) , - data: &bytes[2..] + width, + height: data.len() as u16 / width, + data, } } } |