xref: /DragonOS/kernel/src/libs/lib_ui/font/spleen_font.rs (revision c635d8a9cfe25bc11779f323ef0c7d7a0f597d4a)
1 use crate::libs::lib_ui::textui::GlyphMapping;
2 
3 use super::{BitmapFont, RawBitMap, Size};
4 
5 struct Mapping;
6 
7 impl GlyphMapping for Mapping {
8     #[inline(always)]
9     fn index(&self, c: char) -> usize {
10         let c = c as usize;
11         match c {
12             0..=255 => c,
13             _ => '?' as usize - ' ' as usize,
14         }
15     }
16 }
17 
18 const SPLEEN_GLYPH_MAPPING: Mapping = Mapping;
19 
20 #[allow(non_upper_case_globals)]
21 pub const SPLEEN_FONT_8x16: BitmapFont<'static> = BitmapFont::new(
22     RawBitMap::new(include_bytes!("binaries/spleen-8x16.raw_bytes"), 128),
23     &SPLEEN_GLYPH_MAPPING,
24     Size::new(8, 16),
25 );
26