diff --git a/Cargo.lock b/Cargo.lock index a42baf4..5a1e771 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,6 +463,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + [[package]] name = "bindgen" version = "0.72.1" @@ -796,6 +802,15 @@ dependencies = [ "libc", ] +[[package]] +name = "core_maths" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +dependencies = [ + "libm", +] + [[package]] name = "coreaudio-rs" version = "0.11.3" @@ -1036,6 +1051,18 @@ dependencies = [ "web-sys", ] +[[package]] +name = "egui-system-fonts" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6607438a84f3bd373419978c1e3f2e775bc01a5ad115a545cb11d07b349cfe30" +dependencies = [ + "egui", + "ehttp", + "log", + "system-fonts", +] + [[package]] name = "egui-wgpu" version = "0.36.1" @@ -1092,6 +1119,20 @@ dependencies = [ "winit", ] +[[package]] +name = "ehttp" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2f1b93eb2e039aaff63ce07cca59bd1dca02f2ce30075a17b619d2c42f56efc" +dependencies = [ + "document-features", + "js-sys", + "ureq 3.4.2", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "either" version = "1.18.0" @@ -1294,6 +1335,29 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "fontconfig-parser" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbc773e24e02d4ddd8395fd30dc147524273a83e54e0f312d986ea30de5f5646" +dependencies = [ + "roxmltree", +] + +[[package]] +name = "fontdb" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "457e789b3d1202543297a350643cf459f836cade38934e7a4cf6a39e7cde2905" +dependencies = [ + "fontconfig-parser", + "log", + "memmap2", + "slotmap", + "tinyvec", + "ttf-parser", +] + [[package]] name = "foreign-types" version = "0.5.0" @@ -1635,6 +1699,22 @@ version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + [[package]] name = "icu_collections" version = "2.3.0" @@ -3048,6 +3128,12 @@ dependencies = [ "symphonia", ] +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -3535,6 +3621,17 @@ dependencies = [ "libc", ] +[[package]] +name = "system-fonts" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46ba78ea149d4bb0626dacad10aa789eedc83395889890a0e6e7ec69a4577442" +dependencies = [ + "fontdb", + "sys-locale", + "web-sys", +] + [[package]] name = "tar" version = "0.4.46" @@ -3748,6 +3845,9 @@ name = "ttf-parser" version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" +dependencies = [ + "core_maths", +] [[package]] name = "type-map" @@ -3811,7 +3911,7 @@ version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d" dependencies = [ - "base64", + "base64 0.22.1", "flate2", "log", "once_cell", @@ -3823,6 +3923,35 @@ dependencies = [ "webpki-roots 0.26.11", ] +[[package]] +name = "ureq" +version = "3.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a7ac20be9b7726e0bbdbf974c059676d9acb1cd414961f570a4e8231cacd7fc" +dependencies = [ + "base64 0.23.1", + "flate2", + "log", + "percent-encoding", + "rustls", + "rustls-pki-types", + "ureq-proto", + "utf8-zero", + "webpki-roots 1.0.9", +] + +[[package]] +name = "ureq-proto" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86fd172ccca569e458f61b6bdd6220965a9ef36e672a6852953b51a0e1583be" +dependencies = [ + "base64 0.23.1", + "http", + "httparse", + "log", +] + [[package]] name = "url" version = "2.5.8" @@ -3835,6 +3964,12 @@ dependencies = [ "serde", ] +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -3858,6 +3993,7 @@ version = "0.7.0" dependencies = [ "cc", "eframe", + "egui-system-fonts", "flate2", "rfd", "rodio", @@ -3867,7 +4003,7 @@ dependencies = [ "sha2", "sys-locale", "tar", - "ureq", + "ureq 2.12.1", "winres", "zip", ] diff --git a/Cargo.toml b/Cargo.toml index f1e8694..bbdc082 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/ui/app.rs b/src/ui/app.rs index 44a77d9..2486d56 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -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).