cp437_tools/libs/public/
fonts.rs

1//! Fonts used for rendering PNG images
2//!
3//! These fonts are free to use under the
4//! [CC-BY-SA-4.0](https://creativecommons.org/licenses/by-sa/4.0) license.
5//!
6//! See <https://int10h.org/oldschool-pc-fonts>
7//!
8
9use lazy_static::lazy_static;
10use rust_embed::RustEmbed;
11use ttf_parser::Face;
12
13#[derive(RustEmbed)]
14#[folder = "$CARGO_MANIFEST_DIR/res/fonts"]
15#[include = "*.otb"]
16#[include = "*.woff"]
17struct Fonts;
18
19lazy_static! {
20    /// IBM VGA 8x16 raw font.
21    pub static ref VGA_8X16_OTB: Vec<u8> = Fonts::get("IBM VGA.8x16.otb").expect("File exists").data.into_owned();
22    /// IBM VGA 9x16 raw font.
23    pub static ref VGA_9X16_OTB: Vec<u8> = Fonts::get("IBM VGA.9x16.otb").expect("File exists").data.into_owned();
24    /// IBM VGA 8x16 woff font.
25    pub static ref VGA_8X16_WOFF: Vec<u8> = Fonts::get("IBM VGA.8x16.woff").expect("File exists").data.into_owned();
26    /// IBM VGA 9x16 woff font.
27    pub static ref VGA_9X16_WOFF: Vec<u8> = Fonts::get("IBM VGA.9x16.woff").expect("File exists").data.into_owned();
28
29    /// IBM VGA 8x16 font.
30    ///
31    /// See [`ttf_parser::Face`](https://docs.rs/ttf-parser/latest/ttf_parser/struct.Face.html)
32    ///
33    pub static ref VGA_8X16: Face<'static> = Face::parse(&VGA_8X16_OTB, 0).expect("Valid font");
34
35    /// IBM VGA 9x16 font.
36    ///
37    /// See [`ttf_parser::Face`](https://docs.rs/ttf-parser/latest/ttf_parser/struct.Face.html)
38    ///
39    pub static ref VGA_9X16: Face<'static> = Face::parse(&VGA_9X16_OTB, 0).expect("Valid font");
40}