Add PDF and document artwork imports as reference pictures
This commit is contained in:
parent
dfbfc89945
commit
ba63d4cf52
|
|
@ -2,6 +2,12 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "ab_glyph_rasterizer"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
|
||||
|
||||
[[package]]
|
||||
name = "acadrust"
|
||||
version = "0.6.6"
|
||||
|
|
@ -63,6 +69,21 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloc-no-stdlib"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
|
||||
|
||||
[[package]]
|
||||
name = "alloc-stdlib"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-activity"
|
||||
version = "0.6.1"
|
||||
|
|
@ -161,6 +182,12 @@ version = "0.5.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.7.8"
|
||||
|
|
@ -375,6 +402,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 = "bit-set"
|
||||
version = "0.9.1"
|
||||
|
|
@ -442,6 +475,27 @@ dependencies = [
|
|||
"piper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brotli"
|
||||
version = "8.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cc91aac060a7a1e25823bdccbfb6af1875b88f17c6daac97894eed8207166b3"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
"alloc-stdlib",
|
||||
"brotli-decompressor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brotli-decompressor"
|
||||
version = "5.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
"alloc-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "1.13.1"
|
||||
|
|
@ -548,9 +602,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "canvas-pilot"
|
||||
version = "0.9.45"
|
||||
version = "0.9.46"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"craft-dwg",
|
||||
"craft-dxf",
|
||||
"csv",
|
||||
|
|
@ -562,19 +616,23 @@ dependencies = [
|
|||
"figcraft-doc",
|
||||
"figcraft-format",
|
||||
"figcraft-geom",
|
||||
"figcraft-svg",
|
||||
"flate2",
|
||||
"hayro",
|
||||
"image",
|
||||
"reqwest",
|
||||
"resvg",
|
||||
"rfd",
|
||||
"roxmltree",
|
||||
"roxmltree 0.20.0",
|
||||
"rust-i18n",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"skrifa",
|
||||
"svgtypes",
|
||||
"skrifa 0.42.1",
|
||||
"svgtypes 0.15.3",
|
||||
"sys-locale",
|
||||
"tempfile",
|
||||
"tungstenite",
|
||||
"url",
|
||||
"winresource",
|
||||
"zip 2.6.1",
|
||||
]
|
||||
|
|
@ -828,6 +886,12 @@ version = "2.11.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
|
||||
|
||||
[[package]]
|
||||
name = "data-url"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"
|
||||
|
||||
[[package]]
|
||||
name = "deckcraft-color"
|
||||
version = "0.6.1"
|
||||
|
|
@ -1173,18 +1237,18 @@ dependencies = [
|
|||
"ecolor",
|
||||
"emath",
|
||||
"epaint_default_fonts",
|
||||
"font-types",
|
||||
"harfrust",
|
||||
"font-types 0.11.3",
|
||||
"harfrust 0.7.0",
|
||||
"log",
|
||||
"nohash-hasher",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"self_cell",
|
||||
"skrifa",
|
||||
"skrifa 0.42.1",
|
||||
"smallvec",
|
||||
"unicode-general-category",
|
||||
"unicode-segmentation",
|
||||
"vello_cpu",
|
||||
"vello_cpu 0.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1271,6 +1335,18 @@ version = "0.4.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b97b65636e5b9ef369943878ac74335ba1c55c1cb6adbf1e2c293c624248d693"
|
||||
|
||||
[[package]]
|
||||
name = "fearless_simd"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4beca3cb2444e3304ac30843cc091f44ed58932353cd492ce740067bfce6b12"
|
||||
|
||||
[[package]]
|
||||
name = "fearless_simd"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "629c9d6b6f30b5604089e0980f4d924a013aacb1654a6cdf5d3d852224f68651"
|
||||
|
||||
[[package]]
|
||||
name = "figcraft-color"
|
||||
version = "0.5.1"
|
||||
|
|
@ -1333,6 +1409,57 @@ dependencies = [
|
|||
"linesweeper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "figcraft-render"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c647e0857f128d9904523d20d695b344c83aac0e409662c8ec12a2221d7980c"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"figcraft-color",
|
||||
"figcraft-doc",
|
||||
"figcraft-geom",
|
||||
"figcraft-pathops",
|
||||
"figcraft-text",
|
||||
"image",
|
||||
"log",
|
||||
"moxcms",
|
||||
"png",
|
||||
"rayon",
|
||||
"tiny-skia",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "figcraft-svg"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3400bbaf26dca36cff3b9dee60361306455a10e4eb571681bbf37fd06aacf899"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"figcraft-color",
|
||||
"figcraft-doc",
|
||||
"figcraft-geom",
|
||||
"figcraft-pathops",
|
||||
"figcraft-render",
|
||||
"figcraft-text",
|
||||
"usvg 0.48.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "figcraft-text"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7bb386a04c28f194791959e5252165a50786e42f51d5461dfae492f2939f3ae"
|
||||
dependencies = [
|
||||
"figcraft-doc",
|
||||
"figcraft-geom",
|
||||
"harfrust 0.13.3",
|
||||
"log",
|
||||
"skrifa 0.47.0",
|
||||
"unicode-bidi",
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.15"
|
||||
|
|
@ -1350,6 +1477,12 @@ dependencies = [
|
|||
"zlib-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "float-cmp"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
|
|
@ -1365,6 +1498,37 @@ dependencies = [
|
|||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "font-types"
|
||||
version = "0.12.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fontconfig-parser"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbc773e24e02d4ddd8395fd30dc147524273a83e54e0f312d986ea30de5f5646"
|
||||
dependencies = [
|
||||
"roxmltree 0.20.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fontdb"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2660c5e9157bf76d2db1294e4a9feba604ef610819a3b591088d0d8392a3290f"
|
||||
dependencies = [
|
||||
"fontconfig-parser",
|
||||
"log",
|
||||
"memmap2",
|
||||
"slotmap",
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.5.0"
|
||||
|
|
@ -1550,9 +1714,26 @@ dependencies = [
|
|||
"hashbrown 0.17.1",
|
||||
"log",
|
||||
"peniko",
|
||||
"skrifa",
|
||||
"skrifa 0.42.1",
|
||||
"smallvec",
|
||||
"vello_common",
|
||||
"vello_common 0.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glifo"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f1218dedd5348c1b166ec3b8b3cbca49d2f527bd43b3fa072ea5123c523ed3f"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"foldhash",
|
||||
"hashbrown 0.17.1",
|
||||
"log",
|
||||
"peniko",
|
||||
"png",
|
||||
"skrifa 0.44.0",
|
||||
"smallvec",
|
||||
"vello_common 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1702,10 +1883,48 @@ checksum = "0431e8e389aa0f1e72bb9d1c2db8957a1a7a3580e8ed97db819c14837aac9b3e"
|
|||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"read-fonts",
|
||||
"read-fonts 0.39.2",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "harfrust"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"read-fonts 0.41.0",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "harfrust"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "948d0741125ba89cd3e1c23e5642415b6ade7e1d29d67ba25fb925b533e989d6"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"once_cell",
|
||||
"read-fonts 0.43.3",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "harfrust"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "865dcc4105d51c323d8fedbb2d75b5e9c8ecddf5613f74c82f851d0afbc97114"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"read-fonts 0.46.0",
|
||||
"smallvec",
|
||||
"yoke",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.16.1"
|
||||
|
|
@ -1724,6 +1943,113 @@ dependencies = [
|
|||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34d3977ae664ab6eea015be3024379c83c6a3580f67d51be6884f1992bf683ba"
|
||||
dependencies = [
|
||||
"ab_glyph_rasterizer",
|
||||
"bytemuck",
|
||||
"fearless_simd 1.2.0",
|
||||
"hayro-interpret",
|
||||
"image",
|
||||
"kurbo 0.13.1",
|
||||
"pic-scale",
|
||||
"rustc-hash 2.1.3",
|
||||
"vello_cpu 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-ccitt"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adbed896e99325bc312778bb9c9c289d795d51c12775c44dd5e4352f679c7e46"
|
||||
|
||||
[[package]]
|
||||
name = "hayro-cmap"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a14afde3344be69225fec4f6f44f6a219a3a492f9d8301eb25ef608fe4b7014c"
|
||||
dependencies = [
|
||||
"brotli",
|
||||
"hayro-postscript",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-font"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ac7f0c78172573e9bd6eeb17f62c63f4d378b2a2d127c3ee9c2c7cc6fbdf78b"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
"hayro-syntax",
|
||||
"kurbo 0.13.1",
|
||||
"phf 0.13.1",
|
||||
"rustc-hash 2.1.3",
|
||||
"siphasher",
|
||||
"skrifa 0.49.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "166477622df4b770a0fc5889a9e4b48c7ff8595d6ec019bf71b4297b97b55fb6"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
"hayro-font",
|
||||
"hayro-syntax",
|
||||
"kurbo 0.13.1",
|
||||
"moxcms",
|
||||
"rustc-hash 2.1.3",
|
||||
"siphasher",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-jbig2"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb5c7f3a4eb551c2bb7fa16e268f728d4bc2a5c9b090554b8dc0ee2503fb5840"
|
||||
dependencies = [
|
||||
"fearless_simd 1.2.0",
|
||||
"hayro-ccitt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-jpeg2000"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e5e5f2b3de970707fc22fd956d8f44211602939d5e4588603afa919cb7b3740"
|
||||
dependencies = [
|
||||
"fearless_simd 1.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-postscript"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f"
|
||||
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6ced8279487b029813f6cc05399099fa34df6fa23d8f7b0d41d972c49d5b30d"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-ccitt",
|
||||
"hayro-jbig2",
|
||||
"hayro-jpeg2000",
|
||||
"memchr",
|
||||
"rustc-hash 2.1.3",
|
||||
"smallvec",
|
||||
"zune-jpeg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.5.3"
|
||||
|
|
@ -1807,7 +2133,7 @@ version = "0.1.20"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
|
|
@ -1973,6 +2299,12 @@ dependencies = [
|
|||
"quick-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imagesize"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65b27460c2c92b037f3f94c538ed9a3342f3fdf923606781629ccb35f82d042a"
|
||||
|
||||
[[package]]
|
||||
name = "imbl"
|
||||
version = "7.0.2"
|
||||
|
|
@ -2716,7 +3048,7 @@ version = "2.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c7959d3349f484aec36462f98226983578bf7d33f9b034c32967489c7000e1f"
|
||||
dependencies = [
|
||||
"phf",
|
||||
"phf 0.11.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2805,7 +3137,40 @@ version = "0.11.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
"phf_shared 0.11.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
|
||||
dependencies = [
|
||||
"phf_macros",
|
||||
"phf_shared 0.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"phf_shared 0.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_macros"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared 0.13.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2817,6 +3182,31 @@ dependencies = [
|
|||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266"
|
||||
dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pic-scale"
|
||||
version = "0.7.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8ee5747ff9d46f571e25570fbb3ceb82846b29a4ead247e6ec01610a1efcde6"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"pxfm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pico-args"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.1.13"
|
||||
|
|
@ -3087,7 +3477,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "c4ed38b89c2c77ff968c524145ad65fb010f38af5c7a224b53b81d47ac2daa81"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"font-types",
|
||||
"font-types 0.11.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.41.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"font-types 0.12.7",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.43.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "005c8acf251756c478b0bf402885bfd88a1476020c4c7e6060edc1aa68da38ea"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"font-types 0.12.7",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.44.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5a0cf4bb6cbce4c29756270d189a5e400ac05e91192161d83a0bcb6e68492e8"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"font-types 0.12.7",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdaa4fffe9ff3ca2c353fa9729792805b9b3e324695ff5a081f860612e81b330"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"foldhash",
|
||||
"font-types 0.12.7",
|
||||
"once_cell",
|
||||
"smallvec",
|
||||
"yoke",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3168,7 +3605,7 @@ version = "0.12.28"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
|
|
@ -3196,6 +3633,24 @@ dependencies = [
|
|||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "resvg"
|
||||
version = "0.50.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77bb4b284cf8a5c8ae721594af53387fb755d2196fddb32b2acfb4fa9251fa0c"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"gif",
|
||||
"image-webp",
|
||||
"log",
|
||||
"pico-args",
|
||||
"rgb",
|
||||
"svgtypes 0.16.2",
|
||||
"tiny-skia",
|
||||
"usvg 0.50.0",
|
||||
"zune-jpeg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rfd"
|
||||
version = "0.15.4"
|
||||
|
|
@ -3220,12 +3675,30 @@ dependencies = [
|
|||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rgb"
|
||||
version = "0.8.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "roxmltree"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97"
|
||||
|
||||
[[package]]
|
||||
name = "roxmltree"
|
||||
version = "0.21.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n"
|
||||
version = "4.2.4"
|
||||
|
|
@ -3398,7 +3871,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "b8050abb251097357e24aff63ba2c52a6309ecb7d23a5474023df960a02694d8"
|
||||
dependencies = [
|
||||
"annotate-snippets",
|
||||
"base64",
|
||||
"base64 0.23.1",
|
||||
"encoding_rs_io",
|
||||
"granit-parser",
|
||||
"nohash-hasher",
|
||||
|
|
@ -3533,6 +4006,15 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
||||
|
||||
[[package]]
|
||||
name = "simplecss"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c"
|
||||
dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "1.0.4"
|
||||
|
|
@ -3546,7 +4028,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "0c34617370ae968efb7161bb2beb517d9084659aae19e24b89e3db25b46e4564"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts",
|
||||
"read-fonts 0.39.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.44.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts 0.41.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "526e654b303ff4ad73a5a40b25de2b3ce3d039c5e3b6da5f89ae6e57004cb40f"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts 0.44.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.49.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7459fb60888ad9a5f367dd293fa2fb9df142cb451aa6bfd6cd66a7d6a9b739d"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"once_cell",
|
||||
"read-fonts 0.46.0",
|
||||
"smallvec",
|
||||
"yoke",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3667,6 +4182,15 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strict-num"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
|
||||
dependencies = [
|
||||
"float-cmp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "svgtypes"
|
||||
version = "0.15.3"
|
||||
|
|
@ -3677,6 +4201,16 @@ dependencies = [
|
|||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "svgtypes"
|
||||
version = "0.16.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f12b12995e3638c70618c1facb1ce65302f6a6f706b675f07c58a5d7391120e"
|
||||
dependencies = [
|
||||
"kurbo 0.13.1",
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.119"
|
||||
|
|
@ -3795,6 +4329,32 @@ dependencies = [
|
|||
"zune-jpeg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiny-skia"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47ffee5eaaf5527f630fb0e356b90ebdec84d5d18d937c5e440350f88c5a91ea"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec",
|
||||
"bytemuck",
|
||||
"cfg-if",
|
||||
"log",
|
||||
"png",
|
||||
"tiny-skia-path",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiny-skia-path"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edca365c3faccca67d06593c5980fa6c57687de727a03131735bb85f01fdeeb9"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"bytemuck",
|
||||
"strict-num",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.8.4"
|
||||
|
|
@ -3805,6 +4365,12 @@ dependencies = [
|
|||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.54.0"
|
||||
|
|
@ -4057,6 +4623,12 @@ dependencies = [
|
|||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-general-category"
|
||||
version = "1.1.0"
|
||||
|
|
@ -4069,12 +4641,24 @@ version = "1.0.27"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-script"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa04c955db05429d464c74d495c1ee677e1866e783a4c3747f9c0cef7756cabf"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-vo"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.3"
|
||||
|
|
@ -4100,6 +4684,62 @@ version = "2.1.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||
|
||||
[[package]]
|
||||
name = "usvg"
|
||||
version = "0.48.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "977d0a4abdef933f424a99fe09f95576e089b90aebc6f016a3bc813762493e91"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"data-url",
|
||||
"flate2",
|
||||
"fontdb",
|
||||
"harfrust 0.12.0",
|
||||
"imagesize",
|
||||
"kurbo 0.13.1",
|
||||
"log",
|
||||
"pico-args",
|
||||
"roxmltree 0.21.2",
|
||||
"simplecss",
|
||||
"siphasher",
|
||||
"skrifa 0.44.0",
|
||||
"strict-num",
|
||||
"svgtypes 0.16.2",
|
||||
"tiny-skia-path",
|
||||
"unicode-bidi",
|
||||
"unicode-script",
|
||||
"unicode-vo",
|
||||
"xmlwriter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "usvg"
|
||||
version = "0.50.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdb896f04730b97805bbc3191fc57e4bf03face0f14577dd42e783c4d8c98802"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"data-url",
|
||||
"flate2",
|
||||
"fontdb",
|
||||
"harfrust 0.15.0",
|
||||
"imagesize",
|
||||
"kurbo 0.13.1",
|
||||
"log",
|
||||
"pico-args",
|
||||
"roxmltree 0.21.2",
|
||||
"simplecss",
|
||||
"siphasher",
|
||||
"skrifa 0.49.0",
|
||||
"strict-num",
|
||||
"svgtypes 0.16.2",
|
||||
"tiny-skia-path",
|
||||
"unicode-bidi",
|
||||
"unicode-script",
|
||||
"unicode-vo",
|
||||
"xmlwriter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf-8"
|
||||
version = "0.7.6"
|
||||
|
|
@ -4130,7 +4770,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "19d672facaa2d697285a786cd9d44d614cd2ce54cdc022504bf339f8fff3b750"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"fearless_simd",
|
||||
"fearless_simd 0.4.1",
|
||||
"guillotiere",
|
||||
"hashbrown 0.17.1",
|
||||
"log",
|
||||
|
|
@ -4139,6 +4779,22 @@ dependencies = [
|
|||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vello_common"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73c2fbe53548bcd25c8ff42f75a93770a8611a16b37bee56d7ef7b44e36027f1"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"fearless_simd 0.7.0",
|
||||
"guillotiere",
|
||||
"log",
|
||||
"peniko",
|
||||
"png",
|
||||
"smallvec",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vello_cpu"
|
||||
version = "0.0.9"
|
||||
|
|
@ -4146,9 +4802,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "588691169aed86b5c8fb487266afee01323234e6fd0a3f2aaec0eaa8e4007f23"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"glifo",
|
||||
"glifo 0.1.1",
|
||||
"hashbrown 0.17.1",
|
||||
"vello_common",
|
||||
"vello_common 0.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vello_cpu"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed1fec424fbba6acf6cbc78bb526447eb77590d95f40419d598870fe37535212"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"glifo 0.4.0",
|
||||
"hashbrown 0.17.1",
|
||||
"png",
|
||||
"vello_common 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4816,6 +5485,12 @@ version = "0.8.29"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7"
|
||||
|
||||
[[package]]
|
||||
name = "xmlwriter"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.8.3"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.9.45"
|
||||
version = "0.9.46"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ bin-dir = "{ name }-{ target }-v{ version }/{ bin }{ binary-ext }"
|
|||
|
||||
[features]
|
||||
default = ["vendor_formats"]
|
||||
vendor_formats = ["dep:craft-dwg", "dep:deckcraft-pptx", "dep:deckcraft-model", "dep:deckcraft-geom", "dep:figcraft-format", "dep:figcraft-doc", "dep:figcraft-geom"]
|
||||
vendor_formats = ["dep:craft-dwg", "dep:deckcraft-pptx", "dep:deckcraft-model", "dep:deckcraft-geom", "dep:figcraft-format", "dep:figcraft-doc", "dep:figcraft-geom", "dep:figcraft-svg"]
|
||||
# Use with --no-default-features to exclude the optional codecs and their dependencies.
|
||||
no_proprietary = []
|
||||
|
||||
|
|
@ -40,9 +40,13 @@ base64 = "0.22"
|
|||
flate2 = "1"
|
||||
csv = "1.4"
|
||||
tempfile = "3"
|
||||
url = "2"
|
||||
directories = "6"
|
||||
reqwest = { version = "0.12.28", default-features = false, features = ["blocking"] }
|
||||
tungstenite = { version = "0.28", default-features = false, features = ["handshake"] }
|
||||
hayro = "0.9"
|
||||
resvg = "0.50"
|
||||
figcraft-svg = { version = "=0.5.1", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
winresource = "0.1.17"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,353 @@
|
|||
use super::*;
|
||||
use canvas_pilot::reference_document::Document;
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
sync::mpsc::{self, Receiver},
|
||||
};
|
||||
|
||||
type Job<T> = Option<Receiver<Result<T, String>>>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct DocumentReferenceUi {
|
||||
queue: VecDeque<egui::DroppedFile>,
|
||||
file: Option<egui::DroppedFile>,
|
||||
loading: Job<Document>,
|
||||
rendering: Job<super::super::reference::Reference>,
|
||||
document: Option<Document>,
|
||||
preview: Option<super::super::reference::Reference>,
|
||||
page: usize,
|
||||
resolution: u32,
|
||||
layout_only: bool,
|
||||
error: String,
|
||||
}
|
||||
|
||||
fn poll<T>(job: &mut Job<T>) -> Option<Result<T, String>> {
|
||||
match job.as_ref()?.try_recv() {
|
||||
Ok(result) => {
|
||||
*job = None;
|
||||
Some(result)
|
||||
}
|
||||
Err(mpsc::TryRecvError::Empty) => None,
|
||||
Err(mpsc::TryRecvError::Disconnected) => {
|
||||
*job = None;
|
||||
Some(Err("Document reader stopped. Please try again.".into()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DocumentReferenceUi {
|
||||
pub(super) fn enqueue(&mut self, file: egui::DroppedFile) -> Result<(), String> {
|
||||
if self.queue.len() >= 32 {
|
||||
return Err("Up to 32 reference documents can be queued.".into());
|
||||
}
|
||||
self.queue.push_back(file);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn load(&mut self, ctx: &egui::Context) {
|
||||
let Some(file) = self.file.clone() else {
|
||||
return;
|
||||
};
|
||||
let layout_only = self.layout_only;
|
||||
self.preview = None;
|
||||
self.document = None;
|
||||
self.rendering = None;
|
||||
self.error.clear();
|
||||
let (tx, rx) = mpsc::channel();
|
||||
self.loading = Some(rx);
|
||||
let ctx = ctx.clone();
|
||||
std::thread::spawn(move || {
|
||||
let result = (|| {
|
||||
let name = file
|
||||
.path
|
||||
.as_deref()
|
||||
.and_then(|p| p.file_name())
|
||||
.map(|n| n.to_string_lossy().into_owned())
|
||||
.unwrap_or(file.name);
|
||||
let bytes = if let Some(bytes) = file.bytes {
|
||||
bytes.to_vec()
|
||||
} else {
|
||||
canvas_pilot::reference_document::read(
|
||||
file.path.as_deref().ok_or("Missing document path")?,
|
||||
)?
|
||||
};
|
||||
Document::open(bytes, &name, layout_only)
|
||||
})();
|
||||
let _ = tx.send(result);
|
||||
ctx.request_repaint();
|
||||
});
|
||||
}
|
||||
|
||||
fn render(&mut self, ctx: &egui::Context) {
|
||||
let Some(document) = self.document.clone() else {
|
||||
return;
|
||||
};
|
||||
self.preview = None;
|
||||
self.error.clear();
|
||||
let page = self.page;
|
||||
let resolution = self.resolution;
|
||||
let (tx, rx) = mpsc::channel();
|
||||
self.rendering = Some(rx);
|
||||
let ctx = ctx.clone();
|
||||
std::thread::spawn(move || {
|
||||
let result = document.render(page, resolution).and_then(|bytes| {
|
||||
let mut reference = super::super::reference::Reference::load(
|
||||
&ctx,
|
||||
&egui::DroppedFile {
|
||||
name: format!("{} · {}", document.name, document.pages[page]),
|
||||
bytes: Some(bytes.into()),
|
||||
..Default::default()
|
||||
},
|
||||
)?;
|
||||
reference.preserve_ratio = true;
|
||||
Ok(reference)
|
||||
});
|
||||
let _ = tx.send(result);
|
||||
ctx.request_repaint();
|
||||
});
|
||||
}
|
||||
|
||||
fn close(&mut self) {
|
||||
self.file = None;
|
||||
self.document = None;
|
||||
self.preview = None;
|
||||
self.loading = None;
|
||||
self.rendering = None;
|
||||
self.error.clear();
|
||||
}
|
||||
|
||||
pub(super) fn show(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
) -> Option<super::super::reference::Reference> {
|
||||
if self.file.is_none()
|
||||
&& let Some(file) = self.queue.pop_front()
|
||||
{
|
||||
self.file = Some(file);
|
||||
self.layout_only = false;
|
||||
self.page = 0;
|
||||
self.resolution = 1920;
|
||||
self.load(ctx);
|
||||
}
|
||||
if let Some(result) = poll(&mut self.loading) {
|
||||
match result {
|
||||
Ok(document) => {
|
||||
self.document = Some(document);
|
||||
self.page = 0;
|
||||
self.render(ctx);
|
||||
}
|
||||
Err(error) => self.error = error,
|
||||
}
|
||||
}
|
||||
if let Some(result) = poll(&mut self.rendering) {
|
||||
match result {
|
||||
Ok(reference) => self.preview = Some(reference),
|
||||
Err(error) => self.error = error,
|
||||
}
|
||||
}
|
||||
self.file.as_ref()?;
|
||||
let mut open = true;
|
||||
let mut add = false;
|
||||
let mut cancel = false;
|
||||
let mut reload = false;
|
||||
let mut render = false;
|
||||
egui::Window::new("Import document as reference")
|
||||
.id(egui::Id::new("document-reference-import"))
|
||||
.open(&mut open)
|
||||
.default_width(600.0)
|
||||
.show(ctx, |ui| {
|
||||
ui.label("Choose a page and check its appearance before adding it.");
|
||||
ui.add_enabled_ui(self.loading.is_none() && self.rendering.is_none(), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Render:");
|
||||
reload |= ui
|
||||
.selectable_value(&mut self.layout_only, false, "Artwork")
|
||||
.changed();
|
||||
reload |= ui
|
||||
.selectable_value(&mut self.layout_only, true, "Layout boxes")
|
||||
.changed();
|
||||
});
|
||||
});
|
||||
if let Some(document) = &self.document {
|
||||
ui.label(&document.name);
|
||||
ui.label(&document.note);
|
||||
ui.add_enabled_ui(self.rendering.is_none(), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
egui::ComboBox::from_id_salt("reference-document-page")
|
||||
.selected_text(&document.pages[self.page])
|
||||
.show_ui(ui, |ui| {
|
||||
for (i, name) in document.pages.iter().enumerate() {
|
||||
render |=
|
||||
ui.selectable_value(&mut self.page, i, name).changed();
|
||||
}
|
||||
});
|
||||
egui::ComboBox::from_id_salt("reference-document-resolution")
|
||||
.selected_text(format!("{} px longest edge", self.resolution))
|
||||
.show_ui(ui, |ui| {
|
||||
for size in [1280, 1920, 2560, 3840, 4096] {
|
||||
render |= ui
|
||||
.selectable_value(
|
||||
&mut self.resolution,
|
||||
size,
|
||||
format!("{size} px"),
|
||||
)
|
||||
.changed();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
if let Some(preview) = &self.preview {
|
||||
ui.add(
|
||||
egui::Image::new((preview.texture.id(), preview.texture.size_vec2()))
|
||||
.max_size(egui::vec2(560.0, 330.0)),
|
||||
);
|
||||
ui.small(format!(
|
||||
"{} × {} px · proportions preserved",
|
||||
preview.size[0], preview.size[1]
|
||||
));
|
||||
}
|
||||
if self.loading.is_some() || self.rendering.is_some() {
|
||||
ui.spinner();
|
||||
ui.label("Preparing reference…");
|
||||
}
|
||||
if !self.error.is_empty() {
|
||||
ui.colored_label(theme::palette(ctx).amber, &self.error);
|
||||
}
|
||||
add = ui
|
||||
.add_enabled(
|
||||
self.preview.is_some() && !reload && !render,
|
||||
egui::Button::new("Add reference"),
|
||||
)
|
||||
.clicked();
|
||||
cancel = ui.button("Cancel").clicked();
|
||||
});
|
||||
if !open || cancel {
|
||||
self.close();
|
||||
return None;
|
||||
}
|
||||
if reload {
|
||||
self.load(ctx);
|
||||
} else if render {
|
||||
self.render(ctx);
|
||||
}
|
||||
if add {
|
||||
let reference = self.preview.take();
|
||||
self.close();
|
||||
return reference;
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::tests::{frame, mouse};
|
||||
use super::*;
|
||||
|
||||
fn wait_preview(app: &mut Editor, ctx: &egui::Context) {
|
||||
let until = std::time::Instant::now() + std::time::Duration::from_secs(15);
|
||||
while app.document_reference.preview.is_none()
|
||||
&& app.document_reference.error.is_empty()
|
||||
&& std::time::Instant::now() < until
|
||||
{
|
||||
frame(app, ctx, vec![]);
|
||||
std::thread::sleep(std::time::Duration::from_millis(5));
|
||||
}
|
||||
assert!(
|
||||
app.document_reference.error.is_empty(),
|
||||
"{}",
|
||||
app.document_reference.error
|
||||
);
|
||||
assert!(app.document_reference.preview.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_review_adds_selected_page_as_portable_reference_without_changing_layers() {
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = Editor::default();
|
||||
let before = app.project();
|
||||
app.load_reference(
|
||||
&ctx,
|
||||
&egui::DroppedFile {
|
||||
name: "client.pdf".into(),
|
||||
bytes: Some(
|
||||
include_bytes!("../tests/fixtures/reference-pages.pdf")
|
||||
.to_vec()
|
||||
.into(),
|
||||
),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
wait_preview(&mut app, &ctx);
|
||||
assert_eq!(
|
||||
app.project(),
|
||||
before,
|
||||
"preview must not change the document"
|
||||
);
|
||||
app.document_reference.page = 1;
|
||||
app.document_reference.resolution = 200;
|
||||
app.document_reference.render(&ctx);
|
||||
wait_preview(&mut app, &ctx);
|
||||
let output = frame(&mut app, &ctx, vec![]);
|
||||
let pos = output
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|s| match &s.shape {
|
||||
egui::Shape::Text(t) if t.galley.text() == "Add reference" => {
|
||||
Some(t.pos + t.galley.size() / 2.0)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.unwrap();
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::PointerMoved(pos), mouse(pos, true)],
|
||||
);
|
||||
frame(&mut app, &ctx, vec![mouse(pos, false)]);
|
||||
assert_eq!(app.references.len(), 1);
|
||||
let reference = &app.references[0];
|
||||
assert_eq!(reference.name, "client.pdf · Page 2");
|
||||
assert!(reference.preserve_ratio);
|
||||
assert_eq!(reference.size, [200, 200]);
|
||||
assert_eq!(app.project().layers, before.layers);
|
||||
let saved =
|
||||
canvas_pilot::project::Project::from_json(&app.project().to_json().unwrap()).unwrap();
|
||||
let mut restored = Editor::default();
|
||||
restored.install_project(&ctx, saved).unwrap();
|
||||
assert_eq!(restored.references[0].bytes, reference.bytes);
|
||||
assert!(restored.references[0].preserve_ratio);
|
||||
assert!(app.document_reference.file.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cancellation_and_failed_documents_keep_existing_project_and_ignore_late_results() {
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = Editor::default();
|
||||
let before = app.project();
|
||||
app.document_reference.file = Some(egui::DroppedFile {
|
||||
name: "bad.pdf".into(),
|
||||
bytes: Some(b"broken".to_vec().into()),
|
||||
..Default::default()
|
||||
});
|
||||
app.document_reference.load(&ctx);
|
||||
let until = std::time::Instant::now() + std::time::Duration::from_secs(5);
|
||||
while app.document_reference.error.is_empty() && std::time::Instant::now() < until {
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
std::thread::sleep(std::time::Duration::from_millis(5));
|
||||
}
|
||||
assert!(app.document_reference.error.contains("Cannot open PDF"));
|
||||
assert_eq!(app.project(), before);
|
||||
let (tx, rx) = mpsc::channel();
|
||||
app.document_reference.loading = Some(rx);
|
||||
app.document_reference.close();
|
||||
assert!(tx.send(Err("late result".into())).is_err());
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
assert_eq!(app.project(), before);
|
||||
assert!(app.document_reference.error.is_empty());
|
||||
let (tx, rx) = mpsc::channel::<Result<Document, String>>();
|
||||
drop(tx);
|
||||
assert!(poll(&mut Some(rx)).unwrap().is_err());
|
||||
}
|
||||
}
|
||||
|
|
@ -581,3 +581,71 @@ pub(crate) fn looks_like_dxf(text: &str) -> bool {
|
|||
|| (start.starts_with("0\r\nSECTION") && text.contains("LWPOLYLINE"))
|
||||
|| (start.starts_with("0\nSECTION") && text.contains("LWPOLYLINE"))
|
||||
}
|
||||
|
||||
/// Render the supported HTML/JSON exchange schema, retaining embedded pictures.
|
||||
pub(crate) fn reference_svg(text: &str, html: bool) -> Result<String, String> {
|
||||
let (size, shapes) = if html {
|
||||
let parsed = parse_html(text)?;
|
||||
let xml = roxmltree::Document::parse_with_options(
|
||||
text,
|
||||
roxmltree::ParsingOptions {
|
||||
allow_dtd: true,
|
||||
nodes_limit: 200_000,
|
||||
},
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
let canvas = xml
|
||||
.descendants()
|
||||
.find(|n| n.attribute("id") == Some("midra-canvas"))
|
||||
.ok_or("Missing canvas")?;
|
||||
let nodes = canvas
|
||||
.descendants()
|
||||
.filter(|n| n.is_element() && n.attribute("data-midra-role").is_some());
|
||||
let shapes = parsed
|
||||
.shapes
|
||||
.into_iter()
|
||||
.zip(nodes)
|
||||
.map(|(s, node)| {
|
||||
let image = node
|
||||
.attribute("src")
|
||||
.and_then(|s| s.strip_prefix("data:image/png;base64,"))
|
||||
.map(str::to_owned);
|
||||
ExportShape {
|
||||
id: crate::exchange::escape(node.attribute("id").unwrap_or("")),
|
||||
name: s.name.unwrap_or_default(),
|
||||
geometry: s.geometry,
|
||||
background: s.background,
|
||||
image_png_base64: image,
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
(
|
||||
[
|
||||
xml_number(canvas, "data-width")? as u32,
|
||||
xml_number(canvas, "data-height")? as u32,
|
||||
],
|
||||
shapes,
|
||||
)
|
||||
} else {
|
||||
parse_json(text)?;
|
||||
let json: JsonDocument = serde_json::from_str(text).map_err(|e| e.to_string())?;
|
||||
let shapes = json
|
||||
.layers
|
||||
.into_iter()
|
||||
.map(|s| ExportShape {
|
||||
id: crate::exchange::escape(&s.id),
|
||||
name: s.name,
|
||||
geometry: Geometry {
|
||||
x: s.x as f64,
|
||||
y: s.y as f64,
|
||||
width: s.width as f64,
|
||||
height: s.height as f64,
|
||||
},
|
||||
background: s.role == "background",
|
||||
image_png_base64: s.image_png_base64,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
([json.canvas.width, json.canvas.height], shapes)
|
||||
};
|
||||
crate::exchange::encode_shapes(Format::Svg, size, &shapes)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ use super::*;
|
|||
mod capture_ui;
|
||||
#[path = "device_ui.rs"]
|
||||
mod device_ui;
|
||||
#[path = "document_reference_ui.rs"]
|
||||
mod document_reference_ui;
|
||||
#[path = "format_ui.rs"]
|
||||
mod format_ui;
|
||||
#[path = "input_ui.rs"]
|
||||
|
|
@ -105,6 +107,7 @@ pub struct Editor {
|
|||
reference_pending: std::collections::VecDeque<
|
||||
std::sync::mpsc::Receiver<Result<super::reference::Reference, String>>,
|
||||
>,
|
||||
document_reference: document_reference_ui::DocumentReferenceUi,
|
||||
outline_layers: bool,
|
||||
backdrop_title: String,
|
||||
reference_open: bool,
|
||||
|
|
@ -431,6 +434,7 @@ impl Default for Editor {
|
|||
references: Vec::new(),
|
||||
reference_selected: None,
|
||||
reference_pending: Default::default(),
|
||||
document_reference: Default::default(),
|
||||
outline_layers: false,
|
||||
backdrop_title: canvas_pilot::project::DEFAULT_BACKDROP_TITLE.into(),
|
||||
reference_open: false,
|
||||
|
|
@ -695,6 +699,16 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
fn load_reference(&mut self, ctx: &egui::Context, file: &egui::DroppedFile) {
|
||||
let path = file
|
||||
.path
|
||||
.as_deref()
|
||||
.unwrap_or_else(|| std::path::Path::new(&file.name));
|
||||
if canvas_pilot::reference_document::is_document(path) {
|
||||
if let Err(error) = self.document_reference.enqueue(file.clone()) {
|
||||
self.reference_error = error;
|
||||
}
|
||||
return;
|
||||
}
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
if self.references.len() + self.reference_pending.len() >= 32 {
|
||||
self.reference_error = "Up to 32 reference images can be stored.".into();
|
||||
|
|
@ -721,21 +735,24 @@ impl Editor {
|
|||
};
|
||||
self.reference_pending.pop_front();
|
||||
match result {
|
||||
Ok(reference) => {
|
||||
if self.references.iter().map(|r| r.bytes.len()).sum::<usize>()
|
||||
+ reference.bytes.len()
|
||||
> 64 * 1024 * 1024
|
||||
{
|
||||
self.reference_error =
|
||||
"Reference images exceed the combined 64 MiB limit.".into();
|
||||
return;
|
||||
}
|
||||
self.references.push(reference);
|
||||
self.reference_selected = Some(self.references.len() - 1);
|
||||
}
|
||||
Ok(reference) => self.add_reference(reference),
|
||||
Err(error) => self.reference_error = error,
|
||||
}
|
||||
}
|
||||
fn add_reference(&mut self, reference: super::reference::Reference) {
|
||||
if self.references.len() >= 32 {
|
||||
self.reference_error = "Up to 32 reference images can be stored.".into();
|
||||
} else if self.references.iter().map(|r| r.bytes.len()).sum::<usize>()
|
||||
+ reference.bytes.len()
|
||||
> 64 * 1024 * 1024
|
||||
{
|
||||
self.reference_error = "Reference images exceed the combined 64 MiB limit.".into();
|
||||
} else {
|
||||
self.references.push(reference);
|
||||
self.reference_selected = Some(self.references.len() - 1);
|
||||
self.reference_error.clear();
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
fn wait_reference(&mut self) {
|
||||
let until = std::time::Instant::now() + std::time::Duration::from_secs(5);
|
||||
|
|
@ -747,7 +764,10 @@ impl Editor {
|
|||
}
|
||||
fn import_reference_file(&mut self, ctx: &egui::Context) {
|
||||
if let Some(paths) = rfd::FileDialog::new()
|
||||
.add_filter("Pictures", &["png", "jpg", "jpeg", "bmp"])
|
||||
.add_filter(
|
||||
"Pictures and documents",
|
||||
&canvas_pilot::reference_document::extensions(),
|
||||
)
|
||||
.pick_files()
|
||||
{
|
||||
for path in paths {
|
||||
|
|
@ -772,10 +792,7 @@ impl Editor {
|
|||
if ui.button(tr(ui.ctx(), "ui.import-picture")).clicked() {
|
||||
self.import_reference_file(ctx);
|
||||
}
|
||||
ui.label(tr(
|
||||
ui.ctx(),
|
||||
"ui.or-drag-png-jpeg-or-bmp-images-into-the-window",
|
||||
));
|
||||
ui.label("Add pictures, PDF pages or supported documents as references. Drop geometry files here while this window is open to import them as pictures.");
|
||||
if !self.reference_pending.is_empty() {
|
||||
ui.spinner();
|
||||
ui.label(tr(
|
||||
|
|
@ -4245,12 +4262,15 @@ impl Editor {
|
|||
|| self.layer_ui.rename.is_some()
|
||||
|| self.layer_ui.folder_rename.is_some();
|
||||
self.poll_reference();
|
||||
if let Some(reference) = self.document_reference.show(ctx) {
|
||||
self.add_reference(reference);
|
||||
}
|
||||
let palette = theme::palette(ctx);
|
||||
let dropped = ctx.input(|i| i.raw.dropped_files.clone());
|
||||
if self.files.loading.is_none() {
|
||||
let mut geometry = Vec::new();
|
||||
for file in &dropped {
|
||||
if Self::geometry_drop(file) {
|
||||
if Self::geometry_drop(file) && !self.reference_open {
|
||||
geometry.push(file.clone());
|
||||
} else {
|
||||
self.load_reference(ctx, file);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ pub mod import;
|
|||
pub mod input_proposal;
|
||||
pub mod interchange;
|
||||
pub mod project;
|
||||
pub mod reference_document;
|
||||
pub mod size_presets;
|
||||
pub mod snapping;
|
||||
#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,496 @@
|
|||
//! Local document-to-picture imports. Sources are never modified or saved over.
|
||||
use hayro::hayro_syntax::Pdf;
|
||||
use std::{io::Read, path::Path, sync::Arc};
|
||||
|
||||
pub const MAX_BYTES: usize = 64 * 1024 * 1024;
|
||||
const MAX_PAGES: usize = 256;
|
||||
static RENDER_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||
|
||||
#[derive(Clone)]
|
||||
enum Source {
|
||||
Pdf(Arc<Vec<u8>>),
|
||||
Svg(Vec<String>),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Document {
|
||||
pub name: String,
|
||||
pub pages: Vec<String>,
|
||||
pub note: String,
|
||||
source: Source,
|
||||
}
|
||||
|
||||
/// Pictures plus every geometry format compiled into this build.
|
||||
pub fn extensions() -> Vec<&'static str> {
|
||||
let mut extensions = crate::interchange::extensions();
|
||||
extensions.extend(["pdf", "png", "jpg", "jpeg", "bmp"]);
|
||||
extensions
|
||||
}
|
||||
|
||||
pub fn is_document(name: &Path) -> bool {
|
||||
name.extension()
|
||||
.and_then(|v| v.to_str())
|
||||
.is_some_and(|ext| {
|
||||
let ext = ext.to_ascii_lowercase();
|
||||
!matches!(ext.as_str(), "png" | "jpg" | "jpeg" | "bmp")
|
||||
&& extensions().contains(&ext.as_str())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read(path: &Path) -> Result<Vec<u8>, String> {
|
||||
let mut bytes = Vec::new();
|
||||
std::fs::File::open(path)
|
||||
.and_then(|f| f.take(MAX_BYTES as u64 + 1).read_to_end(&mut bytes))
|
||||
.map_err(|e| format!("Cannot read reference document: {e}"))?;
|
||||
check_size(&bytes)?;
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
fn check_size(bytes: &[u8]) -> Result<(), String> {
|
||||
if bytes.len() > MAX_BYTES {
|
||||
Err("Reference document exceeds 64 MiB.".into())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Document {
|
||||
/// `layout_only` explicitly requests the existing geometry codec's bounds view.
|
||||
pub fn open(bytes: Vec<u8>, name: &str, layout_only: bool) -> Result<Self, String> {
|
||||
check_size(&bytes)?;
|
||||
let ext = Path::new(name)
|
||||
.extension()
|
||||
.and_then(|v| v.to_str())
|
||||
.unwrap_or("")
|
||||
.to_ascii_lowercase();
|
||||
if matches!(ext.as_str(), "pptx" | "fig" | "figcraft" | "ai" | "dwg")
|
||||
&& !crate::interchange::extensions().contains(&ext.as_str())
|
||||
{
|
||||
return Err("Vendor format support is disabled in this build.".into());
|
||||
}
|
||||
if ext == "pdf" || bytes.starts_with(b"%PDF-") {
|
||||
return Self::pdf(
|
||||
bytes,
|
||||
name,
|
||||
"PDF page rendered locally. Check the preview before adding it.",
|
||||
);
|
||||
}
|
||||
if !layout_only && ext == "svg" {
|
||||
return Ok(Self { name: name.into(), pages: vec!["Artwork".into()],
|
||||
note: "SVG artwork. Embedded images and installed fonts are rendered; linked external images are omitted.".into(),
|
||||
source: Source::Svg(vec![String::from_utf8(bytes).map_err(|e| e.to_string())?]) });
|
||||
}
|
||||
if !layout_only && matches!(ext.as_str(), "json" | "html") {
|
||||
let text = std::str::from_utf8(&bytes).map_err(|e| e.to_string())?;
|
||||
let svg = crate::geometry_formats::reference_svg(text, ext == "html")?;
|
||||
return Ok(Self { name: name.into(), pages: vec!["Layout artwork".into()],
|
||||
note: "Canvas Pilot exchange artwork, including embedded PNG pictures. HTML is rendered from its geometry data; custom CSS and scripts are not executed.".into(), source: Source::Svg(vec![svg]) });
|
||||
}
|
||||
if !layout_only && ext == "pptx" {
|
||||
let pdf = office_pdf(&bytes)?;
|
||||
return Self::pdf(
|
||||
pdf,
|
||||
name,
|
||||
"Slides rendered by LibreOffice. Fonts and effects may differ from PowerPoint; check the preview.",
|
||||
);
|
||||
}
|
||||
if !layout_only && matches!(ext.as_str(), "drawio" | "xml") {
|
||||
let pdf = drawio_pdf(&bytes)?;
|
||||
return Self::pdf(
|
||||
pdf,
|
||||
name,
|
||||
"Diagram pages rendered by draw.io Desktop. Check the preview.",
|
||||
);
|
||||
}
|
||||
#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))]
|
||||
if !layout_only && ext == "ai" {
|
||||
let pages = crate::vendor_formats::reference_ai(&bytes)?;
|
||||
return Ok(Self { name: name.into(), pages: pages.iter().map(|p| p.0.clone()).collect(),
|
||||
note: "Illustrator artwork converted by VectorCraft. Check the preview for conversion differences.".into(),
|
||||
source: Source::Svg(pages.into_iter().map(|p| p.1).collect()) });
|
||||
}
|
||||
#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))]
|
||||
if !layout_only && matches!(ext.as_str(), "fig" | "figcraft") {
|
||||
let (pages, warnings) =
|
||||
crate::vendor_formats::reference_fig(&bytes, name, ext == "figcraft")?;
|
||||
return Ok(Self {
|
||||
name: name.into(),
|
||||
pages: pages.iter().map(|p| p.0.clone()).collect(),
|
||||
note: format!(
|
||||
"Figma artwork rendered through FigCraft (best effort). Check the preview. {warnings}"
|
||||
),
|
||||
source: Source::Svg(pages.into_iter().map(|p| p.1).collect()),
|
||||
});
|
||||
}
|
||||
if !layout_only && !matches!(ext.as_str(), "json" | "csv" | "dxf" | "dwg") {
|
||||
return Err("This format currently provides a layout preview only. Select ‘Layout boxes’ to render its supported geometry, or export PDF/SVG from the source application for the complete artwork.".into());
|
||||
}
|
||||
let pages = crate::interchange::import(&bytes, name)?;
|
||||
let mut pictures = Vec::new();
|
||||
for page in &pages {
|
||||
pictures.push(layout_svg(&page.document)?);
|
||||
}
|
||||
Ok(Self { name: name.into(), pages: pages.iter().map(|p| p.name.clone()).collect(),
|
||||
note: "Layout boxes only: labels and bounds from the geometry importer. Original artwork, fonts, pictures and decorative shapes are not reproduced. The preview fits the detected bounds.".into(),
|
||||
source: Source::Svg(pictures) })
|
||||
}
|
||||
|
||||
fn pdf(bytes: Vec<u8>, name: &str, note: &str) -> Result<Self, String> {
|
||||
let pdf = parse_pdf(bytes.clone())?;
|
||||
let count = pdf.pages().len();
|
||||
if count == 0 || count > MAX_PAGES {
|
||||
return Err("Choose a PDF with 1–256 pages.".into());
|
||||
}
|
||||
Ok(Self {
|
||||
name: name.into(),
|
||||
pages: (1..=count).map(|n| format!("Page {n}")).collect(),
|
||||
note: note.into(),
|
||||
source: Source::Pdf(Arc::new(bytes)),
|
||||
})
|
||||
}
|
||||
|
||||
/// Render only the chosen page, at a bounded size, and encode portable PNG bytes.
|
||||
pub fn render(&self, page: usize, longest_side: u32) -> Result<Vec<u8>, String> {
|
||||
if page >= self.pages.len() {
|
||||
return Err("Reference page is out of range.".into());
|
||||
}
|
||||
if !(64..=4096).contains(&longest_side) {
|
||||
return Err("Reference resolution must be 64–4096 pixels.".into());
|
||||
}
|
||||
let _guard = RENDER_LOCK
|
||||
.lock()
|
||||
.map_err(|_| "Document renderer stopped; please restart the app.")?;
|
||||
let bytes = match &self.source {
|
||||
Source::Pdf(bytes) => {
|
||||
let pdf = parse_pdf(bytes.as_ref().clone())?;
|
||||
let page = &pdf.pages()[page];
|
||||
let (w, h) = page.render_dimensions();
|
||||
let scale = render_scale(w, h, longest_side)?;
|
||||
let pixmap = hayro::render(
|
||||
page,
|
||||
&hayro::RenderCache::new(),
|
||||
&Default::default(),
|
||||
&Default::default(),
|
||||
&hayro::PixmapSettings {
|
||||
x_scale: scale,
|
||||
y_scale: scale,
|
||||
bg_color: hayro::vello_cpu::color::palette::css::WHITE,
|
||||
},
|
||||
);
|
||||
pixmap
|
||||
.into_png()
|
||||
.map_err(|e| format!("Cannot encode rendered PDF: {e}"))?
|
||||
}
|
||||
Source::Svg(pages) => render_svg(pages[page].as_bytes(), longest_side)?,
|
||||
};
|
||||
check_size(&bytes)?;
|
||||
Ok(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_pdf(bytes: Vec<u8>) -> Result<Pdf, String> {
|
||||
Pdf::new(bytes).map_err(|e| format!("Cannot open PDF ({e:?}). For a password-protected document, export an unlocked copy first."))
|
||||
}
|
||||
|
||||
fn render_scale(width: f32, height: f32, longest: u32) -> Result<f32, String> {
|
||||
if !width.is_finite() || !height.is_finite() || width <= 0.0 || height <= 0.0 {
|
||||
return Err("Invalid document page dimensions.".into());
|
||||
}
|
||||
let scale = longest as f32 / width.max(height);
|
||||
if width.min(height) * scale < 1.0 {
|
||||
return Err("Document page is too narrow to render.".into());
|
||||
}
|
||||
Ok(scale)
|
||||
}
|
||||
|
||||
fn render_svg(bytes: &[u8], longest: u32) -> Result<Vec<u8>, String> {
|
||||
let mut options = resvg::usvg::Options::default();
|
||||
options.image_href_resolver.resolve_string = Box::new(|_, _| None);
|
||||
options.fontdb_mut().load_system_fonts();
|
||||
let tree = resvg::usvg::Tree::from_data(bytes, &options)
|
||||
.map_err(|e| format!("Cannot render SVG: {e}"))?;
|
||||
let scale = render_scale(tree.size().width(), tree.size().height(), longest)?;
|
||||
let width = (tree.size().width() * scale).ceil() as u32;
|
||||
let height = (tree.size().height() * scale).ceil() as u32;
|
||||
let mut pixmap =
|
||||
resvg::tiny_skia::Pixmap::new(width, height).ok_or("Cannot allocate reference image.")?;
|
||||
resvg::render(
|
||||
&tree,
|
||||
resvg::tiny_skia::Transform::from_scale(scale, scale),
|
||||
&mut pixmap.as_mut(),
|
||||
);
|
||||
pixmap.encode_png().map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
fn layout_svg(document: &crate::import::ImportDocument) -> Result<String, String> {
|
||||
if document.shapes.is_empty() {
|
||||
return Err("No supported layout shapes found.".into());
|
||||
}
|
||||
let mut bounds = [0.0_f64, 0.0_f64, 1.0_f64, 1.0_f64];
|
||||
for s in &document.shapes {
|
||||
let g = s.geometry.validate()?;
|
||||
bounds[0] = bounds[0].min(g.x);
|
||||
bounds[1] = bounds[1].min(g.y);
|
||||
bounds[2] = bounds[2].max(g.x + g.width);
|
||||
bounds[3] = bounds[3].max(g.y + g.height);
|
||||
}
|
||||
let [x, y, right, bottom] = bounds;
|
||||
let width = right - x;
|
||||
let height = bottom - y;
|
||||
let mut svg = format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{width}\" height=\"{height}\" viewBox=\"{x} {y} {width} {height}\"><rect x=\"{x}\" y=\"{y}\" width=\"{width}\" height=\"{height}\" fill=\"#111720\"/>"
|
||||
);
|
||||
for s in &document.shapes {
|
||||
let g = s.geometry;
|
||||
let name = crate::exchange::escape(s.name.as_deref().unwrap_or(&s.id));
|
||||
let fill = if s.background { "#1b2330" } else { "#315066" };
|
||||
svg.push_str(&format!("<rect x=\"{}\" y=\"{}\" width=\"{}\" height=\"{}\" fill=\"{fill}\" stroke=\"#66dbef\" stroke-width=\"{}\"/><text x=\"{}\" y=\"{}\" font-family=\"sans-serif\" font-size=\"{}\" fill=\"white\">{name}</text>", g.x, g.y, g.width, g.height, width / 800.0, g.x + width / 200.0, g.y + height / 35.0, height / 45.0));
|
||||
}
|
||||
svg.push_str("</svg>");
|
||||
Ok(svg)
|
||||
}
|
||||
|
||||
fn converter(env: &str, name: &str) -> std::path::PathBuf {
|
||||
if let Some(path) = std::env::var_os(env) {
|
||||
return path.into();
|
||||
}
|
||||
if let Ok(exe) = std::env::current_exe()
|
||||
&& let Some(parent) = exe.parent()
|
||||
{
|
||||
for path in [parent.join(name), parent.join("bin").join(name)] {
|
||||
if path.is_file() {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
name.into()
|
||||
}
|
||||
|
||||
fn office_pdf(bytes: &[u8]) -> Result<Vec<u8>, String> {
|
||||
let dir = tempfile::tempdir().map_err(|e| e.to_string())?;
|
||||
let input = dir.path().join("source.pptx");
|
||||
std::fs::write(&input, bytes).map_err(|e| e.to_string())?;
|
||||
// A separate profile prevents handing the document to an already running user session.
|
||||
let profile = url::Url::from_directory_path(dir.path().join("profile"))
|
||||
.map_err(|_| "Invalid converter profile path")?;
|
||||
let mut cmd = std::process::Command::new(converter(
|
||||
"CANVAS_PILOT_LIBREOFFICE",
|
||||
if cfg!(windows) {
|
||||
"soffice.exe"
|
||||
} else {
|
||||
"libreoffice"
|
||||
},
|
||||
));
|
||||
cmd.arg(format!("-env:UserInstallation={profile}"))
|
||||
.args([
|
||||
"--headless",
|
||||
"--convert-to",
|
||||
"pdf:impress_pdf_Export",
|
||||
"--outdir",
|
||||
])
|
||||
.arg(dir.path())
|
||||
.arg(input);
|
||||
run_converter(&mut cmd, "LibreOffice", "CANVAS_PILOT_LIBREOFFICE")?;
|
||||
read(&dir.path().join("source.pdf"))
|
||||
}
|
||||
|
||||
fn drawio_pdf(bytes: &[u8]) -> Result<Vec<u8>, String> {
|
||||
let dir = tempfile::tempdir().map_err(|e| e.to_string())?;
|
||||
let input = dir.path().join("source.drawio");
|
||||
let output = dir.path().join("source.pdf");
|
||||
std::fs::write(&input, bytes).map_err(|e| e.to_string())?;
|
||||
let mut cmd = std::process::Command::new(converter(
|
||||
"CANVAS_PILOT_DRAWIO",
|
||||
if cfg!(windows) {
|
||||
"draw.io.exe"
|
||||
} else {
|
||||
"drawio"
|
||||
},
|
||||
));
|
||||
cmd.args(["--export", "--format", "pdf", "--all-pages", "--output"])
|
||||
.arg(&output)
|
||||
.arg(input);
|
||||
run_converter(&mut cmd, "draw.io Desktop", "CANVAS_PILOT_DRAWIO")?;
|
||||
read(&output)
|
||||
}
|
||||
|
||||
fn run_converter(cmd: &mut std::process::Command, label: &str, env: &str) -> Result<(), String> {
|
||||
use std::{
|
||||
process::Stdio,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
let mut child = cmd.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null()).spawn()
|
||||
.map_err(|e| format!("Cannot start {label}: {e}. Install it or set {env} to its executable. You can also select Layout boxes or import an exported PDF/SVG."))?;
|
||||
let start = Instant::now();
|
||||
loop {
|
||||
match child.try_wait() {
|
||||
Ok(Some(status)) if status.success() => return Ok(()),
|
||||
Ok(Some(status)) => {
|
||||
return Err(format!(
|
||||
"{label} conversion failed ({status}). Export PDF/SVG in the source application, or use Layout boxes."
|
||||
));
|
||||
}
|
||||
Ok(None) if start.elapsed() < Duration::from_secs(60) => {
|
||||
std::thread::sleep(Duration::from_millis(50))
|
||||
}
|
||||
result => {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
return Err(format!(
|
||||
"{label} did not finish within 60 seconds: {result:?}"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
const PDF: &[u8] = include_bytes!("../tests/fixtures/reference-pages.pdf");
|
||||
|
||||
#[test]
|
||||
fn pdf_page_selection_crop_and_rotation_render_distinct_images() {
|
||||
let document = Document::open(PDF.to_vec(), "client.PDF", false).unwrap();
|
||||
assert_eq!(document.pages, ["Page 1", "Page 2"]);
|
||||
let red = image::load_from_memory(&document.render(0, 200).unwrap())
|
||||
.unwrap()
|
||||
.into_rgba8();
|
||||
assert_eq!(red.dimensions(), (200, 100));
|
||||
assert_eq!(red.get_pixel(50, 50).0, [255, 0, 0, 255]);
|
||||
let green = image::load_from_memory(&document.render(1, 200).unwrap())
|
||||
.unwrap()
|
||||
.into_rgba8();
|
||||
assert_eq!(green.dimensions(), (200, 200));
|
||||
assert_eq!(green.get_pixel(50, 50).0, [0, 255, 0, 255]);
|
||||
assert!(document.render(2, 200).is_err());
|
||||
assert!(document.render(0, 8192).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn svg_artwork_keeps_color_transparency_and_does_not_fetch_linked_images() {
|
||||
let svg = br#"<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100"><rect width="100" height="100" fill="red"/><image href="file:///not-a-reference.png" x="100" width="100" height="100"/></svg>"#;
|
||||
let doc = Document::open(svg.to_vec(), "art.svg", false).unwrap();
|
||||
let image = image::load_from_memory(&doc.render(0, 200).unwrap())
|
||||
.unwrap()
|
||||
.into_rgba8();
|
||||
assert_eq!(image.dimensions(), (200, 100));
|
||||
assert_eq!(image.get_pixel(10, 10).0, [255, 0, 0, 255]);
|
||||
assert_eq!(image.get_pixel(150, 50).0[3], 0);
|
||||
assert!(Document::open(b"broken".to_vec(), "bad.pdf", false).is_err());
|
||||
assert!(
|
||||
Document::open(b"broken".to_vec(), "bad.svg", false)
|
||||
.unwrap()
|
||||
.render(0, 200)
|
||||
.is_err()
|
||||
);
|
||||
assert!(render_scale(f32::INFINITY, 1.0, 200).is_err());
|
||||
assert!(render_scale(0.0, 1.0, 200).is_err());
|
||||
assert!(render_scale(1e20, 1.0, 200).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn supported_exchange_documents_offer_explicit_layout_pictures() {
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../docs/templates/canvas-pilot");
|
||||
for codec in crate::interchange::Codec::available() {
|
||||
if codec == crate::interchange::Codec::Illustrator {
|
||||
continue;
|
||||
}
|
||||
let path = root.join(format!("canvas-pilot-template.{}", codec.extension()));
|
||||
// The catalog owns the canonical starter basename.
|
||||
let path = if path.exists() {
|
||||
path
|
||||
} else {
|
||||
std::fs::read_dir(&root)
|
||||
.unwrap()
|
||||
.filter_map(Result::ok)
|
||||
.map(|e| e.path())
|
||||
.find(|p| p.extension().and_then(|e| e.to_str()) == Some(codec.extension()))
|
||||
.unwrap()
|
||||
};
|
||||
let doc = Document::open(
|
||||
read(&path).unwrap(),
|
||||
path.file_name().unwrap().to_str().unwrap(),
|
||||
true,
|
||||
)
|
||||
.unwrap();
|
||||
assert!(doc.note.contains("Layout boxes only"), "{}", codec.label());
|
||||
assert!(!doc.render(0, 320).unwrap().is_empty(), "{}", codec.label());
|
||||
}
|
||||
assert!(is_document(Path::new("drawing.PDF")));
|
||||
assert!(!is_document(Path::new("picture.PNG")));
|
||||
assert!(!is_document(Path::new("unknown.xyz")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json_and_html_artwork_preserve_embedded_images_and_canvas() {
|
||||
use crate::exchange::{ExportShape, Format, encode_shapes};
|
||||
use base64::Engine;
|
||||
let mut png = std::io::Cursor::new(Vec::new());
|
||||
image::RgbaImage::from_pixel(2, 2, image::Rgba([255, 0, 0, 255]))
|
||||
.write_to(&mut png, image::ImageFormat::Png)
|
||||
.unwrap();
|
||||
let shapes = [ExportShape {
|
||||
id: "red".into(),
|
||||
name: "Picture".into(),
|
||||
geometry: crate::Geometry {
|
||||
x: 0.,
|
||||
y: 0.,
|
||||
width: 200.,
|
||||
height: 100.,
|
||||
},
|
||||
image_png_base64: Some(
|
||||
base64::engine::general_purpose::STANDARD.encode(png.into_inner()),
|
||||
),
|
||||
background: true,
|
||||
}];
|
||||
for format in [Format::Json, Format::Html] {
|
||||
let bytes = encode_shapes(format, [200, 100], &shapes)
|
||||
.unwrap()
|
||||
.into_bytes();
|
||||
let doc =
|
||||
Document::open(bytes, &format!("client.{}", format.extension()), false).unwrap();
|
||||
let image = image::load_from_memory(&doc.render(0, 200).unwrap())
|
||||
.unwrap()
|
||||
.into_rgba8();
|
||||
assert_eq!(image.dimensions(), (200, 100));
|
||||
assert_eq!(image.get_pixel(50, 50).0, [255, 0, 0, 255]);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))]
|
||||
#[test]
|
||||
fn figma_artwork_is_rendered_with_embedded_pictures() {
|
||||
use crate::exchange::ExportShape;
|
||||
use base64::Engine;
|
||||
let mut png = std::io::Cursor::new(Vec::new());
|
||||
image::RgbaImage::from_pixel(2, 2, image::Rgba([255, 0, 0, 255]))
|
||||
.write_to(&mut png, image::ImageFormat::Png)
|
||||
.unwrap();
|
||||
let shapes = [ExportShape {
|
||||
id: "red".into(),
|
||||
name: "Picture".into(),
|
||||
geometry: crate::Geometry {
|
||||
x: 0.,
|
||||
y: 0.,
|
||||
width: 200.,
|
||||
height: 100.,
|
||||
},
|
||||
image_png_base64: Some(
|
||||
base64::engine::general_purpose::STANDARD.encode(png.into_inner()),
|
||||
),
|
||||
background: false,
|
||||
}];
|
||||
for codec in [
|
||||
crate::interchange::Codec::Figma,
|
||||
crate::interchange::Codec::Figcraft,
|
||||
] {
|
||||
let bytes = crate::vendor_formats::export(codec, [200, 100], &shapes).unwrap();
|
||||
let doc = Document::open(bytes, &format!("art.{}", codec.extension()), false).unwrap();
|
||||
let image = image::load_from_memory(&doc.render(0, 200).unwrap())
|
||||
.unwrap()
|
||||
.into_rgba8();
|
||||
assert_eq!(image.get_pixel(50, 50).0, [255, 0, 0, 255]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -466,6 +466,80 @@ fn import_ai(bytes: &[u8]) -> Result<Vec<Page>, String> {
|
|||
Ok(pages)
|
||||
}
|
||||
|
||||
pub(crate) fn reference_ai(bytes: &[u8]) -> Result<Vec<(String, String)>, String> {
|
||||
let dir = tempfile::tempdir().map_err(|e| e.to_string())?;
|
||||
let input = dir.path().join("input.ai");
|
||||
std::fs::write(&input, bytes).map_err(|e| e.to_string())?;
|
||||
let mut command = std::process::Command::new(vectorcraft());
|
||||
command.arg("--safe-mode").arg("info").arg(&input);
|
||||
let info = run_vectorcraft(&mut command, dir.path())?;
|
||||
let boards = info
|
||||
.get("artboards")
|
||||
.and_then(|v| v.as_array())
|
||||
.ok_or("No Illustrator artboards")?;
|
||||
if boards.is_empty() || boards.len() > 64 {
|
||||
return Err("Illustrator supports 1–64 artboards.".into());
|
||||
}
|
||||
boards
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, board)| {
|
||||
let (svg, warnings) = convert_ai(bytes, "ai", "svg", Some(index))?;
|
||||
let label = format!(
|
||||
"Artboard {} · {} {}",
|
||||
index + 1,
|
||||
board
|
||||
.get("name")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("Unnamed"),
|
||||
warnings.join("; ")
|
||||
);
|
||||
Ok((label, String::from_utf8(svg).map_err(|e| e.to_string())?))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn reference_fig(
|
||||
bytes: &[u8],
|
||||
name: &str,
|
||||
native: bool,
|
||||
) -> Result<(Vec<(String, String)>, String), String> {
|
||||
use figcraft_doc::NodeKind;
|
||||
let (doc, warnings) = if native {
|
||||
figcraft_format::load_bytes(bytes)
|
||||
} else {
|
||||
figcraft_format::fig::import(bytes, name)
|
||||
}
|
||||
.map_err(|e| e.to_string())?;
|
||||
let mut pages = Vec::new();
|
||||
for id in &doc.pages {
|
||||
let Some(page) = doc.node(*id) else { continue };
|
||||
let mut loose = Vec::new();
|
||||
for id in &page.children {
|
||||
let Some(node) = doc.node(*id) else { continue };
|
||||
if matches!(node.kind, NodeKind::Frame | NodeKind::Component { .. }) {
|
||||
let svg = figcraft_svg::export_svg(&doc, &[*id], &Default::default())
|
||||
.ok_or("Cannot render Figma frame")?;
|
||||
pages.push((format!("{} / {}", page.name, node.name), svg));
|
||||
} else {
|
||||
loose.push(*id);
|
||||
}
|
||||
}
|
||||
if !loose.is_empty() {
|
||||
let svg = figcraft_svg::export_svg(&doc, &loose, &Default::default())
|
||||
.ok_or("Cannot render Figma page")?;
|
||||
pages.push((page.name.clone(), svg));
|
||||
}
|
||||
if pages.len() > 256 {
|
||||
return Err("Reference supports up to 256 pages/frames.".into());
|
||||
}
|
||||
}
|
||||
if pages.is_empty() {
|
||||
return Err("No visible Figma pages/frames.".into());
|
||||
}
|
||||
Ok((pages, warnings.join("; ")))
|
||||
}
|
||||
|
||||
fn convert_ai(
|
||||
bytes: &[u8],
|
||||
from: &str,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
%PDF-1.4
|
||||
1 0 obj
|
||||
<< /Type /Catalog /Pages 2 0 R >>
|
||||
endobj
|
||||
2 0 obj
|
||||
<< /Type /Pages /Kids [3 0 R 5 0 R] /Count 2 >>
|
||||
endobj
|
||||
3 0 obj
|
||||
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 100] /Resources << >> /Contents 4 0 R >>
|
||||
endobj
|
||||
4 0 obj
|
||||
<< /Length 25 >>
|
||||
stream
|
||||
1 0 0 rg 0 0 200 100 re f
|
||||
endstream
|
||||
endobj
|
||||
5 0 obj
|
||||
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 100] /CropBox [0 0 100 100] /Rotate 90 /Resources << >> /Contents 6 0 R >>
|
||||
endobj
|
||||
6 0 obj
|
||||
<< /Length 25 >>
|
||||
stream
|
||||
0 1 0 rg 0 0 200 100 re f
|
||||
endstream
|
||||
endobj
|
||||
xref
|
||||
0 7
|
||||
0000000000 65535 f
|
||||
0000000009 00000 n
|
||||
0000000058 00000 n
|
||||
0000000121 00000 n
|
||||
0000000225 00000 n
|
||||
0000000300 00000 n
|
||||
0000000438 00000 n
|
||||
trailer
|
||||
<< /Size 7 /Root 1 0 R >>
|
||||
startxref
|
||||
513
|
||||
%%EOF
|
||||
|
|
@ -4,6 +4,19 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### v0.9.46
|
||||
|
||||
- Added PDF/document reference import with page selection, resolution control and
|
||||
preview before adding. PDF/SVG and Figma artwork render locally; JSON/HTML retain
|
||||
embedded pictures. PPTX and draw.io artwork use optional local converters, AI
|
||||
uses VectorCraft, and all geometry formats offer labelled layout-box pictures.
|
||||
Rendered PNGs preserve proportions and reopen without the source/converter.
|
||||
PDF remains reference-only; complex rendering and external converters have the
|
||||
documented limits. Added page/crop/rotation, artwork, cancellation and save/load
|
||||
regression checks; checked the showcase PDFs and LibreOffice slide conversion.
|
||||
Required Rust checks and the manual build passed; whole-app coverage is 91.99%.
|
||||
External draw.io/VectorCraft rendering was not exercised (tools unavailable).
|
||||
|
||||
### v0.9.45
|
||||
|
||||
- Split bundled themes into video-game-themes (6, including Ravenswatch) and
|
||||
|
|
|
|||
|
|
@ -10,6 +10,51 @@ of a box) icons. They open the same import/export menus available from Menu;
|
|||
opening a menu does not read or write device values. Hover for the label, or
|
||||
turn on toolbar icon names in Options.
|
||||
|
||||
## PDF pages and documents as reference pictures
|
||||
|
||||
Choose **Add reference images** from the reference list or Import menu, then
|
||||
select a picture or supported document. For documents, choose **Artwork** or
|
||||
**Layout boxes**, select the page/slide/frame and resolution, inspect the preview,
|
||||
and click **Add reference**. Repeat to add another page. Closing the dialog
|
||||
leaves the document unchanged. PDF drops open this dialog directly; other exchange
|
||||
files normally open geometry review, unless the **Reference image** window is open.
|
||||
|
||||
| Source | Artwork reference |
|
||||
| --- | --- |
|
||||
| PDF | Built-in page rendering; no external application required |
|
||||
| SVG | Built-in rendering of artwork, text and embedded images |
|
||||
| PPTX | Slides converted locally by an installed LibreOffice |
|
||||
| draw.io / XML | Pages converted locally by an installed draw.io Desktop |
|
||||
| FIG / FIGCRAFT | Built-in FigCraft artwork rendering in the normal build; best effort for native FIG |
|
||||
| Illustrator | Artboards converted by the existing optional VectorCraft CLI |
|
||||
| Geometry JSON / Canvas Pilot HTML | Layout artwork including embedded PNG images; HTML uses the exchange data, not custom CSS/scripts |
|
||||
| CSV / DXF / DWG | Layout boxes from supported geometry, with labels; not a full CAD drawing renderer |
|
||||
|
||||
**Layout boxes** is available for every compiled geometry importer. It draws the
|
||||
detected rectangles and their labels, fitted to their bounds; it does not reproduce
|
||||
original artwork. This is useful when a converter is unavailable. For a faithful
|
||||
reference from an unsupported drawing feature, export PDF or SVG from its editor.
|
||||
|
||||
PDF pages render on a white background; SVG transparency is retained. References
|
||||
preserve proportions by default and contain the rendered PNG, so saving and reopening
|
||||
a project needs neither the source document nor its converter. These are static
|
||||
pictures, without editable text, automatic layer detection or playback.
|
||||
|
||||
The default longest edge is 1920 px; choose up to 4096 px for detailed artwork.
|
||||
Input files are limited to 64 MiB, PDFs to 256 pages, and the existing 32-reference /
|
||||
64 MiB combined image limits still apply. Render only the pages you need. Export an
|
||||
unlocked copy of password-protected PDFs. Inspect font substitutions and complex
|
||||
PDF effects in the preview; SVG external linked images are omitted.
|
||||
|
||||
For PPTX conversion, install LibreOffice and put `libreoffice` (`soffice.exe` on
|
||||
Windows) on PATH, or set `CANVAS_PILOT_LIBREOFFICE` to the executable. For draw.io,
|
||||
use `drawio` (`draw.io.exe` on Windows) or `CANVAS_PILOT_DRAWIO`. Executables beside
|
||||
Canvas Pilot or in its `bin/` folder are also found. On macOS, the executable may
|
||||
be inside the installed application's `Contents/MacOS/` directory. Conversion uses
|
||||
temporary copies and has a 60-second timeout; source files are never overwritten.
|
||||
These converters are optional and are not bundled. Draw.io Desktop may require a
|
||||
graphical desktop session. The existing VectorCraft setup is described below.
|
||||
|
||||
## Paste layer values and import geometry
|
||||
|
||||
Check the [clipboard feature matrix](format-matrix.md#clipboard-matrix) for your
|
||||
|
|
@ -18,7 +63,9 @@ application: its file and copy/paste workflows can support different features.
|
|||
Drop SVG, draw.io/XML, geometry JSON/CSV, DXF/DWG, HTML, PPTX, FIG, FIGCRAFT or Illustrator files into
|
||||
the window to open the same geometry review as **Import → Geometry file…**.
|
||||
Native codecs still require their normal build options/dependencies. Filename
|
||||
extensions are case-insensitive; PNG/JPEG/BMP drops remain reference images.
|
||||
extensions are case-insensitive; PNG/JPEG/BMP and PDF drops open as references.
|
||||
While the **Reference image** window is open, supported document drops also open
|
||||
as references instead of layer geometry.
|
||||
Multiple geometry files appear in the **File / page / frame / slide** chooser;
|
||||
choose one document/page to map at a time. Reading runs in the background, and
|
||||
nothing changes in the layout until Apply. The entire geometry drop is limited
|
||||
|
|
@ -111,7 +158,8 @@ SVG import accepts square-corner rectangles and simple closed rectangular
|
|||
paths/polygons, including translated/scaled groups and inline styles. It applies
|
||||
page dimensions and `viewBox` transforms, using CSS units at 96 px/in. Coordinates
|
||||
are relative to the SVG page; exporting only a selection may lose its original
|
||||
document position. The SVG is used for bounds, not rendered as a reference image.
|
||||
document position. This geometry-import action uses bounds. For the complete
|
||||
SVG artwork, use **Add reference images** instead.
|
||||
|
||||
A first full-page rectangle or image is marked as a possible background. Uncheck
|
||||
**Include full-page background** to exclude it from the count and mapping. This
|
||||
|
|
|
|||
|
|
@ -45,6 +45,15 @@ See the [advanced feature matrix](advanced-exchange.md) for every saved feature.
|
|||
|
||||
See also [conversion examples and losses](conversion-losses.md) before passing files through several editors.
|
||||
|
||||
## Document reference pictures
|
||||
|
||||
PDF pages and SVG artwork can be rendered directly as reference images. Other
|
||||
supported documents also have reference import, using built-in artwork rendering,
|
||||
optional local converters or an explicitly labelled layout-box preview.
|
||||
See the [reference-picture support table](files.md#pdf-pages-and-documents-as-reference-pictures)
|
||||
for each format's requirements and limits. This does not add PDF geometry export
|
||||
or recover editable layers from a PDF.
|
||||
|
||||
## File exchange matrix
|
||||
|
||||
All eleven exchange formats import and export layer positions and sizes. Geometry
|
||||
|
|
|
|||
|
|
@ -51,9 +51,34 @@ MIDRA_VECTORCRAFT_CLI=/path/to/vectorcraft-cli cargo test --locked -p canvas-pil
|
|||
| Illustrator, VectorCraft | Native Illustrator via VectorCraft CLI | Yes; artboard picker on import | Embedded PNG | Embedded PNG |
|
||||
|
||||
PSD, VSDX and ODG remain future adapters rather than implied support.
|
||||
PDF is a useful final visual but does not retain a
|
||||
reliable editable-rectangle contract for import, so it is not presented as a
|
||||
round-trip format.
|
||||
PDF supports reference-picture import through Hayro 0.9, with page selection;
|
||||
it is not a geometry round-trip format. SVG reference artwork uses resvg 0.50,
|
||||
FIG/FIGCRAFT uses figcraft-svg 0.5.1, PPTX uses optional LibreOffice-to-PDF,
|
||||
draw.io uses optional draw.io Desktop-to-PDF, and AI uses VectorCraft-to-SVG.
|
||||
JSON and HTML references render the validated exchange schema and embedded PNGs.
|
||||
CSV/DXF/DWG references draw the existing importer's supported boxes only. Every
|
||||
compiled geometry importer also offers an explicit layout-box rendering mode.
|
||||
See [reference import instructions](../canvas-pilot/guide/files.md#pdf-pages-and-documents-as-reference-pictures).
|
||||
|
||||
Reference conversion is asynchronous and does not apply geometry, read embedded
|
||||
project snapshots, change the save path or modify the source. The selected page is
|
||||
rasterized with preserved proportions to 64–4096 px on its longest edge (UI choices
|
||||
1280–4096, default 1920), then encoded to PNG. PDF uses a white page background;
|
||||
SVG retains alpha and disables external image resolution. PDF crop boxes and
|
||||
rotation are applied by Hayro. Input and converted files are bounded at 64 MiB;
|
||||
PDF accepts 1–256 pages, Illustrator 1–64 artboards. Geometry-only mode retains
|
||||
the exchange codec's 16 MiB limit. Page rendering is serialized, and only the chosen
|
||||
page is rasterized. These bounds do not impose a hard process-memory limit on
|
||||
compressed document contents or renderer internals. Cancel discards late results;
|
||||
it does not interrupt an in-process render already underway. External conversion
|
||||
has a 60-second process timeout and uses temporary files; LibreOffice gets a fresh
|
||||
isolated profile. Password-required PDFs report an error rather than prompting.
|
||||
|
||||
The project schema remains version 18: the existing reference `image_base64`
|
||||
contains the generated PNG, and its name includes the source filename and chosen
|
||||
page label. No document bytes, source paths, converter settings or live links are
|
||||
persisted. Reopening a project only decodes that PNG. Source editability, resolution
|
||||
independence, fonts and unused pages are intentionally absent from this snapshot.
|
||||
|
||||
## Scope, coordinates and artwork
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ Each reference object:
|
|||
| Field | Representation / meaning |
|
||||
| --- | --- |
|
||||
| `name` | Display filename, not a path to read |
|
||||
| `image_base64` | Standard padded RFC 4648 base64 of the original PNG/JPEG/BMP file bytes; no data-URL prefix |
|
||||
| `image_base64` | Standard padded RFC 4648 base64 of the PNG/JPEG/BMP file bytes (generated PNG for document references); no data-URL prefix |
|
||||
| `visible` | Boolean |
|
||||
| `opacity` | Number from 0 to 1 |
|
||||
| `preserve_ratio` | Boolean: fit proportionally if true, stretch to screen if false; applies when native sizing is off |
|
||||
|
|
@ -143,7 +143,10 @@ decoding run in a background worker. The editor is replaced only after every
|
|||
image succeeds; Cancel loading ignores late worker results. Recovery checkpoints
|
||||
pause during loading. Texture upload/presentation still depends on the GUI/GPU.
|
||||
Captured Midra stills use the same reference object and embedded PNG bytes, with
|
||||
no device request on reload; no schema/version change is required.
|
||||
no device request on reload; no schema/version change is required. PDF/document
|
||||
references also use embedded PNG bytes, with proportions preserved initially and
|
||||
a source/page label as their name; original documents and converter paths are not
|
||||
stored. See [document reference conversion](canvas-pilot-exchange.md#application-and-format-matrix).
|
||||
|
||||
Editor object:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue