From a7edaea8088db01fd259443d65a70a53cd732615 Mon Sep 17 00:00:00 2001 From: xiaji Date: Sat, 4 Apr 2026 17:45:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E6=94=AF=E6=8C=81=EF=BC=8C=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E6=98=BE=E7=A4=BA=E4=B9=B1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flomo-ai-desktop/src/main.rs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) 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); +}