Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 138 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ zip = { version = "2.2", default-features = false, features = ["deflate"] }
flate2 = "1.0"
tar = "0.4"
sys-locale = "0.3"
egui-system-fonts = "0.36.0"

[build-dependencies]
cc = "1.2"
Expand Down
43 changes: 1 addition & 42 deletions src/ui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,7 @@ pub struct VcdPlayerApp {
}

fn setup_custom_fonts(ctx: &egui::Context) {
let mut fonts = egui::FontDefinitions::default();

// Candidate CJK font paths on Windows, Linux, and macOS
let candidate_font_paths = [
// Windows (Microsoft YaHei, SimSun, SimHei)
r"C:\Windows\Fonts\msyh.ttc",
r"C:\Windows\Fonts\msyh.ttf",
r"C:\Windows\Fonts\simsun.ttc",
r"C:\Windows\Fonts\simhei.ttf",
// Linux
"/usr/share/fonts/truetype/wqy/wqy-microhei.ttc",
"/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
// macOS
"/System/Library/Fonts/PingFang.ttc",
"/Library/Fonts/Songti.ttc",
];

for path in candidate_font_paths {
if let Ok(bytes) = std::fs::read(path) {
fonts.font_data.insert(
"cjk_font".to_owned(),
std::sync::Arc::new(egui::FontData::from_owned(bytes)),
);

// Add CJK font at highest priority for Proportional font family
fonts
.families
.entry(egui::FontFamily::Proportional)
.or_default()
.insert(0, "cjk_font".to_owned());

fonts
.families
.entry(egui::FontFamily::Monospace)
.or_default()
.push("cjk_font".to_owned());

break;
}
}

ctx.set_fonts(fonts);
egui_system_fonts::set_auto(ctx, egui_system_fonts::FontStyle::Sans);
}

/// Transient status message linger duration (5 seconds).
Expand Down
Loading