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] =
47 include_bytes!("../fonts/font-awesome-6-free-regular-400.otf");
48
49const FONT_DATA_FA_BRANDS: &[u8] =
50 include_bytes!("../fonts/font-awesome-6-brands-regular-400.otf");
51
52const FONT_DATA_FA_SOLID: &[u8] =
53 include_bytes!("../fonts/font-awesome-6-free-solid-900.otf");
54
55pub const FA_ICON_USER: &str = "f007";
61
62pub const FA_ICON_NEW: &str = "f15b";
64
65pub const FA_ICON_OPEN: &str = "f07c";
67
68pub const FA_ICON_SAVE: &str = "f0c7";
70
71pub const FA_ICON_0: &str = "30";
77
78pub const FA_ICON_1: &str = "31";
80
81pub const FA_ICON_2: &str = "32";
83
84pub const FA_ICON_3: &str = "33";
86
87pub const FA_ICON_4: &str = "34";
89
90pub const FA_ICON_5: &str = "35";
92
93pub const FA_ICON_6: &str = "36";
95
96pub const FA_ICON_7: &str = "37";
98
99pub const FA_ICON_8: &str = "38";
101
102pub const FA_ICON_9: &str = "39";
104
105pub const FA_ICON_CIRCLE_CHECK: &str = "f058";
111
112pub const FA_ICON_CIRCLE_XMARK: &str = "f057";