1use std::borrow::Cow;
8use iced::advanced::graphics::text::font_system;
9use iced::{Element, Font};
10use iced::font::Family;
11use iced::widget::text;
12
13pub fn load_font_fontawesome() {
17 let mut font_system = font_system().write().unwrap();
18 font_system.load_font(Cow::from(FONT_DATA_FA_REGULAR));
19 font_system.load_font(Cow::from(FONT_DATA_FA_BRANDS));
20 font_system.load_font(Cow::from(FONT_DATA_FA_SOLID));
21}
22
23pub fn iced_text_icon<'a, Message>(code: &str) -> Element<'a, Message> {
29 let code_u32 = u32::from_str_radix(&code, 16).unwrap();
30 let unicode_char = char::from_u32(code_u32).unwrap();
31 text(unicode_char).font(FONT_FA_REGULAR).into()
32}
33
34pub const FONT_FA_REGULAR: Font = Font {
38 family: Family::Name("Font Awesome 6 Free"),
39 ..Font::DEFAULT
40};
41
42const FONT_DATA_FA_REGULAR: &[u8] =
43 include_bytes!("../fonts/font-awesome-6-free-regular-400.otf");
44
45const FONT_DATA_FA_BRANDS: &[u8] =
46 include_bytes!("../fonts/font-awesome-6-brands-regular-400.otf");
47
48const FONT_DATA_FA_SOLID: &[u8] =
49 include_bytes!("../fonts/font-awesome-6-free-solid-900.otf");
50
51pub const FA_ICON_USER: &str = "f007";
55
56pub const FA_ICON_NEW: &str = "f15b";
60
61pub const FA_ICON_OPEN: &str = "f07c";
65
66pub const FA_ICON_SAVE: &str = "f0c7";
70
71pub const FA_ICON_0: &str = "30";
75pub const FA_ICON_1: &str = "31";
76pub const FA_ICON_2: &str = "32";
77pub const FA_ICON_3: &str = "33";
78pub const FA_ICON_4: &str = "34";
79pub const FA_ICON_5: &str = "35";
80pub const FA_ICON_6: &str = "36";
81pub const FA_ICON_7: &str = "37";
82pub const FA_ICON_8: &str = "38";
83pub const FA_ICON_9: &str = "39";
84