os_terminal/font/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use alloc::vec::Vec;

#[cfg(feature = "bitmap")]
mod bitmap;
#[cfg(feature = "truetype")]
mod truetype;

#[cfg(feature = "bitmap")]
pub use bitmap::BitmapFont;
#[cfg(feature = "truetype")]
pub use truetype::TrueTypeFont;

pub enum Rasterized<'a> {
    Slice(&'a [&'a [u8]]),
    Vec(&'a Vec<Vec<u8>>),
}

#[derive(Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct ContentInfo {
    content: char,
    bold: bool,
    italic: bool,
    wide: bool,
}

impl ContentInfo {
    pub fn new(content: char, bold: bool, italic: bool, wide: bool) -> Self {
        Self {
            content,
            bold,
            italic,
            wide,
        }
    }
}

pub trait FontManager: Send {
    fn size(&self) -> (usize, usize);
    fn rasterize(&mut self, info: ContentInfo) -> Rasterized;
}