#[derive(Clone)]
pub enum Font {
Bitmap {
texture_path: String,
chars: String,
width: f32,
height: f32,
texture_columns: f32,
texture_lines: f32,
},
}
impl Font {
pub(crate) fn find_line_and_column(
chars: &String,
texture_column: f32,
character: char,
) -> (f32, f32) {
let index_of_char = chars
.find(character)
.expect("A character is not a part of the bitmap font but has been added to an UiText");
(
(index_of_char / texture_column as usize) as f32,
(index_of_char % texture_column as usize) as f32,
)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn find_indexes() {
assert_eq!((1., 0.), Font::find_line_and_column(&"abcdef".to_string(), 3., 'd'))
}
}