forked from 1b-agent/opencadstudio-upstream
build: reach lopdf and encoding_rs through printpdf and the codec
#1418 added both as direct dependencies although each was already in the tree: printpdf's to_lopdf_doc returns the lopdf document whose compress and save_to are plain methods, and the codec's encoding_from_code_page hands back the Big5 / GBK / Shift_JIS / EUC-KR encodings by their DXF code-page names. Cargo.toml keeps its dependency list. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
697ea4984b
commit
baba5bccd3
3 files changed
+12
-17
No files matched your search
Generated
-2
@@ -18,7 +18,6 @@ dependencies = [
|
|||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
"cosmic-text 0.15.0",
|
"cosmic-text 0.15.0",
|
||||||
"dwg-thumbnailer",
|
"dwg-thumbnailer",
|
||||||
"encoding_rs",
|
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"flate2",
|
"flate2",
|
||||||
"fluent-syntax",
|
"fluent-syntax",
|
||||||
@@ -38,7 +37,6 @@ dependencies = [
|
|||||||
"js-sys",
|
"js-sys",
|
||||||
"libloading",
|
"libloading",
|
||||||
"log",
|
"log",
|
||||||
"lopdf",
|
|
||||||
"lyon_tessellation",
|
"lyon_tessellation",
|
||||||
"meshopt",
|
"meshopt",
|
||||||
"naga 27.0.3",
|
"naga 27.0.3",
|
||||||
|
|||||||
@@ -55,9 +55,6 @@ ttf-parser = "0.25"
|
|||||||
cosmic-text = "0.15"
|
cosmic-text = "0.15"
|
||||||
unicode-bidi = "0.3"
|
unicode-bidi = "0.3"
|
||||||
lyon_tessellation = "1.0.20"
|
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"
|
pollster = "0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
@@ -93,8 +90,6 @@ i18n-embed = { version = "0.16", features = ["desktop-requester"] }
|
|||||||
rayon = "1"
|
rayon = "1"
|
||||||
open = "5"
|
open = "5"
|
||||||
printpdf = { version = "0.9.1", default-features = false, features = ["images"] }
|
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"] }
|
ureq = { version = "3", default-features = false, features = ["rustls", "platform-verifier", "win-system-proxy"] }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
|||||||
+12
-10
@@ -203,25 +203,24 @@ pub fn is_bigfont(path: &str) -> bool {
|
|||||||
load_file(path).is_some_and(|f| f.kind == ShxKind::Bigfont)
|
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
|
/// The code pages a big font's double-byte codes may be in, most likely
|
||||||
/// first for this file name. The font itself does not say; try them in turn
|
/// first, guessed from the file name. The codec maps a name to its encoding
|
||||||
/// and take the first code the font actually has.
|
/// (`ansi_950` Big5, `ansi_936` GBK, `ansi_932` Shift_JIS, `ansi_949` EUC-KR).
|
||||||
fn bigfont_encodings(path: &str) -> [&'static encoding_rs::Encoding; 4] {
|
fn bigfont_code_pages(path: &str) -> [&'static str; 4] {
|
||||||
use encoding_rs::{BIG5, EUC_KR, GBK, SHIFT_JIS};
|
|
||||||
let name = path
|
let name = path
|
||||||
.rsplit(['/', '\\'])
|
.rsplit(['/', '\\'])
|
||||||
.next()
|
.next()
|
||||||
.unwrap_or(path)
|
.unwrap_or(path)
|
||||||
.to_ascii_lowercase();
|
.to_ascii_lowercase();
|
||||||
if name.contains("gb") || name.contains("hz") || name.contains("china") {
|
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") {
|
} 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") {
|
} 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 {
|
} else {
|
||||||
// `chineset.shx` and most Taiwanese fonts.
|
// `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<Arc<crate::scene::text::lff
|
|||||||
}
|
}
|
||||||
let mut buf = [0u8; 4];
|
let mut buf = [0u8; 4];
|
||||||
let s = ch.encode_utf8(&mut buf);
|
let s = ch.encode_utf8(&mut buf);
|
||||||
for enc in bigfont_encodings(path) {
|
for page in bigfont_code_pages(path) {
|
||||||
|
let Some(enc) = acadrust::io::dxf::code_page::encoding_from_code_page(page) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let (bytes, _, unmappable) = enc.encode(s);
|
let (bytes, _, unmappable) = enc.encode(s);
|
||||||
if unmappable || bytes.len() != 2 {
|
if unmappable || bytes.len() != 2 {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in new issue
Block a user