1 use self::font_type::vga8x16::FONT_VGA_8X16; 2 3 pub mod font_type; 4 5 #[allow(dead_code)] 6 pub struct FontDesc { 7 pub index: usize, 8 pub name: &'static str, 9 pub width: u32, 10 pub height: u32, 11 pub char_count: u32, 12 pub data: &'static [u8], 13 } 14 15 impl FontDesc { get_default_font(_xres: u32, _yres: u32, _font_w: u32, _font_h: u32) -> &'static Self16 pub fn get_default_font(_xres: u32, _yres: u32, _font_w: u32, _font_h: u32) -> &'static Self { 17 // todo: 目前先直接返回一个字体 18 &FONT_VGA_8X16 19 } 20 21 pub const DOUBLE_WIDTH_RANGE: &'static [(u32, u32)] = &[ 22 (0x1100, 0x115F), 23 (0x2329, 0x232A), 24 (0x2E80, 0x303E), 25 (0x3040, 0xA4CF), 26 (0xAC00, 0xD7A3), 27 (0xF900, 0xFAFF), 28 (0xFE10, 0xFE19), 29 (0xFE30, 0xFE6F), 30 (0xFF00, 0xFF60), 31 (0xFFE0, 0xFFE6), 32 (0x20000, 0x2FFFD), 33 (0x30000, 0x3FFFD), 34 ]; is_double_width(ch: u32) -> bool35 pub fn is_double_width(ch: u32) -> bool { 36 if ch < Self::DOUBLE_WIDTH_RANGE.first().unwrap().0 37 || ch > Self::DOUBLE_WIDTH_RANGE.last().unwrap().1 38 { 39 return false; 40 } 41 42 for (first, last) in Self::DOUBLE_WIDTH_RANGE { 43 if ch >= *first && ch < *last { 44 return true; 45 } 46 } 47 48 false 49 } 50 } 51