diff --git a/Cargo.lock b/Cargo.lock index 191ee67f3..4da766abd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,6 @@ dependencies = [ "console_error_panic_hook", "cosmic-text 0.15.0", "dwg-thumbnailer", - "encoding_rs", "env_logger", "flate2", "fluent-syntax", @@ -38,7 +37,6 @@ dependencies = [ "js-sys", "libloading", "log", - "lopdf", "lyon_tessellation", "meshopt", "naga 27.0.3", diff --git a/Cargo.toml b/Cargo.toml index f65b42ce0..6e78631dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,9 +55,6 @@ ttf-parser = "0.25" cosmic-text = "0.15" unicode-bidi = "0.3" lyon_tessellation = "1.0.20" -# Big-font (.shx) lookups: encode a char to the font's Big5 / GBK / Shift_JIS -# / EUC-KR double-byte code. Already in the tree through other deps. -encoding_rs = "0.8" pollster = "0.4" [dev-dependencies] @@ -93,8 +90,6 @@ i18n-embed = { version = "0.16", features = ["desktop-requester"] } rayon = "1" open = "5" printpdf = { version = "0.9.1", default-features = false, features = ["images"] } -# The lopdf printpdf builds on: used to Flate-compress the exported PDF streams. -lopdf = { version = "0.39.0", default-features = false, features = ["time"] } ureq = { version = "3", default-features = false, features = ["rustls", "platform-verifier", "win-system-proxy"] } [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/src/scene/text/shx.rs b/src/scene/text/shx.rs index 997e48c30..2e067b144 100644 --- a/src/scene/text/shx.rs +++ b/src/scene/text/shx.rs @@ -203,25 +203,24 @@ pub fn is_bigfont(path: &str) -> bool { load_file(path).is_some_and(|f| f.kind == ShxKind::Bigfont) } -/// The double-byte legacy encodings a big font may be keyed by, most likely -/// first for this file name. The font itself does not say; try them in turn -/// and take the first code the font actually has. -fn bigfont_encodings(path: &str) -> [&'static encoding_rs::Encoding; 4] { - use encoding_rs::{BIG5, EUC_KR, GBK, SHIFT_JIS}; +/// The code pages a big font's double-byte codes may be in, most likely +/// first, guessed from the file name. The codec maps a name to its encoding +/// (`ansi_950` Big5, `ansi_936` GBK, `ansi_932` Shift_JIS, `ansi_949` EUC-KR). +fn bigfont_code_pages(path: &str) -> [&'static str; 4] { let name = path .rsplit(['/', '\\']) .next() .unwrap_or(path) .to_ascii_lowercase(); if name.contains("gb") || name.contains("hz") || name.contains("china") { - [GBK, BIG5, SHIFT_JIS, EUC_KR] + ["ansi_936", "ansi_950", "ansi_932", "ansi_949"] } else if name.contains("bigfont") || name.contains("extfont") || name.contains("jp") { - [SHIFT_JIS, BIG5, GBK, EUC_KR] + ["ansi_932", "ansi_950", "ansi_936", "ansi_949"] } else if name.contains("whg") || name.contains("kor") || name.contains("han") { - [EUC_KR, BIG5, GBK, SHIFT_JIS] + ["ansi_949", "ansi_950", "ansi_936", "ansi_932"] } else { // `chineset.shx` and most Taiwanese fonts. - [BIG5, GBK, SHIFT_JIS, EUC_KR] + ["ansi_950", "ansi_936", "ansi_932", "ansi_949"] } } @@ -235,7 +234,10 @@ pub fn bigfont_glyph(path: &str, ch: char) -> Option