Skip to main content

winit_ui/
font.rs

1pub struct Font {
2    font: fontdue::Font,
3}
4
5impl Font {
6    pub fn new(path: &str) -> Self {
7        let font_data = std::fs::read(path).unwrap();
8        let font = fontdue::Font::from_bytes(font_data, fontdue::FontSettings::default()).unwrap();
9        Self { font }
10    }
11
12    pub fn rasterize(&self, char: char, size: f32) -> (fontdue::Metrics, Vec<u8>) {
13        self.font.rasterize(char, size)
14    }
15}