So i tried the Examples in egui documentation and it works. However the Examples in the egui documentation, seems to focus on overwriting the existing FontFamily (Proportional,Monospace):
let mut fonts = FontDefinitions::default();
// Install my own font (maybe supporting non-latin characters):
fonts.font_data.insert("my_font".to_owned(),
FontData::from_static(include_bytes!("../../fonts/Ubuntu-Light.ttf"))); // .ttf and .otf supported
// Put my font first (highest priority):
fonts.families.get_mut(&FontFamily::Proportional).unwrap()
.insert(0, "my_font".to_owned());
// Put my font as last fallback for monospace:
fonts.families.get_mut(&FontFamily::Monospace).unwrap()
.push("my_font".to_owned());
egui_ctx.set_fonts(fonts);
But how to i declare or define a completely new Family in the Enum?
pub enum FontFamily {
Proportional,
Monospace,
Name(Arc<str>),
}
pub enum FontFamily {
Proportional,
Monospace,
my_font, <-- How i put the font here as a new FamilyMember?
Name(Arc<str>),
}
I would like to use my own my_font only for specfic labels or fields like in this case:
ui.add(
egui::TextEdit::singleline(&mut ss)
.text_color(egui::Color32::LIGHT_RED)
.font(egui::FontSelection::FontId(FontId::new(
20.,
egui::FontFamily::my_font, <--
))),