mod.rs 1.2 KB

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