-
Notifications
You must be signed in to change notification settings - Fork 25
/
multiple_variants.rs
97 lines (86 loc) · 3.02 KB
/
multiple_variants.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use egui::ViewportBuilder;
use egui_phosphor::{bold, fill, light, regular, thin};
fn main() {
eframe::run_native(
"egui-phosphor demo",
eframe::NativeOptions {
viewport: ViewportBuilder::default().with_inner_size((320.0, 755.0)),
..Default::default()
},
Box::new(|cc| Ok(Box::new(Demo::new(cc)))),
)
.unwrap();
}
struct Demo {}
impl Demo {
fn new(cc: &eframe::CreationContext) -> Self {
let mut fonts = egui::FontDefinitions::default();
fonts.font_data.insert(
"phosphor-thin".into(),
egui_phosphor::Variant::Thin.font_data(),
);
fonts.families.insert(
egui::FontFamily::Name("phosphor-thin".into()),
vec!["Ubuntu-Light".into(), "phosphor-thin".into()],
);
fonts.font_data.insert(
"phosphor-light".into(),
egui_phosphor::Variant::Light.font_data(),
);
fonts.families.insert(
egui::FontFamily::Name("phosphor-light".into()),
vec!["Ubuntu-Light".into(), "phosphor-light".into()],
);
fonts.font_data.insert(
"phosphor".into(),
egui_phosphor::Variant::Regular.font_data(),
);
fonts.families.insert(
egui::FontFamily::Name("phosphor".into()),
vec!["Ubuntu-Light".into(), "phosphor".into()],
);
fonts.font_data.insert(
"phosphor-bold".into(),
egui_phosphor::Variant::Bold.font_data(),
);
fonts.families.insert(
egui::FontFamily::Name("phosphor-bold".into()),
vec!["Ubuntu-Light".into(), "phosphor-bold".into()],
);
fonts.font_data.insert(
"phosphor-fill".into(),
egui_phosphor::Variant::Fill.font_data(),
);
fonts.families.insert(
egui::FontFamily::Name("phosphor-fill".into()),
vec!["Ubuntu-Light".into(), "phosphor-fill".into()],
);
cc.egui_ctx.set_fonts(fonts);
Self {}
}
}
impl eframe::App for Demo {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
for (family, icon) in [
("phosphor-thin", thin::FILE_CODE),
("phosphor-light", light::FILE_CODE),
("phosphor", regular::FILE_CODE),
("phosphor-bold", bold::FILE_CODE),
("phosphor-fill", fill::FILE_CODE),
] {
ui.heading(family);
egui::Frame::canvas(ui.style()).show(ui, |ui| {
for size in [16.0, 32.0, 48.0] {
let demo_text = format!("FILE_CODE {icon}");
ui.label(
egui::RichText::new(&demo_text)
.family(egui::FontFamily::Name(family.into()))
.size(size),
);
}
});
}
});
}
}