diff --git a/flomo-ai-desktop/src/main.rs b/flomo-ai-desktop/src/main.rs index 90d581f..d5f255e 100644 --- a/flomo-ai-desktop/src/main.rs +++ b/flomo-ai-desktop/src/main.rs @@ -20,6 +20,39 @@ fn main() -> eframe::Result { eframe::run_native( "AI优化", options, - Box::new(|cc| Ok(Box::new(FlomoAiApp::new(cc)))), + Box::new(|cc| { + setup_fonts(&cc.egui_ctx); + Ok(Box::new(FlomoAiApp::new(cc))) + }), ) } + +fn setup_fonts(ctx: &egui::Context) { + let mut fonts = egui::FontDefinitions::default(); + + let font_paths = [ + "C:/Windows/Fonts/msyh.ttc", + "C:/Windows/Fonts/msyhbd.ttc", + "C:/Windows/Fonts/simsun.ttc", + "C:/Windows/Fonts/simhei.ttf", + ]; + + for (i, path) in font_paths.iter().enumerate() { + if let Ok(data) = std::fs::read(path) { + let name = format!("chinese_{}", i); + fonts.font_data.insert(name.clone(), egui::FontData::from_owned(data)); + fonts + .families + .entry(egui::FontFamily::Proportional) + .or_default() + .push(name.clone()); + fonts + .families + .entry(egui::FontFamily::Monospace) + .or_default() + .push(name); + } + } + + ctx.set_fonts(fonts); +}