diff --git a/Cargo.lock b/Cargo.lock
index 5bc7ce4ae2c..a85eea6a655 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1320,7 +1320,7 @@ dependencies = [
[[package]]
name = "craft-affinity"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"crc32fast",
"flate2",
@@ -1331,7 +1331,7 @@ dependencies = [
[[package]]
name = "craft-atomic"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"rustix 1.1.5",
]
@@ -1339,7 +1339,7 @@ dependencies = [
[[package]]
name = "craft-crw"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"thiserror 2.0.21",
]
@@ -1347,17 +1347,17 @@ dependencies = [
[[package]]
name = "craft-docpath"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
[[package]]
name = "craft-eps"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
[[package]]
name = "craft-file-formats"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"craft-eps",
"craft-idml",
@@ -1375,12 +1375,12 @@ dependencies = [
[[package]]
name = "craft-fonts-build"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
[[package]]
name = "craft-heif"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"heic-rs",
"rayon",
@@ -1389,7 +1389,7 @@ dependencies = [
[[package]]
name = "craft-i18n"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"fixed_decimal",
"icu_decimal",
@@ -1412,7 +1412,7 @@ dependencies = [
[[package]]
name = "craft-idml"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1422,7 +1422,7 @@ dependencies = [
[[package]]
name = "craft-image-codecs"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"craft-heif",
"craft-jpeg",
@@ -1445,7 +1445,7 @@ dependencies = [
[[package]]
name = "craft-jpeg"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"thiserror 2.0.21",
]
@@ -1453,7 +1453,7 @@ dependencies = [
[[package]]
name = "craft-kra"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1463,7 +1463,7 @@ dependencies = [
[[package]]
name = "craft-metadata"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"brotli-decompressor 6.3.1",
"chrono",
@@ -1475,7 +1475,7 @@ dependencies = [
[[package]]
name = "craft-ora"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1485,7 +1485,7 @@ dependencies = [
[[package]]
name = "craft-pcraft-bundle"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"blake3",
"craft-atomic",
@@ -1498,7 +1498,7 @@ dependencies = [
[[package]]
name = "craft-pcraft-format"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"serde",
"serde_json",
@@ -1508,20 +1508,21 @@ dependencies = [
[[package]]
name = "craft-pdf"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"bytemuck",
"flate2",
"hayro",
"hayro-interpret",
"hayro-syntax",
+ "roxmltree 0.21.2",
"thiserror 2.0.21",
]
[[package]]
name = "craft-pdn"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -1530,7 +1531,7 @@ dependencies = [
[[package]]
name = "craft-print"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"craft-winprint-gdi",
"log",
@@ -1544,7 +1545,7 @@ dependencies = [
[[package]]
name = "craft-psd"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"encoding_rs",
"flate2",
@@ -1555,7 +1556,7 @@ dependencies = [
[[package]]
name = "craft-raw"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"chrono",
"craft-crw",
@@ -1573,7 +1574,7 @@ dependencies = [
[[package]]
name = "craft-svg"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"craft-image-codecs",
"craft-xml",
@@ -1588,7 +1589,7 @@ dependencies = [
[[package]]
name = "craft-tiff"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -1597,7 +1598,7 @@ dependencies = [
[[package]]
name = "craft-ui"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"craft-fonts-build",
"craft-i18n",
@@ -1618,7 +1619,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"chrono",
"dunce",
@@ -1653,7 +1654,7 @@ dependencies = [
[[package]]
name = "craft-xcf"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -1662,7 +1663,7 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"quick-xml 0.41.0",
"thiserror 2.0.21",
@@ -1671,7 +1672,7 @@ dependencies = [
[[package]]
name = "craft-zip"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -3077,7 +3078,7 @@ dependencies = [
[[package]]
name = "hayro"
version = "0.7.1"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"bytemuck",
"hayro-interpret",
@@ -3107,7 +3108,7 @@ dependencies = [
[[package]]
name = "hayro-interpret"
version = "0.7.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"bitflags 2.13.2",
"hayro-cmap",
@@ -3125,7 +3126,7 @@ dependencies = [
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"fearless_simd",
"hayro-ccitt",
@@ -3149,7 +3150,7 @@ checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
-source = "git+https://github.com/storytold/craft-libs?rev=a07481b41#a07481b416e0709cb03884592f3e93b4c83d4fd3"
+source = "git+https://github.com/storytold/craft-libs?rev=f623bb317#f623bb317b359df74b7a035c1eb84be1fbf83b0a"
dependencies = [
"flate2",
"hayro-ccitt",
diff --git a/Cargo.toml b/Cargo.toml
index 63a6db2c9eb..4b1122f6c1f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
rust-version = "1.95"
[workspace.dependencies]
-craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41", features = ["serde"] }
+craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317", features = ["serde"] }
# internal
photocraft-geom = { path = "crates/geom" }
photocraft-color = { path = "crates/color" }
@@ -18,11 +18,11 @@ photocraft-cms = { path = "crates/cms" }
photocraft-raster = { path = "crates/raster" }
photocraft-doc = { path = "crates/doc" }
photocraft-ops = { path = "crates/ops" }
-photocraft-psd = { package = "craft-psd", git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "a07481b41", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] }
+photocraft-psd = { package = "craft-psd", git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "f623bb317", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] }
photocraft-raw = { path = "crates/raw" }
-photocraft-affinity = { package = "craft-affinity", git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
+photocraft-affinity = { package = "craft-affinity", git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
photocraft-compose = { path = "crates/compose" }
photocraft-gpu = { path = "crates/gpu" }
photocraft-paint = { path = "crates/paint" }
@@ -40,27 +40,27 @@ photocraft-tablet = { path = "crates/tablet" }
photocraft-ipp = { path = "crates/ipp" }
# external
-craft-print = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
+craft-print = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
# HEIC/HEIF: the shared decoder (replaces crates/heif; craft-libs#784).
-craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41", features = ["raster", "write-raster"] }
-craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41", features = ["tree-render", "tree-render-system-fonts"] }
-craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
+craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317", features = ["raster", "write-raster"] }
+craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317", features = ["tree-render", "tree-render-system-fonts"] }
+craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
# Interface translations: lookup, fallback, CLDR plurals and language names over the craft-i18n
# catalogs that `crates/ui-egui/build.rs` embeds from `CRAFT_I18N_DIR` (storytold/craft-i18n, at
# the commit in `craft-i18n.rev`). Already in the tree through craft-ui.
-craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
+craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
# craft-update: app-specific pretend versions apply to startup and manual checks.
-craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "a07481b41", features = ["egui"] }
+craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "f623bb317", features = ["egui"] }
thiserror = "2"
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"
@@ -220,7 +220,7 @@ egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "6d518fc7
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
# craft-pdf's vendored Hayro trees: consumers patch the same craft-libs revision (crates/pdf README).
-hayro = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
-hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "a07481b41" }
+hayro = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
+hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "f623bb317" }
diff --git a/crates/io/src/pdf.rs b/crates/io/src/pdf.rs
index f2ce34edb9a..4efa8a6545b 100644
--- a/crates/io/src/pdf.rs
+++ b/crates/io/src/pdf.rs
@@ -31,129 +31,8 @@ fn print_pdf_pages(
Ok(craft_pdf::write_raster::write_pages(pages, vectors, selection_font, xmp))
}
-/// `s` as XML character data.
-fn xml_text(s: &str) -> String {
- let mut o = String::with_capacity(s.len());
- for c in s.chars() {
- match c {
- '&' => o.push_str("&"),
- '<' => o.push_str("<"),
- '>' => o.push_str(">"),
- '"' => o.push_str("""),
- c => o.push(c),
- }
- }
- o
-}
-
-/// The RDF namespace every XMP packet's `rdf:RDF` element is in.
-const RDF_NS: &str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-
-/// Where a description joins an XMP packet's RDF element, found as XML rather than by its
-/// spelling, so the prefix the packet binds to RDF, whitespace in its end tag and markup in
-/// comments make no difference: the byte offset of the element's end tag (`closed` false), or of
-/// the `/>` of a self-closing element (`closed` true) together with its qualified name, so the
-/// caller can expand it. None when the packet does not parse or has no RDF element.
-fn rdf_insertion(xmp: &str) -> Option<(usize, Option<&str>)> {
- // roxmltree does not take a byte order mark ahead of the prolog; offsets below are into `xmp`.
- let bom = xmp.strip_prefix('\u{feff}').map_or(0, |_| '\u{feff}'.len_utf8());
- let body = xmp.get(bom..)?;
- let doc = crate::xml::parse(body, roxmltree::ParsingOptions::default()).ok()?;
- let rdf = doc.descendants().find(|n| n.is_element() && n.tag_name().namespace() == Some(RDF_NS) && n.tag_name().name() == "RDF")?;
- let range = rdf.range();
- let text = body.get(range.clone())?;
- if let Some(open) = text.strip_suffix("/>") {
- // ``: the qualified name follows the `<`, up to whitespace or the `/`.
- let name = open.get(1..)?;
- let end = name.find(|c: char| c.is_whitespace() || c == '/').unwrap_or(name.len());
- return Some((bom + range.end - 2, Some(name.get(..end)?)));
- }
- // The end tag is the last thing in the element's own range.
- Some((bom + range.start + text.rfind("")?, None))
-}
-
-/// The XMP namespace of the spot-plate description.
-pub const SPOT_PLATES_NS: &str = "http://ns.getartcraft.com/photocraft/spot-plates/1.0/";
-
-/// The XMP packet of a spot-plate PDF: the document's own packet (`doc_xmp`, if any) with one
-/// `rdf:Description` added under [`SPOT_PLATES_NS`] that lists the plates in painting order, so a
-/// converter can rebuild each spot channel with its real ink colour, which the Separation
-/// colour space's CMYK alternate cannot carry:
-///
-/// ```xml
-///
-///
-///
-///
-/// 0
-/// Underbase White
-/// 100.00
-/// 0.00
-/// 0.00
-/// #FFFFFF
-/// 100
-///
-///
-///
-///
-/// ```
-///
-/// An alpha-type channel of a Multichannel document lists as black with solidity 0. The plates
-/// are the document's, the same on every page of an artboard export.
-fn plates_xmp(doc_xmp: Option<&str>, plates: &[SpotPlate]) -> String {
- // The description binds `rdf` itself: the packet it joins may bind another prefix to RDF.
- let mut d = format!(" \n \n \n");
- // Two decimals, never "-0.00".
- let two = |v: f32| {
- let v = (v * 100.0).round() / 100.0;
- if v == 0.0 { 0.0 } else { v }
- };
- for (i, p) in plates.iter().enumerate() {
- let hex = p.srgb.map(|v| format!("{:02X}", (v.clamp(0.0, 1.0) * 255.0).round() as u8)).concat();
- d.push_str(&format!(
- " \n {i}\n {}\n {:.2}\n {:.2}\n {:.2}\n #{hex}\n {}\n \n",
- xml_text(&p.name),
- two(p.lab[0]),
- two(p.lab[1]),
- two(p.lab[2]),
- (p.solidity * 100.0).round() as u32
- ));
- }
- d.push_str(" \n \n \n");
- // Into the document's packet when it has one, inside its RDF element; else a packet of its
- // own. A packet that does not parse or has no RDF element has nowhere for the description to
- // go and is kept as it is rather than replaced; so is one whose insertion offset falls off a
- // char boundary, which the parser never yields but a document-supplied packet must not panic.
- if let Some(xmp) = doc_xmp {
- let Some((at, self_closing)) = rdf_insertion(xmp) else {
- return xmp.to_owned();
- };
- // A self-closing element's tail skips its `/>`.
- let tail_at = if self_closing.is_some() { at + 2 } else { at };
- let (Some(head), Some(tail)) = (xmp.get(..at), xmp.get(tail_at..)) else {
- return xmp.to_owned();
- };
- let mut out = String::with_capacity(xmp.len() + d.len() + 16);
- out.push_str(head);
- match self_closing {
- // `` becomes `` + the description + ``.
- Some(name) => {
- out.push_str(">\n");
- out.push_str(&d);
- out.push_str(" ");
- out.push_str(name);
- out.push('>');
- }
- None => out.push_str(&d),
- }
- out.push_str(tail);
- return out;
- }
- format!(
- "\n\n \n{d} \n\n"
- )
-}
+/// The namespace of the spot-plate description written by the shared PDF metadata encoder.
+pub const SPOT_PLATES_NS: &str = craft_pdf::write_raster::SPOT_PLATES_NAMESPACE;
/// The channels of `doc` that leave as plates, in channel order (the first prints first,
/// underneath): every channel of a Multichannel document, the spot channels of any other.
@@ -170,7 +49,7 @@ fn plate_channels(doc: &Document) -> impl Iterator- Vec {
let to8 = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8;
plate_channels(doc)
@@ -291,7 +170,8 @@ pub fn export(doc: &Document, spot_plates: bool, ctl: &photocraft_raster::Interr
}
/// [`export`] with the XMP packet to embed (`doc_xmp`: the document's, or `None` when the save
-/// embeds no metadata). With spot plates the packet gains their description ([`plates_xmp`]);
+/// embeds no metadata). With spot plates the packet gains their description through the shared
+/// PDF writer;
/// without plates it is written as it is, and nothing when there is none.
pub fn export_with(doc: &Document, spot_plates: bool, doc_xmp: Option<&str>, ctl: &photocraft_raster::Interrupt) -> std::result::Result {
ctl.check().map_err(|_| IoError::Cancelled)?;
@@ -440,7 +320,7 @@ pub fn export_with(doc: &Document, spot_plates: bool, doc_xmp: Option<&str>, ctl
} else if doc.channels.iter().any(|ch| ch.spot.is_some()) {
warnings.push("spot channels were not written: spot plates were left out".into());
}
- let xmp = if plates.is_empty() { doc_xmp.map(str::to_owned) } else { Some(plates_xmp(doc_xmp, plates)) };
+ let xmp = craft_pdf::write_raster::xmp_with_spot_plates(doc_xmp, plates);
if !doc.metadata.text.is_empty() {
warnings.push("free-form text metadata is not supported by PDF; it will be dropped".into());
}