use eframe::{egui, epi}; struct MyApp { text: String, } impl Default for MyApp { fn default() -> Self { Self { text: "Edit this text field if you want".to_owned(), } } } impl epi::App for MyApp { fn name(&self) -> &str { "egui example: custom font" } fn setup( &mut self, ctx: &egui::Context, _frame: &epi::Frame, _storage: Option<&dyn epi::Storage>, ) { // Start with the default fonts (we will be adding to them rather than replacing them). let mut fonts = egui::FontDefinitions::default(); // Install my own font (maybe supporting non-latin characters). // .ttf and .otf files supported. fonts.font_data.insert( "my_font".to_owned(), egui::FontData::from_static(include_bytes!("../../epaint/fonts/Hack-Regular.ttf")), ); // Put my font first (highest priority) for proportional text: fonts .families .entry(egui::FontFamily::Proportional) .or_default() .insert(0, "my_font".to_owned()); // Put my font as last fallback for monospace: fonts .families .entry(egui::FontFamily::Monospace) .or_default() .push("my_font".to_owned()); // Tell egui to use these fonts: ctx.set_fonts(fonts); } fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) { egui::CentralPanel::default().show(ctx, |ui| { ui.heading("egui using custom fonts"); ui.text_edit_multiline(&mut self.text); }); } } fn main() { let options = eframe::NativeOptions::default(); eframe::run_native(Box::new(MyApp::default()), options); }