Merge remote-tracking branch 'origin/main' into imo778-metafile-unit-facts

# Conflicts:
#	Cargo.lock
#	Cargo.toml
This commit is contained in:
FredApps committed 2026-11-23 08:38:58 +07:00
commit 53f5e552f8
13 files changed
+129 -1668

No files matched your search

Generated
+42 -43
View File
@@ -1001,7 +1001,7 @@ dependencies = [
[[package]]
name = "craft-affinity"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"crc32fast",
"flate2",
@@ -1012,7 +1012,7 @@ dependencies = [
[[package]]
name = "craft-cdr"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"crc32fast",
"flate2",
@@ -1021,7 +1021,7 @@ dependencies = [
[[package]]
name = "craft-cms"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"md-5",
"rayon",
@@ -1030,12 +1030,12 @@ dependencies = [
[[package]]
name = "craft-codepage"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
[[package]]
name = "craft-dds"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"rayon",
]
@@ -1043,12 +1043,12 @@ dependencies = [
[[package]]
name = "craft-docpath"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
[[package]]
name = "craft-dxf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"craft-codepage",
"encoding_rs",
@@ -1060,12 +1060,12 @@ dependencies = [
[[package]]
name = "craft-eps"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
[[package]]
name = "craft-font-catalog"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"harfrust 0.13.3",
"kurbo 0.13.1",
@@ -1079,12 +1079,12 @@ dependencies = [
[[package]]
name = "craft-fonts-build"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
[[package]]
name = "craft-gif"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"gif",
]
@@ -1092,7 +1092,7 @@ dependencies = [
[[package]]
name = "craft-gzip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"flate2",
]
@@ -1100,7 +1100,7 @@ dependencies = [
[[package]]
name = "craft-i18n"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"fixed_decimal",
"icu_decimal",
@@ -1123,7 +1123,7 @@ dependencies = [
[[package]]
name = "craft-image-codecs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"craft-dds",
"craft-jpeg",
@@ -1150,7 +1150,7 @@ dependencies = [
[[package]]
name = "craft-jpeg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"thiserror 2.0.21",
]
@@ -1158,7 +1158,7 @@ dependencies = [
[[package]]
name = "craft-jxl"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"brotli-decompressor 5.0.3",
"jixel",
@@ -1169,7 +1169,7 @@ dependencies = [
[[package]]
name = "craft-keymap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"egui",
"serde",
@@ -1179,7 +1179,7 @@ dependencies = [
[[package]]
name = "craft-metadata"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"brotli-decompressor 6.3.2",
"chrono",
@@ -1191,7 +1191,7 @@ dependencies = [
[[package]]
name = "craft-metafile"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"encoding_rs",
"image",
@@ -1202,7 +1202,7 @@ dependencies = [
[[package]]
name = "craft-mime"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"chrono",
"craft-codepage",
@@ -1212,7 +1212,7 @@ dependencies = [
[[package]]
name = "craft-pdf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"hayro-interpret",
"hayro-syntax",
@@ -1223,7 +1223,7 @@ dependencies = [
[[package]]
name = "craft-plotter"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"kurbo 0.13.1",
"thiserror 2.0.21",
@@ -1232,7 +1232,7 @@ dependencies = [
[[package]]
name = "craft-print"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"craft-winprint-gdi",
"log",
@@ -1246,7 +1246,7 @@ dependencies = [
[[package]]
name = "craft-proof"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"log",
"miniz_oxide 0.9.1",
@@ -1257,7 +1257,7 @@ dependencies = [
[[package]]
name = "craft-ps"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"craft-eps",
"flate2",
@@ -1271,7 +1271,7 @@ dependencies = [
[[package]]
name = "craft-psd"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"encoding_rs",
"flate2",
@@ -1282,7 +1282,7 @@ dependencies = [
[[package]]
name = "craft-stream-codecs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"fax",
"hayro-ccitt",
@@ -1293,7 +1293,7 @@ dependencies = [
[[package]]
name = "craft-svg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"craft-image-codecs",
"craft-xml",
@@ -1314,7 +1314,7 @@ dependencies = [
[[package]]
name = "craft-tiff"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -1324,7 +1324,7 @@ dependencies = [
[[package]]
name = "craft-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"craft-fonts-build",
"craft-i18n",
@@ -1345,7 +1345,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"chrono",
"dunce",
@@ -1372,7 +1372,7 @@ dependencies = [
[[package]]
name = "craft-vectorcraft-format"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"flate2",
"serde",
@@ -1383,7 +1383,7 @@ dependencies = [
[[package]]
name = "craft-web-api"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"js-sys",
"serde_json",
@@ -1394,7 +1394,7 @@ dependencies = [
[[package]]
name = "craft-window"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"egui",
"objc2 0.6.5",
@@ -1413,7 +1413,7 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"quick-xml 0.41.0",
"serde",
@@ -2520,7 +2520,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
[[package]]
name = "hayro-cmap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"brotli",
"hayro-postscript",
@@ -2529,7 +2529,7 @@ dependencies = [
[[package]]
name = "hayro-interpret"
version = "0.7.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"bitflags 2.13.2",
"hayro-cmap",
@@ -2547,7 +2547,7 @@ dependencies = [
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"fearless_simd",
"hayro-ccitt",
@@ -2565,12 +2565,12 @@ dependencies = [
[[package]]
name = "hayro-postscript"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"flate2",
"hayro-ccitt",
@@ -3370,7 +3370,7 @@ dependencies = [
[[package]]
name = "krilla"
version = "0.8.2"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"base64 0.22.1",
"bumpalo",
@@ -3479,7 +3479,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
[[package]]
name = "linesweeper"
version = "0.5.0"
source = "git+https://github.com/storytold/craft-libs?rev=33be35625e252cc4f06aa375b3b428521faea37d#33be35625e252cc4f06aa375b3b428521faea37d"
source = "git+https://github.com/storytold/craft-libs?rev=8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81#8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81"
dependencies = [
"arrayvec",
"kurbo 0.13.1",
@@ -6974,7 +6974,6 @@ dependencies = [
name = "vectorcraft-metafile"
version = "0.24.1"
dependencies = [
"craft-codepage",
"craft-image-codecs",
"craft-metafile",
"image",
+35 -35
View File
@@ -11,44 +11,44 @@ rust-version = "1.95"
repository = "https://github.com/storytold/vectorcraft"
[workspace.dependencies]
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d", default-features = false, features = ["interpret", "write"] }
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d", features = ["serde"] }
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81", default-features = false, features = ["interpret", "write"] }
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81", features = ["serde"] }
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
# Decides who draws the window frame (desktop vs. app) so the suite shares one native titlebar per
# desktop. The `egui` feature adds `craft_window::decorate`. (craft-libs#217.)
craft-window = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d", features = ["egui"] }
craft-window = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81", features = ["egui"] }
# The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON.
craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
# craft-update: app-specific pretend versions apply to startup and manual checks.
# Native Affinity documents (craft-libs#914).
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
# Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778).
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
# SVG parsing, limits, SVGZ and writer (craft-libs#778).
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d", features = ["tree"] }
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81", features = ["tree"] }
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
# EPS container, previews, ASCII85 and DSC comments (craft-libs#778).
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
# DXF tags, reader and writer (craft-libs#778, #926, #927).
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
# WMF, EMF and EMF+ reader (craft-libs#778).
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d", default-features = false, features = ["read", "write"] }
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "33be35625e252cc4f06aa375b3b428521faea37d", features = ["egui"] }
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81", default-features = false, features = ["read", "write"] }
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81", features = ["egui"] }
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
# internal
vectorcraft-geom = { path = "crates/geom" }
vectorcraft-color = { path = "crates/color" }
@@ -191,13 +191,13 @@ lto = "thin"
codegen-units = 1
[patch.crates-io]
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
krilla = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
krilla = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81" }
ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
emath = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
epaint = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+1 -1
View File
@@ -17,7 +17,7 @@ path = "src/main.rs"
vectorcraft-engine = { workspace = true, features = ["bundled-fonts", "heif"] }
vectorcraft-ui-egui = { workspace = true }
# The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft.
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d", version = "0.1.0" }
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81", version = "0.1.0" }
vectorcraft-format = { workspace = true }
vectorcraft-text = { workspace = true }
egui = { workspace = true }
+2 -3
View File
@@ -140,9 +140,8 @@ pub fn detect(name: &str, bytes: &[u8]) -> Option<&'static Format> {
if let Some(f) = craft_image_codecs::detect(bytes).and_then(image_format) {
return Some(f);
}
// A version 2 PICT is known by its version opcodes after the picture's frame, at byte 522 of a
// file or byte 10 of a bare picture (version 1 by its file's name), so a format whose
// signature starts the file is checked first.
// A PICT is known by its version opcodes after the picture's frame, at byte 522 of a file or
// byte 10 of a bare picture, so a format whose signature starts the file is checked first.
if vectorcraft_metafile::is_pict(bytes) {
return format("pict");
}
+1 -2
View File
@@ -3,13 +3,12 @@ name = "vectorcraft-metafile"
version.workspace = true
edition.workspace = true
license.workspace = true
description = "VectorCraft metafiles: EMF and WMF export and EMF, EMF+ and WMF import through craft-metafile, and a QuickDraw picture (PICT) reader"
description = "VectorCraft metafiles: EMF and WMF export and EMF, EMF+, WMF and QuickDraw PICT import through craft-metafile"
[lints]
workspace = true
[dependencies]
craft-codepage = { workspace = true }
vectorcraft-geom = { workspace = true }
vectorcraft-color = { workspace = true }
vectorcraft-doc = { workspace = true }
+1 -26
View File
@@ -1,4 +1,4 @@
//! App bitmap sizing, read budgets, and raster conversion for imported pictures.
//! App bitmap sizing and raster conversion for imported pictures.
use craft_metafile::write::Image;
use vectorcraft_doc::resample::{Resample, resized};
@@ -7,14 +7,6 @@ use vectorcraft_doc::resample::{Resample, resized};
const MAX_SIDE: u32 = 8192;
/// Most pixels an image the writers store holds.
const MAX_PIXELS: u64 = 1 << 24;
/// Most pixels along a side, and in all, of a bitmap the PICT reader decodes.
pub(crate) const MAX_READ_SIDE: u32 = 1 << 15;
pub(crate) const MAX_READ_PIXELS: u64 = 1 << 26;
/// Most pixels the bitmaps of one file may decode to together (four of the largest one), so a small
/// file of many image records can't cost minutes of decoding (#3600).
pub(crate) const MAX_FILE_PIXELS: u64 = 1 << 28;
/// What [`charge`] says of a bitmap past what is left of the file's budget.
pub(crate) const OVER_BUDGET: &str = "the bitmaps hold more pixels than one file may";
/// Pixels with straight (not premultiplied) alpha, row by row from the top.
#[derive(Clone, Debug, PartialEq)]
@@ -51,13 +43,6 @@ impl Rgba {
}
}
/// Take a bitmap of `w` × `h` from what is `left` of the file's budget, before it is decoded.
pub(crate) fn charge(w: u32, h: u32, left: &mut u64) -> Result<(), String> {
let n = u64::from(w) * u64::from(h);
*left = left.checked_sub(n).ok_or(OVER_BUDGET)?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
@@ -68,16 +53,6 @@ mod tests {
Image { width: 3, height: 2, rgba: pixels }
}
#[test]
fn bitmaps_share_the_file_budget() {
// #3600: each bitmap is charged before it is decoded, and one past what is left is refused.
let mut left = 6 + 5;
assert!(charge(3, 2, &mut left).is_ok());
assert_eq!(left, 5);
assert_eq!(charge(3, 2, &mut left).unwrap_err(), OVER_BUDGET);
assert_eq!(left, 5, "a refused bitmap costs nothing");
}
#[test]
fn rgb24_is_bottom_up_bgr_over_white() {
// WMF's shared writer emits a StretchDIB record: 28 bytes of parameters and
+14 -380
View File
@@ -1,27 +1,14 @@
//! The metafile readers. EMF (with its EMF+ records) and WMF files are read by `craft_metafile`,
//! and `picture` turns what they draw into document objects. QuickDraw pictures (`pict`) play their
//! opcodes on a [`Player`], a small model of the drawing state (pen, brush, font, the clip), which
//! turns what they draw into document objects.
//! The metafile readers. EMF (with its EMF+ records) and WMF files, and QuickDraw pictures (PICT),
//! are read by `craft_metafile`, and `picture` turns what they draw into document objects.
//!
//! Fills and strokes become paths with a fill and a stroke; lines drawn one after another with the
//! same pen join into one path. Clips become clipping groups around what they clip. Images keep
//! their pixels (as PNG), text becomes point type in the font the file names.
pub(crate) mod pict;
mod picture;
use std::sync::Arc;
use vectorcraft_color::{Color, Paint};
use vectorcraft_doc::clipnest::{Clip, Drawn, MAX_NEST, deep_clips, nest};
use vectorcraft_doc::{
Appearance, AppearanceItem, CharStyle, Dash, Document, FillLayer, ImageBlob, ImageObject, Justify, LayerColor, LineCap, LineJoin, Node, NodeKind,
StrokeLayer, TextObject,
};
use vectorcraft_geom::{Affine, BezPath, FillRule, PathData, PathEl, Point, Rect, Shape, shapes};
use crate::dib::{self, Rgba};
use crate::{Imported, Kind};
use vectorcraft_geom::{BezPath, PathEl, Point, Rect, Shape};
/// Most objects an import makes (a hostile file can't exhaust memory with them).
const MAX_NODES: usize = 1 << 20;
@@ -31,12 +18,7 @@ const LIMIT: f64 = 1e6;
/// Width of a cosmetic pen (one pixel of a 96 ppi screen), points.
const HAIRLINE: f64 = 0.75;
/// Raster operations.
pub(crate) const SRCCOPY: u32 = 0x00CC_0020;
const SKIPPED_ROPS: &str = "images drawn with raster operations other than a plain copy (masks, inversions) were left out";
const BAD_IMAGE: &str = "an image that couldn't be read was left out";
const TOO_MANY_PIXELS: &str = "images past the most pixels one file may hold were left out";
const FAR_AWAY: &str = "objects far outside the picture were left out";
/// Is `r` finite and within [`LIMIT`]?
@@ -65,8 +47,8 @@ fn around(path: &BezPath, frame: Rect) -> bool {
let (p, start) = match e {
PathEl::MoveTo(p) => (*p, true),
PathEl::LineTo(p) => (*p, false),
PathEl::ClosePath => continue,
PathEl::QuadTo(..) | PathEl::CurveTo(..) => return false,
PathEl::ClosePath => break,
_ => return false,
};
let Some(i) = corners.iter().position(|c| near(*c, p)) else { return false };
if start {
@@ -96,365 +78,17 @@ fn around(path: &BezPath, frame: Rect) -> bool {
seen.iter().all(|s| *s) && b.contains(frame.origin()) && b.contains(Point::new(frame.x1, frame.y1))
}
/// A pen: its style flags (`PS_*`), width in logical units, colour and dash entries.
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct PenObj {
pub style: u32,
pub width: f64,
pub color: [u8; 3],
/// PS_USERSTYLE entries, logical units.
pub entries: Vec<f64>,
}
impl PenObj {
pub fn solid(color: [u8; 3]) -> Self {
Self { style: 0, width: 0.0, color, entries: vec![] }
}
}
pub(crate) const PS_NULL: u32 = 5;
const PS_GEOMETRIC: u32 = 0x0001_0000;
/// A font: its height in logical units (negative: the character height, positive: the cell
/// height), escapement (tenths of a degree), weight, italics and face.
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct FontObj {
pub height: f64,
pub escapement: f64,
pub weight: i32,
pub italic: bool,
pub face: String,
}
/// The drawing state.
#[derive(Clone, Debug)]
struct Dc {
pen: PenObj,
/// The brush's color.
brush: [u8; 3],
font: FontObj,
text_color: [u8; 3],
text_align: u32,
fill_rule: FillRule,
miter: f64,
clips: Vec<Arc<Clip>>,
}
impl Default for Dc {
fn default() -> Self {
Self {
pen: PenObj::solid([0; 3]),
brush: [255; 3],
font: FontObj::default(),
text_color: [0; 3],
text_align: 0,
fill_rule: FillRule::EvenOdd,
miter: 10.0,
clips: vec![],
}
}
}
pub(crate) struct Player {
kind: Kind,
/// Picture units → document points.
dev_to_doc: Affine,
dc: Dc,
/// The artboard (document space): clips holding all of it clip nothing worth keeping.
frame: Rect,
/// Lines drawn one after another, not drawn yet.
pending: BezPath,
out: Drawn,
doc: Document,
warnings: Vec<String>,
next_clip: u32,
/// Pixels the file's bitmaps may still decode to ([`dib::MAX_FILE_PIXELS`]).
pub pixels_left: u64,
}
fn rgb(c: [u8; 3]) -> Paint {
Paint::solid(Color::rgb8(c[0], c[1], c[2]))
}
/// A rectangle with elliptical corners `rx` × `ry`.
pub(crate) fn round_rect(r: Rect, rx: f64, ry: f64) -> BezPath {
let r = r.abs();
let (rx, ry) = ((rx / 2.0).abs().min(r.width() / 2.0), (ry / 2.0).abs().min(r.height() / 2.0));
if rx <= 0.0 || ry <= 0.0 {
return shapes::rectangle(r).to_bezpath();
}
// A rectangle with round corners of radius `ry`, squeezed across.
let s = ry / rx;
let squeezed = Rect::new(r.x0 * s, r.y0, r.x1 * s, r.y1);
let mut bp = shapes::rounded_rectangle(squeezed, ry).to_bezpath();
bp.apply_affine(Affine::scale_non_uniform(1.0 / s, 1.0));
bp
}
impl Player {
fn new(kind: Kind, dev_to_doc: Affine, artboard: Rect) -> Self {
let side = |v: f64| if v.is_finite() { v.clamp(1.0, LIMIT) } else { 1.0 };
let (w, h) = (side(artboard.width()), side(artboard.height()));
let mut doc = Document::new(w, h);
doc.layers.clear();
Self {
kind,
dev_to_doc,
dc: Dc::default(),
frame: artboard,
pending: BezPath::new(),
out: vec![],
doc,
warnings: vec![],
next_clip: 0,
pixels_left: dib::MAX_FILE_PIXELS,
}
}
pub fn warn(&mut self, w: &str) {
if !self.warnings.iter().any(|x| x == w) {
self.warnings.push(w.to_string());
}
}
// ---------- mapping ----------
/// Picture units → document.
fn xf(&self) -> Affine {
self.dev_to_doc
}
/// How much picture lengths grow in the document.
fn scale(&self) -> f64 {
let s = self.xf().determinant().abs().sqrt();
if s.is_finite() { s } else { 0.0 }
}
// ---------- output ----------
fn push(&mut self, mut node: Node) {
if self.out.len() >= MAX_NODES {
return;
}
if !node.visual_bounds().is_none_or(sane) {
return self.warn(FAR_AWAY);
}
node.id = self.doc.alloc_id();
self.out.push((self.dc.clips.clone(), node));
}
fn fill_paint(&self) -> Paint {
rgb(self.dc.brush)
}
fn stroke_layer(&self) -> Option<StrokeLayer> {
let p = &self.dc.pen;
let kind = p.style & 0xf;
if kind == PS_NULL {
return None;
}
// Geometric pens, and other pens wider than 1, have a width in logical units; the others
// are one pixel wide.
let w = p.width * self.scale();
let width = if w > 0.0 && w.is_finite() && (p.style & PS_GEOMETRIC != 0 || p.width > 1.0) { w } else { HAIRLINE };
let mut st = StrokeLayer::new(rgb(p.color), width);
// Round caps and joins unless the style asks for others.
st.cap = match p.style & 0xf00 {
0x100 => LineCap::Square,
0x200 => LineCap::Butt,
_ => LineCap::Round,
};
st.join = match p.style & 0xf000 {
0x1000 => LineJoin::Bevel,
0x2000 => LineJoin::Miter,
_ => LineJoin::Round,
};
st.miter_limit = self.dc.miter;
let unit = width.max(HAIRLINE);
let pattern: Vec<f64> = match kind {
1 => vec![3.0 * unit, unit],
2 => vec![unit, unit],
3 => vec![3.0 * unit, unit, unit, unit],
4 => vec![3.0 * unit, unit, unit, unit, unit, unit],
7 => p.entries.iter().map(|e| e * self.scale()).collect(),
_ => vec![],
};
let dash = Dash { pattern, offset: 0.0, align_corners: false };
st.dash = dash.is_dashed().then_some(dash);
Some(st)
}
/// Paint `bp` (document space) with the brush and the pen.
fn draw(&mut self, bp: BezPath, fill: bool, stroke: bool) {
if bp.elements().is_empty() {
return;
}
let mut items = vec![];
if fill {
items.push(AppearanceItem::Fill(FillLayer::new(self.fill_paint())));
}
if stroke && let Some(st) = self.stroke_layer() {
items.push(AppearanceItem::Stroke(st));
}
if items.is_empty() {
return;
}
let mut n = Node::path(vectorcraft_doc::NodeId(0), PathData::from_bezpath(&bp), Appearance { items, ..Appearance::default() });
if let NodeKind::Path { rule, .. } = &mut n.kind {
*rule = self.dc.fill_rule;
}
self.push(n);
}
/// Draw the lines drawn one after another so far.
pub fn flush(&mut self) {
if !self.pending.elements().is_empty() {
let bp = std::mem::take(&mut self.pending);
self.draw(bp, false, true);
}
}
// ---------- clips ----------
fn push_clip(&mut self, path: BezPath, rule: FillRule, replace: bool) {
if replace {
self.dc.clips.clear();
}
if !sane(path.bounding_box()) {
return self.warn(FAR_AWAY);
}
if around(&path, self.frame) {
return;
}
if self.dc.clips.len() >= MAX_NEST {
return self.warn(&deep_clips());
}
self.next_clip += 1;
self.dc.clips.push(Arc::new(Clip { id: self.next_clip, region: Some((path, rule)) }));
}
// ---------- images and text ----------
/// An image whose source rectangle `src` (pixels, from the top-left) is drawn into `dest`
/// (picture units: origin and signed size) with raster operation `rop`, at `opacity`.
pub fn image(&mut self, img: Result<Rgba, String>, src: Rect, dest: Rect, rop: u32, opacity: f64) {
if rop != SRCCOPY {
self.warn(SKIPPED_ROPS);
return;
}
let img = match img {
Ok(i) => i,
Err(e) if e == dib::OVER_BUDGET => return self.warn(TOO_MANY_PIXELS),
Err(_) => return self.warn(BAD_IMAGE),
};
let img = crop(img, src);
if img.width == 0 || img.height == 0 {
return;
}
let (w, h) = (f64::from(img.width), f64::from(img.height));
self.image_xf(img, Affine::translate((dest.x0, dest.y0)) * Affine::scale_non_uniform(dest.width() / w, dest.height() / h), opacity);
}
/// An image placed by `xf` (its pixels, from the top-left, → picture units), at `opacity`. An
/// image that `xf` flattens or sends past finite numbers is left out, and adds nothing to the
/// document's images.
pub(crate) fn image_xf(&mut self, img: Rgba, xf: Affine, opacity: f64) {
if img.width == 0 || img.height == 0 {
return;
}
let xf = self.xf() * xf;
if !xf.as_coeffs().iter().all(|v| v.is_finite()) || xf.determinant().abs() < 1e-12 {
return;
}
let Ok(png) = img.to_png() else { return self.warn(BAD_IMAGE) };
let blob = ImageBlob::new("image/png", png);
let key = blob.content_key();
self.doc.images.entry(key.clone()).or_insert(blob);
let im = ImageObject { key, width: img.width, height: img.height, xf, link: None, placement: Default::default(), pixels: None };
let mut n = Node::new(vectorcraft_doc::NodeId(0), NodeKind::Image(Box::new(im)));
n.opacity = opacity.clamp(0.0, 1.0) as f32;
self.push(n);
}
/// Text at `at` (picture units) in the current font.
pub fn text(&mut self, at: Point, s: &str) {
let s: String = s.chars().filter(|c| *c != '\0').collect();
if s.trim().is_empty() {
return;
}
let align = self.dc.text_align;
let f = self.dc.font.clone();
let k = self.scale();
// A negative height is the em; a positive one the cell (the em and the internal leading).
let em = if f.height < 0.0 { -f.height } else { f.height * 0.85 };
let size = if em > 0.0 && (em * k).is_finite() { (em * k).clamp(0.5, 5000.0) } else { 12.0 };
let mut style = CharStyle { size, fill: rgb(self.dc.text_color), stroke: Paint::None, ..CharStyle::default() };
if !f.face.trim().is_empty() {
style.font_family = f.face.trim().to_string();
}
style.font_style = match (f.weight >= 600, f.italic) {
(true, true) => "Bold Italic",
(true, false) => "Bold",
(false, true) => "Italic",
(false, false) => "Regular",
}
.into();
let angle = -(f.escapement / 10.0).to_radians();
let angle = if angle.is_finite() { angle } else { 0.0 };
// TA_BASELINE, TA_BOTTOM or TA_TOP (the default): where the baseline is.
let drop = match align & 0x18 {
0x18 => 0.0,
0x08 => -0.2 * size,
_ => 0.8 * size,
};
let origin = self.xf() * at;
let mut t = TextObject::point(Point::ZERO, &s, style);
t.xf = Affine::translate(origin.to_vec2()) * Affine::rotate(angle) * Affine::translate((0.0, drop));
t.para.justify = match align & 0x06 {
0x06 => Justify::Center,
0x02 => Justify::Right,
_ => Justify::Left,
};
t.cached_bounds = Some(vectorcraft_text::layout(vectorcraft_text::FontDb::global(), &t).bounds);
self.push(Node::new(vectorcraft_doc::NodeId(0), NodeKind::Text(Box::new(t))));
}
// ---------- the document ----------
/// The document: what was drawn on one layer, clipped art in clipping groups.
fn finish(mut self) -> Imported {
self.flush();
let out = std::mem::take(&mut self.out);
let children = nest(&mut self.doc, out);
let mut layer = Node::layer(self.doc.alloc_id(), "Layer 1", LayerColor::Preset(0));
if let Some(c) = layer.children_mut() {
*c = children;
}
self.doc.layers = vec![Arc::new(layer)];
Imported { document: self.doc, kind: self.kind, warnings: self.warnings }
}
}
/// `img` cut to `src` (pixels from the top-left, within the image).
fn crop(img: Rgba, src: Rect) -> Rgba {
let (w, h) = (img.width, img.height);
let s = src.abs();
let clamp = |v: f64, max: u32| if v.is_finite() { v.round().clamp(0.0, f64::from(max)) as u32 } else { 0 };
let (x0, y0, x1, y1) = (clamp(s.x0, w), clamp(s.y0, h), clamp(s.x1, w), clamp(s.y1, h));
if (x0, y0, x1, y1) == (0, 0, w, h) || x1 <= x0 || y1 <= y0 {
return img;
}
let mut pixels = Vec::with_capacity(((x1 - x0) * (y1 - y0) * 4) as usize);
for y in y0..y1 {
let row = (y * w) as usize * 4;
if let Some(p) = img.pixels.get(row + x0 as usize * 4..row + x1 as usize * 4) {
pixels.extend_from_slice(p);
}
}
Rgba { width: x1 - x0, height: y1 - y0, pixels }
}
/// Read an EMF or WMF file.
pub(crate) fn import(bytes: &[u8]) -> Result<Imported, String> {
picture::import(bytes)
pub(crate) use picture::import;
/// Read a QuickDraw picture (PICT, versions 1 and 2) through `craft_metafile`.
pub(crate) fn import_pict(bytes: &[u8]) -> Result<crate::Picture, String> {
let pic = craft_metafile::parse_pict(bytes).map_err(|e| match e {
craft_metafile::Error::NotPict => "not a PICT file".to_string(),
_ => "the PICT file is damaged".to_string(),
})?;
Ok(picture::convert(pic))
}
File diff suppressed because it is too large. Load diff
+21 -2
View File
@@ -50,6 +50,7 @@ const PATTERNS: &str = "hatched and pattern brushes are filled with their averag
const ENDS_EARLY: &str = "the file ends early: what it held was imported";
const TOO_MANY: &str = "objects past the most one file may hold were left out";
const AT_LIMIT: &str = "the file or a picture inside it reached a limit on what one file may hold: what came after the limit was not read";
const PICT_TRUNCATED: &str = "the picture is cut short or reached a limit on what one file may hold: what came after was not read";
/// Points a unit of a WMF without a placeable header (1440 units an inch).
const WMF_UNIT: f64 = 72.0 / 1440.0;
@@ -168,7 +169,7 @@ fn average(rgba: &[u8]) -> Option<[u8; 4]> {
}
let a = sum[3];
let alpha = (a / pixels.len().max(1) as u64) as u8;
(a > 0).then(|| [(sum[0] / a) as u8, (sum[1] / a) as u8, (sum[2] / a) as u8, alpha.max(1)])
(a > 0).then(|| [((sum[0] + a / 2) / a) as u8, ((sum[1] + a / 2) / a) as u8, ((sum[2] + a / 2) / a) as u8, alpha.max(1)])
}
impl Mapper {
@@ -1062,7 +1063,7 @@ fn retracked(t: &TextObject, laid: &vectorcraft_text::TextLayout, dx: &[f64]) ->
pub(crate) fn import(bytes: &[u8]) -> Result<Imported, String> {
let kind = crate::sniff(bytes).ok_or("not an EMF or WMF file")?;
let pic = craft_metafile::parse(bytes).map_err(|e| match e {
craft_metafile::Error::NotMetafile => "not an EMF or WMF file".to_string(),
craft_metafile::Error::NotMetafile | craft_metafile::Error::NotPict => "not an EMF or WMF file".to_string(),
craft_metafile::Error::BadHeader => format!("the {} header is damaged", kind.id().to_uppercase()),
craft_metafile::Error::NoRecords => format!("the {} file holds no records", kind.id().to_uppercase()),
})?;
@@ -1084,3 +1085,21 @@ pub(crate) fn import(bytes: &[u8]) -> Result<Imported, String> {
}
Ok(m.finish(kind, lost))
}
/// Turn a metafile picture into a document.
pub(crate) fn convert(pic: craft_metafile::Picture) -> crate::Picture {
let mut m = Mapper::new(f64::from(pic.width), f64::from(pic.height), (1.0, 1.0));
if pic.truncated {
m.warn(PICT_TRUNCATED);
}
let lost = Lost { skipped: pic.skipped_records, images: pic.dropped_images, clips: pic.ignored_clips, rops: pic.unplayed_raster_ops };
for item in pic.items {
m.item(item);
}
let imported = m.finish(Kind::Wmf, lost);
let mut p = crate::Picture { document: imported.document, warnings: imported.warnings };
if p.document.layers.iter().all(|l| l.children().is_none_or(|c| c.is_empty())) {
p.warnings.push("the picture draws nothing VectorCraft reads".to_string());
}
p
}
+4 -5
View File
@@ -136,17 +136,16 @@ pub struct Picture {
pub warnings: Vec<String>,
}
/// Do `bytes` hold a version 2 QuickDraw picture, after a PICT file's 512 bytes of application
/// data or on their own? A version 1 picture is known by its file's name.
/// Do `bytes` hold a QuickDraw picture (version 1 or 2), after a PICT file's 512 bytes of
/// application data or on their own?
pub fn is_pict(bytes: &[u8]) -> bool {
import::pict::is_pict(bytes)
craft_metafile::is_pict(bytes)
}
/// Read a QuickDraw picture (version 1 or 2; a PICT file, or a picture on its own) into a document
/// whose one artboard is the picture's frame.
pub fn import_pict(bytes: &[u8]) -> Result<Picture, String> {
let i = import::pict::play(bytes)?;
let mut p = Picture { document: i.document, warnings: i.warnings };
let mut p = import::import_pict(bytes)?;
p.document.limit_depth_noting(&mut p.warnings);
Ok(p)
}
+5 -5
View File
@@ -147,7 +147,7 @@ fn a_bare_picture_and_a_version_1_picture_open() {
v1.extend([0xA0, 0x00, 0x05, 0x50]);
v1.extend(rect(20, 20, 30, 30));
v1.push(0xFF);
assert!(!crate::is_pict(&v1));
assert!(crate::is_pict(&v1));
let p = import_pict(&v1).unwrap();
assert!(p.warnings.is_empty(), "{:?}", p.warnings);
assert_eq!(p.document.artboards[0].rect.size(), (60.0, 40.0).into());
@@ -231,7 +231,7 @@ fn patterns_fill_with_their_average_color() {
assert_eq!(fill_rgb(&v[0]), Some([128, 128, 128]));
// eraseRect with an RGB background pattern.
assert_eq!(fill_rgb(&v[1]), Some([0, 255, 0]));
assert!(p.warnings.iter().any(|w| w.contains("average of their colors")), "{:?}", p.warnings);
assert!(p.warnings.iter().any(|w| w.contains("their average color")), "{:?}", p.warnings);
}
#[test]
@@ -407,7 +407,7 @@ fn quicktime_jpeg_images_are_placed_by_their_matrix() {
let [r, g, b, _] = px.get_pixel(1, 1).0;
assert!(r > 240 && g < 16 && b < 16, "{r} {g} {b}");
assert!(near(n.geometric_bounds().unwrap(), Rect::new(10.0, 5.0, 18.0, 9.0), 1e-9));
assert!(p.warnings.iter().any(|w| w.contains("other than JPEG")), "{:?}", p.warnings);
assert!(p.warnings.iter().any(|w| w.contains("couldn't be read was left out")), "{:?}", p.warnings);
}
/// An image whose matrix flattens it is left out, and adds nothing to the document's images.
@@ -457,7 +457,7 @@ fn a_picture_that_never_ends_stops_at_the_opcode_limit() {
b.resize(b.len() + 2 * ((1 << 22) + 1), 0);
let p = import_pict(&b).unwrap();
assert_eq!(paths(&p.document).len(), 1);
assert!(p.warnings.iter().any(|w| w.contains("more opcodes")), "{:?}", p.warnings);
assert!(p.warnings.iter().any(|w| w.contains("limit on what one file may hold")), "{:?}", p.warnings);
}
/// Regions share one budget of inversion points per picture: past it, a region is left out.
@@ -470,7 +470,7 @@ fn regions_past_the_picture_budget_are_left_out() {
let body = [rect(0, 0, 1, 16_000), be(&words)].concat();
let region = [be(&[(body.len() + 2) as i16]), body].concat();
let p = import_pict(&v2([0, 0, 300, 300], &[(0x81, region.clone()), (0x81, region.clone()), (0x81, region)])).unwrap();
assert!(p.warnings.iter().any(|w| w.contains("regions larger")), "{:?}", p.warnings);
assert!(p.warnings.iter().any(|w| w.contains("skipped")), "{:?}", p.warnings);
let v = paths(&p.document);
assert_eq!(v.len(), 2);
let NodeKind::Path { path, .. } = &v[0].kind else { panic!("a path") };
+1 -1
View File
@@ -10,7 +10,7 @@ workspace = true
[dependencies]
# The shared font catalog from craft-libs main (it has the outline, bidi and caret helpers used here).
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "33be35625e252cc4f06aa375b3b428521faea37d", default-features = false }
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81", default-features = false }
vectorcraft-geom = { workspace = true }
vectorcraft-doc = { workspace = true }
kurbo = { workspace = true }
+2 -2
View File
@@ -5,8 +5,8 @@ use std::process::Command;
use serde_json::Value;
const REV: &str = "33be35625e252cc4f06aa375b3b428521faea37d";
const STREAM_REV: &str = "33be35625e252cc4f06aa375b3b428521faea37d";
const REV: &str = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81";
const STREAM_REV: &str = "8f6ad14b58ca2efee67aac5d0f5573bad6a5ca81";
const PACKAGES: &[(&str, &str, &str)] = &[
("craft-pdf", "0.1.0", REV),
("krilla", "0.8.2", REV),