Is your feature request related to a problem? Please describe.
There is currently no way to define a custom replacement glyph for user-provided fonts. For example, the font "MaterialSymbolsSharp" can't be used with egui because it does not have the replacement glyphs egui is hardcoded to look for. The font itself seems to load fine; however as soon as I try to use the font the code panics here:
Describe the solution you'd like
Add user-specified overrides to FontTweak that replace the glyphs that the library looks for.
Describe alternatives you've considered
Besides using another font, there isn't really any option. Even using font fallbacks (for example with RichText::append_to), egui still tries to load the font and panics before falling back.
Additional context
Seen on egui 0.27.2 on a custom vulkan backend (although that is unrelated to the issue at hand).
Usage:
// This happens on app start, looks through ./assets/fonts and loads everything:
def.font_data.insert(
font_name.to_owned(), // MaterialSymbolsSharp
FontData::from_owned(file_data.unwrap())
);
def.families.entry(value.clone())
.and_modify(move |value| value.push(font_name.to_owned()))
.or_insert(vec![font_name.to_owned()]);
def.families.insert(FontFamily::Name(font_name.into()), vec![font_name.to_owned()]);
// Later in the UI
let mut label_job = LayoutJob::default();
RichText::new("HOME")
.family(FontFamily::Name("MaterialSymbolsSharp".into()))
.append_to(&mut label_job, &Style::default(), FontSelection::Default, egui::Align::Min);
RichText::new("Home")
.family(FontFamily::Name("Roboto-Light".into()))
.append_to(&mut label_job, &Style::default(), FontSelection::Default, egui::Align::Min);
ui.selectable_value(&mut self.active_tab, Tab::Home, label_job);
Is your feature request related to a problem? Please describe.
There is currently no way to define a custom replacement glyph for user-provided fonts. For example, the font "MaterialSymbolsSharp" can't be used with egui because it does not have the replacement glyphs egui is hardcoded to look for. The font itself seems to load fine; however as soon as I try to use the font the code panics here:
Describe the solution you'd like Add user-specified overrides to
FontTweak
that replace the glyphs that the library looks for.Describe alternatives you've considered Besides using another font, there isn't really any option. Even using font fallbacks (for example with
RichText::append_to
), egui still tries to load the font and panics before falling back.Additional context Seen on egui 0.27.2 on a custom vulkan backend (although that is unrelated to the issue at hand).
Usage: