egui_phosphor/variants/
mod.rs1#[cfg(feature = "bold")]
2pub mod bold;
3#[cfg(feature = "fill")]
4pub mod fill;
5#[cfg(feature = "light")]
6pub mod light;
7#[cfg(feature = "regular")]
8pub mod regular;
9#[cfg(feature = "thin")]
10pub mod thin;
11
12#[cfg(not(any(
13 feature = "thin",
14 feature = "light",
15 feature = "regular",
16 feature = "bold",
17 feature = "fill",
18)))]
19compile_error!(
20 "At least one font variant must be selected as a crate feature. When in doubt, use default features."
21);
22
23#[derive(Debug, Clone, Copy)]
24pub enum Variant {
25 #[cfg(feature = "thin")]
26 Thin,
27 #[cfg(feature = "light")]
28 Light,
29 #[cfg(feature = "regular")]
30 Regular,
31 #[cfg(feature = "bold")]
32 Bold,
33 #[cfg(feature = "fill")]
34 Fill,
35}
36
37impl Variant {
38 pub fn font_bytes(&self) -> &'static [u8] {
39 match self {
40 #[cfg(feature = "thin")]
41 Variant::Thin => &*include_bytes!("../../res/Phosphor-Thin.ttf"),
42 #[cfg(feature = "light")]
43 Variant::Light => &*include_bytes!("../../res/Phosphor-Light.ttf"),
44 #[cfg(feature = "regular")]
45 Variant::Regular => &*include_bytes!("../../res/Phosphor.ttf"),
46 #[cfg(feature = "bold")]
47 Variant::Bold => &*include_bytes!("../../res/Phosphor-Bold.ttf"),
48 #[cfg(feature = "fill")]
49 Variant::Fill => &*include_bytes!("../../res/Phosphor-Fill.ttf"),
50 }
51 }
52
53 pub fn font_data(&self) -> egui::FontData {
54 egui::FontData::from_static(self.font_bytes())
55 }
56}