mirror of
https://github.com/typst/typst
synced 2025-07-27 22:37:54 +08:00
Merge 7ea0ed59acbd8cae7e995318cce02b6320d3c4a3 into 627f5b9d4f39f91affc529f276bb500d42887dae
This commit is contained in:
commit
049dd7b282
553
Cargo.lock
generated
553
Cargo.lock
generated
@ -17,6 +17,15 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aligned-vec"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b"
|
||||
dependencies = [
|
||||
"equator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
@ -82,6 +91,12 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.5.1"
|
||||
@ -100,6 +115,17 @@ dependencies = [
|
||||
"derive_arbitrary",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arg_enum_proc_macro"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.9"
|
||||
@ -124,6 +150,29 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "av1-grain"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f3efb2ca85bc610acfa917b5aaa36f3fcbebed5b3182d7f877b02531c4b80c8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arrayvec",
|
||||
"log",
|
||||
"nom",
|
||||
"num-rational",
|
||||
"v_frame",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "avif-serialize"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ea8ef51aced2b9191c08197f55450d830876d9933f8f48a429b354f1d496b42"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "az"
|
||||
version = "1.2.1"
|
||||
@ -173,6 +222,12 @@ version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@ -181,13 +236,19 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.8.0"
|
||||
version = "2.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitstream-io"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "1.0.1"
|
||||
@ -200,6 +261,12 @@ dependencies = [
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "built"
|
||||
version = "0.7.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.17.0"
|
||||
@ -214,9 +281,9 @@ checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.21.0"
|
||||
version = "1.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3"
|
||||
checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422"
|
||||
dependencies = [
|
||||
"bytemuck_derive",
|
||||
]
|
||||
@ -255,6 +322,16 @@ dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.15.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
@ -415,6 +492,15 @@ name = "codex"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/typst/codex?rev=9ac86f9#9ac86f96af5b89fce555e6bba8b6d1ac7b44ef00"
|
||||
|
||||
[[package]]
|
||||
name = "color"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ae467d04a8a8aea5d9a49018a6ade2e4221d92968e8ce55a48c0b1164e5f698"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color-print"
|
||||
version = "0.3.7"
|
||||
@ -687,6 +773,26 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equator"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc"
|
||||
dependencies = [
|
||||
"equator-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equator-macro"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
@ -703,6 +809,21 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
version = "1.73.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"half",
|
||||
"lebe",
|
||||
"miniz_oxide",
|
||||
"rayon-core",
|
||||
"smallvec",
|
||||
"zune-inflate",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.11.0"
|
||||
@ -793,6 +914,14 @@ dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "font-types"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/googlefonts/fontations?rev=b5c3030#b5c3030a19f2b7e7fe3fb7a0f38b01e63352aea9"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fontconfig-parser"
|
||||
version = "0.5.7"
|
||||
@ -964,6 +1093,68 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-font"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"phf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"hayro-font",
|
||||
"hayro-syntax",
|
||||
"kurbo",
|
||||
"log",
|
||||
"peniko",
|
||||
"phf",
|
||||
"qcms",
|
||||
"skrifa 0.32.0 (git+https://github.com/googlefonts/fontations?rev=b5c3030)",
|
||||
"smallvec",
|
||||
"yoke 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-render"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"hayro-interpret",
|
||||
"hayro-syntax",
|
||||
"image",
|
||||
"kurbo",
|
||||
"peniko",
|
||||
"rustc-hash",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"kurbo",
|
||||
"log",
|
||||
"rustc-hash",
|
||||
"smallvec",
|
||||
"zune-jpeg 0.5.0-rc5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hayro-write"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-syntax",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"pdf-writer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
@ -1206,19 +1397,25 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed"
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.5"
|
||||
version = "0.25.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b"
|
||||
checksum = "db35664ce6b9810857a38a906215e75a9c879f0696556a39f59c62829710251a"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder-lite",
|
||||
"color_quant",
|
||||
"exr",
|
||||
"gif",
|
||||
"image-webp",
|
||||
"num-traits",
|
||||
"png",
|
||||
"zune-core",
|
||||
"zune-jpeg",
|
||||
"qoi",
|
||||
"ravif",
|
||||
"rayon",
|
||||
"rgb",
|
||||
"tiff",
|
||||
"zune-core 0.4.12",
|
||||
"zune-jpeg 0.4.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1237,6 +1434,12 @@ version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285"
|
||||
|
||||
[[package]]
|
||||
name = "imgref"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.3"
|
||||
@ -1271,7 +1474,7 @@ version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"inotify-sys",
|
||||
"libc",
|
||||
]
|
||||
@ -1285,6 +1488,17 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "interpolate_name"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-docker"
|
||||
version = "0.2.0"
|
||||
@ -1310,6 +1524,15 @@ version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.14"
|
||||
@ -1325,6 +1548,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00810f1d8b74be64b13dbf3db89ac67740615d6c891f0e7b6179326533011a07"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.77"
|
||||
@ -1367,7 +1596,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "krilla"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/LaurenzV/krilla?rev=20c14fe#20c14fefee5002566b3d6668b338bbe2168784e7"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bumpalo",
|
||||
@ -1376,6 +1604,7 @@ dependencies = [
|
||||
"float-cmp 0.10.0",
|
||||
"fxhash",
|
||||
"gif",
|
||||
"hayro-write",
|
||||
"image-webp",
|
||||
"imagesize",
|
||||
"once_cell",
|
||||
@ -1384,18 +1613,18 @@ dependencies = [
|
||||
"rayon",
|
||||
"rustybuzz",
|
||||
"siphasher",
|
||||
"skrifa",
|
||||
"skrifa 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec",
|
||||
"subsetter",
|
||||
"tiny-skia-path",
|
||||
"xmp-writer",
|
||||
"yoke 0.8.0",
|
||||
"zune-jpeg",
|
||||
"zune-jpeg 0.4.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "krilla-svg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/LaurenzV/krilla?rev=20c14fe#20c14fefee5002566b3d6668b338bbe2168784e7"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"fontdb",
|
||||
@ -1408,14 +1637,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kurbo"
|
||||
version = "0.11.1"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89234b2cc610a7dd927ebde6b41dd1a5d4214cffaef4cf1fb2195d592f92518f"
|
||||
checksum = "1077d333efea6170d9ccb96d3c3026f300ca0773da4938cc4c811daa6df68b0c"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "lebe"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.169"
|
||||
@ -1462,7 +1703,7 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
]
|
||||
@ -1529,6 +1770,15 @@ version = "0.4.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
|
||||
|
||||
[[package]]
|
||||
name = "loop9"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062"
|
||||
dependencies = [
|
||||
"imgref",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lzma-sys"
|
||||
version = "0.1.20"
|
||||
@ -1540,6 +1790,16 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maybe-rayon"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
@ -1612,6 +1872,12 @@ dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "new_debug_unreachable"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
@ -1622,13 +1888,19 @@ dependencies = [
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "noop_proc_macro"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"filetime",
|
||||
"fsevent-sys",
|
||||
"inotify",
|
||||
@ -1663,6 +1935,17 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
@ -1672,6 +1955,17 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@ -1710,7 +2004,7 @@ version = "0.10.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"cfg-if",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
@ -1847,12 +2141,24 @@ version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ea27c5015ab81753fc61e49f8cde74999346605ee148bb20008ef3d3150e0dc"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peniko"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f9529efd019889b2a205193c14ffb6e2839b54ed9d2720674f10f4b04d87ac9"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"color",
|
||||
"kurbo",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
@ -1990,6 +2296,25 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "profiling"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773"
|
||||
dependencies = [
|
||||
"profiling-procmacros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "profiling-procmacros"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "psm"
|
||||
version = "0.1.24"
|
||||
@ -2005,7 +2330,7 @@ version = "0.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"getopts",
|
||||
"memchr",
|
||||
"unicase",
|
||||
@ -2017,6 +2342,15 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edecfcd5d755a5e5d98e24cf43113e7cdaec5a070edd0f6b250c03a573da30fa"
|
||||
|
||||
[[package]]
|
||||
name = "qoi"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "2.0.1"
|
||||
@ -2063,6 +2397,8 @@ version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
@ -2081,6 +2417,59 @@ name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom 0.2.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rav1e"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"arg_enum_proc_macro",
|
||||
"arrayvec",
|
||||
"av1-grain",
|
||||
"bitstream-io",
|
||||
"built",
|
||||
"cfg-if",
|
||||
"interpolate_name",
|
||||
"itertools",
|
||||
"libc",
|
||||
"libfuzzer-sys",
|
||||
"log",
|
||||
"maybe-rayon",
|
||||
"new_debug_unreachable",
|
||||
"noop_proc_macro",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"paste",
|
||||
"profiling",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"simd_helpers",
|
||||
"system-deps",
|
||||
"thiserror 1.0.69",
|
||||
"v_frame",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ravif"
|
||||
version = "0.11.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5825c26fddd16ab9f515930d49028a630efec172e903483c94796cfe31893e6b"
|
||||
dependencies = [
|
||||
"avif-serialize",
|
||||
"imgref",
|
||||
"loop9",
|
||||
"quick-error",
|
||||
"rav1e",
|
||||
"rayon",
|
||||
"rgb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
@ -2109,7 +2498,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "192735ef611aac958468e670cb98432c925426f3cb71521fda202130f7388d91"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"font-types",
|
||||
"font-types 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.30.1"
|
||||
source = "git+https://github.com/googlefonts/fontations?rev=b5c3030#b5c3030a19f2b7e7fe3fb7a0f38b01e63352aea9"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"font-types 0.9.0 (git+https://github.com/googlefonts/fontations?rev=b5c3030)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2118,7 +2516,7 @@ version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2175,7 +2573,7 @@ dependencies = [
|
||||
"svgtypes",
|
||||
"tiny-skia",
|
||||
"usvg",
|
||||
"zune-jpeg",
|
||||
"zune-jpeg 0.4.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2221,7 +2619,7 @@ version = "0.38.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
@ -2240,7 +2638,7 @@ version = "0.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd3c7c96f8a08ee34eff8857b11b49b07d71d1c3f4e88f8a88d4c9e9f90b1702"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"bytemuck",
|
||||
"core_maths",
|
||||
"log",
|
||||
@ -2288,7 +2686,7 @@ version = "2.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"core-foundation",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
@ -2415,6 +2813,15 @@ version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
||||
|
||||
[[package]]
|
||||
name = "simd_helpers"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6"
|
||||
dependencies = [
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simplecss"
|
||||
version = "0.2.2"
|
||||
@ -2437,7 +2844,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6d632b5a73f566303dbeabd344dc3e716fd4ddc9a70d6fc8ea8e6f06617da97"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts",
|
||||
"read-fonts 0.30.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.32.0"
|
||||
source = "git+https://github.com/googlefonts/fontations?rev=b5c3030#b5c3030a19f2b7e7fe3fb7a0f38b01e63352aea9"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts 0.30.1 (git+https://github.com/googlefonts/fontations?rev=b5c3030)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2451,9 +2867,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.13.2"
|
||||
version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
@ -2590,6 +3006,19 @@ dependencies = [
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "6.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
|
||||
dependencies = [
|
||||
"cfg-expr",
|
||||
"heck",
|
||||
"pkg-config",
|
||||
"toml",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tap"
|
||||
version = "1.0.1"
|
||||
@ -2607,6 +3036,12 @@ dependencies = [
|
||||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.12.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.16.0"
|
||||
@ -2686,6 +3121,17 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiff"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"jpeg-decoder",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.37"
|
||||
@ -3063,7 +3509,7 @@ name = "typst-library"
|
||||
version = "0.13.1"
|
||||
dependencies = [
|
||||
"az",
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"bumpalo",
|
||||
"chinese-number",
|
||||
"ciborium",
|
||||
@ -3075,6 +3521,7 @@ dependencies = [
|
||||
"fontdb",
|
||||
"glidesort",
|
||||
"hayagriva",
|
||||
"hayro-syntax",
|
||||
"icu_properties",
|
||||
"icu_provider",
|
||||
"icu_provider_blob",
|
||||
@ -3173,6 +3620,7 @@ version = "0.13.1"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"comemo",
|
||||
"hayro-render",
|
||||
"image",
|
||||
"pixglyph",
|
||||
"resvg",
|
||||
@ -3444,12 +3892,29 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "v_frame"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2"
|
||||
dependencies = [
|
||||
"aligned-vec",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
@ -3589,7 +4054,7 @@ version = "0.221.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9845c470a2e10b61dd42c385839cdd6496363ed63b5c9e420b5488b77bd22083"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
"indexmap 2.7.1",
|
||||
]
|
||||
|
||||
@ -3724,7 +4189,7 @@ version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3970,11 +4435,33 @@ version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a"
|
||||
|
||||
[[package]]
|
||||
name = "zune-core"
|
||||
version = "0.5.0-rc2"
|
||||
source = "git+https://github.com/etemesi254/zune-image?rev=ac43af3#ac43af36e7125c120d64392c3eee52528c24b5c4"
|
||||
|
||||
[[package]]
|
||||
name = "zune-inflate"
|
||||
version = "0.2.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
|
||||
dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zune-jpeg"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028"
|
||||
dependencies = [
|
||||
"zune-core",
|
||||
"zune-core 0.4.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zune-jpeg"
|
||||
version = "0.5.0-rc5"
|
||||
source = "git+https://github.com/etemesi254/zune-image?rev=ac43af3#ac43af36e7125c120d64392c3eee52528c24b5c4"
|
||||
dependencies = [
|
||||
"zune-core 0.5.0-rc2",
|
||||
]
|
||||
|
@ -61,6 +61,8 @@ fontdb = { version = "0.23", default-features = false }
|
||||
fs_extra = "1.3"
|
||||
glidesort = "0.1.2"
|
||||
hayagriva = "0.8.1"
|
||||
hayro-syntax = { path = "../hayro/hayro-syntax" }
|
||||
hayro-render = { path = "../hayro/hayro-render" }
|
||||
heck = "0.5"
|
||||
hypher = "0.1.4"
|
||||
icu_properties = { version = "1.4", features = ["serde"] }
|
||||
@ -73,8 +75,8 @@ image = { version = "0.25.5", default-features = false, features = ["png", "jpeg
|
||||
indexmap = { version = "2", features = ["serde"] }
|
||||
infer = { version = "0.19.0", default-features = false }
|
||||
kamadak-exif = "0.6"
|
||||
krilla = { git = "https://github.com/LaurenzV/krilla", rev = "20c14fe", default-features = false, features = ["raster-images", "comemo", "rayon"] }
|
||||
krilla-svg = { git = "https://github.com/LaurenzV/krilla", rev = "20c14fe" }
|
||||
krilla = { path = "../krilla/crates/krilla", default-features = false, features = ["raster-images", "comemo", "rayon", "pdf"] }
|
||||
krilla-svg = { path = "../krilla/crates/krilla-svg" }
|
||||
kurbo = "0.11"
|
||||
libfuzzer-sys = "0.4"
|
||||
lipsum = "0.9"
|
||||
|
@ -471,6 +471,7 @@ display_possible_values!(DiagnosticFormat);
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, ValueEnum)]
|
||||
pub enum Feature {
|
||||
Html,
|
||||
PdfEmbedding,
|
||||
}
|
||||
|
||||
display_possible_values!(Feature);
|
||||
|
@ -117,6 +117,7 @@ impl SystemWorld {
|
||||
.iter()
|
||||
.map(|&feature| match feature {
|
||||
Feature::Html => typst::Feature::Html,
|
||||
Feature::PdfEmbedding => typst::Feature::PdfEmbedding,
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -31,6 +31,7 @@ flate2 = { workspace = true }
|
||||
fontdb = { workspace = true }
|
||||
glidesort = { workspace = true }
|
||||
hayagriva = { workspace = true }
|
||||
hayro-syntax = { workspace = true }
|
||||
icu_properties = { workspace = true }
|
||||
icu_provider = { workspace = true }
|
||||
icu_provider_blob = { workspace = true }
|
||||
|
@ -237,6 +237,7 @@ impl FromIterator<Feature> for Features {
|
||||
#[non_exhaustive]
|
||||
pub enum Feature {
|
||||
Html,
|
||||
PdfEmbedding,
|
||||
}
|
||||
|
||||
/// A group of related standard library definitions.
|
||||
|
@ -1,5 +1,6 @@
|
||||
//! Image handling.
|
||||
|
||||
mod pdf;
|
||||
mod raster;
|
||||
mod svg;
|
||||
|
||||
@ -26,6 +27,7 @@ use crate::layout::{Length, Rel, Sizing};
|
||||
use crate::loading::{DataSource, Load, LoadSource, Loaded, Readable};
|
||||
use crate::model::Figurable;
|
||||
use crate::text::{families, LocalName};
|
||||
use crate::visualize::image::pdf::{PdfDocument, PdfImage};
|
||||
|
||||
/// A raster or vector graphic.
|
||||
///
|
||||
@ -126,6 +128,11 @@ pub struct ImageElem {
|
||||
/// A text describing the image.
|
||||
pub alt: Option<EcoString>,
|
||||
|
||||
/// The page number that should be embedded as an image. This attribute only has an effect
|
||||
/// for PDF files.
|
||||
#[default(1)]
|
||||
pub page: usize,
|
||||
|
||||
/// How the image should adjust itself to a given area (the area is defined
|
||||
/// by the `width` and `height` fields). Note that `fit` doesn't visually
|
||||
/// change anything if the area's aspect ratio is the same as the image's
|
||||
@ -261,6 +268,15 @@ impl Packed<ImageElem> {
|
||||
)
|
||||
.within(loaded)?,
|
||||
),
|
||||
ImageFormat::Vector(VectorFormat::Pdf) => {
|
||||
let document = PdfDocument::new(loaded.data.clone()).within(loaded)?;
|
||||
// The user provides the page number staring from 1, further down the pipeline they page
|
||||
// numbers are 0-based.
|
||||
let pdf_image =
|
||||
PdfImage::new(document, self.page.get(styles) - 1).within(loaded)?;
|
||||
|
||||
ImageKind::Pdf(pdf_image)
|
||||
}
|
||||
};
|
||||
|
||||
Ok(Image::new(kind, self.alt.get_cloned(styles), self.scaling.get(styles)))
|
||||
@ -286,6 +302,7 @@ impl Packed<ImageElem> {
|
||||
"jpg" | "jpeg" => return Ok(ExchangeFormat::Jpg.into()),
|
||||
"gif" => return Ok(ExchangeFormat::Gif.into()),
|
||||
"svg" | "svgz" => return Ok(VectorFormat::Svg.into()),
|
||||
"pdf" => return Ok(VectorFormat::Pdf.into()),
|
||||
"webp" => return Ok(ExchangeFormat::Webp.into()),
|
||||
_ => {}
|
||||
}
|
||||
@ -373,6 +390,7 @@ impl Image {
|
||||
match &self.0.kind {
|
||||
ImageKind::Raster(raster) => raster.format().into(),
|
||||
ImageKind::Svg(_) => VectorFormat::Svg.into(),
|
||||
ImageKind::Pdf(_) => VectorFormat::Pdf.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,6 +399,7 @@ impl Image {
|
||||
match &self.0.kind {
|
||||
ImageKind::Raster(raster) => raster.width() as f64,
|
||||
ImageKind::Svg(svg) => svg.width(),
|
||||
ImageKind::Pdf(pdf) => pdf.width() as f64,
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,6 +408,7 @@ impl Image {
|
||||
match &self.0.kind {
|
||||
ImageKind::Raster(raster) => raster.height() as f64,
|
||||
ImageKind::Svg(svg) => svg.height(),
|
||||
ImageKind::Pdf(pdf) => pdf.height() as f64,
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,6 +417,7 @@ impl Image {
|
||||
match &self.0.kind {
|
||||
ImageKind::Raster(raster) => raster.dpi(),
|
||||
ImageKind::Svg(_) => Some(Image::USVG_DEFAULT_DPI),
|
||||
ImageKind::Pdf(_) => Some(Image::DEFAULT_DPI),
|
||||
}
|
||||
}
|
||||
|
||||
@ -435,6 +456,8 @@ pub enum ImageKind {
|
||||
Raster(RasterImage),
|
||||
/// An SVG image.
|
||||
Svg(SvgImage),
|
||||
/// A PDF image.
|
||||
Pdf(PdfImage),
|
||||
}
|
||||
|
||||
impl From<RasterImage> for ImageKind {
|
||||
@ -469,10 +492,20 @@ impl ImageFormat {
|
||||
return Some(Self::Vector(VectorFormat::Svg));
|
||||
}
|
||||
|
||||
if is_pdf(data) {
|
||||
return Some(Self::Vector(VectorFormat::Pdf));
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks whether the data looks like a PDF file.
|
||||
fn is_pdf(data: &[u8]) -> bool {
|
||||
let head = &data[..data.len().min(2048)];
|
||||
memchr::memmem::find(head, b"%PDF-").is_some()
|
||||
}
|
||||
|
||||
/// Checks whether the data looks like an SVG or a compressed SVG.
|
||||
fn is_svg(data: &[u8]) -> bool {
|
||||
// Check for the gzip magic bytes. This check is perhaps a bit too
|
||||
@ -493,6 +526,8 @@ fn is_svg(data: &[u8]) -> bool {
|
||||
pub enum VectorFormat {
|
||||
/// The vector graphics format of the web.
|
||||
Svg,
|
||||
/// The PDF graphics format.
|
||||
Pdf,
|
||||
}
|
||||
|
||||
impl<R> From<R> for ImageFormat
|
||||
|
96
crates/typst-library/src/visualize/image/pdf.rs
Normal file
96
crates/typst-library/src/visualize/image/pdf.rs
Normal file
@ -0,0 +1,96 @@
|
||||
use crate::diag::LoadResult;
|
||||
use crate::foundations::Bytes;
|
||||
use hayro_syntax::pdf::Pdf;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::sync::Arc;
|
||||
use hayro_syntax::document::page::Page;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct DocumentRepr {
|
||||
pdf: Arc<Pdf>,
|
||||
data: Bytes,
|
||||
page_sizes: Vec<(f32, f32)>,
|
||||
}
|
||||
|
||||
impl Hash for DocumentRepr {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.data.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
/// A PDF document.
|
||||
#[derive(Clone, Hash)]
|
||||
pub struct PdfDocument(Arc<DocumentRepr>);
|
||||
|
||||
impl PdfDocument {
|
||||
/// Load a PDF document.
|
||||
#[comemo::memoize]
|
||||
#[typst_macros::time(name = "load pdf document")]
|
||||
pub fn new(data: Bytes) -> LoadResult<PdfDocument> {
|
||||
// TODO: Remove unwraps
|
||||
let pdf = Arc::new(Pdf::new(Arc::new(data.clone())).unwrap());
|
||||
let pages = pdf.pages().unwrap();
|
||||
|
||||
let page_sizes = pages.get().iter().map(|p| p.render_dimensions()).collect();
|
||||
|
||||
Ok(Self(Arc::new(DocumentRepr { data, pdf, page_sizes })))
|
||||
}
|
||||
}
|
||||
|
||||
struct ImageRepr {
|
||||
pub document: PdfDocument,
|
||||
pub page_index: usize,
|
||||
pub width: f32,
|
||||
pub height: f32,
|
||||
}
|
||||
|
||||
impl Hash for ImageRepr {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.document.hash(state);
|
||||
self.page_index.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
/// A page of a PDF file.
|
||||
#[derive(Clone, Hash)]
|
||||
pub struct PdfImage(Arc<ImageRepr>);
|
||||
|
||||
impl PdfImage {
|
||||
#[comemo::memoize]
|
||||
pub fn new(document: PdfDocument, page: usize) -> LoadResult<PdfImage> {
|
||||
// TODO: Don't allow loading if pdf-embedding feature is disabled.
|
||||
// TODO: Remove Unwrap
|
||||
let dimensions = *(&document.0).page_sizes.get(page).unwrap();
|
||||
|
||||
Ok(Self(Arc::new(ImageRepr {
|
||||
document,
|
||||
page_index: page,
|
||||
width: dimensions.0,
|
||||
height: dimensions.1,
|
||||
})))
|
||||
}
|
||||
|
||||
pub fn with_page<F, R>(&self, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&Page) -> R,
|
||||
{
|
||||
let pages = self.0.document.0.pdf.pages().unwrap();
|
||||
f(&pages.get().get(self.0.page_index).unwrap())
|
||||
}
|
||||
|
||||
pub fn width(&self) -> f32 {
|
||||
self.0.width
|
||||
}
|
||||
|
||||
pub fn height(&self) -> f32 {
|
||||
self.0.height
|
||||
}
|
||||
|
||||
pub fn data(&self) -> &Bytes {
|
||||
&self.0.document.0.data
|
||||
}
|
||||
|
||||
pub fn page_index(&self) -> usize {
|
||||
self.0.page_index
|
||||
}
|
||||
}
|
@ -363,6 +363,11 @@ fn finish(
|
||||
hint: "convert the image to 8 bit instead"
|
||||
)
|
||||
}
|
||||
KrillaError::Pdf(_, e, loc) => {
|
||||
// TODO: Better errors
|
||||
let span = to_span(loc);
|
||||
bail!(span, "failed to process PDF");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -576,6 +581,17 @@ fn convert_error(
|
||||
"{prefix} missing document date";
|
||||
hint: "set the date of the document"
|
||||
),
|
||||
ValidationError::DuplicateTagId(_, loc) => error!(
|
||||
to_span(*loc),
|
||||
"{prefix} duplicate tag id";
|
||||
hint: "please report this as a bug"
|
||||
),
|
||||
ValidationError::UnknownTagId(_, loc) => error!(
|
||||
to_span(*loc),
|
||||
"{prefix} unknown tag id";
|
||||
hint: "please report this as a bug"
|
||||
),
|
||||
ValidationError::EmbeddedPDF(loc) => error!(to_span(*loc), "TODO"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ use std::sync::{Arc, OnceLock};
|
||||
|
||||
use image::{DynamicImage, EncodableLayout, GenericImageView, Rgba};
|
||||
use krilla::image::{BitsPerComponent, CustomImage, ImageColorspace};
|
||||
use krilla::pdf::PdfDocument;
|
||||
use krilla::surface::Surface;
|
||||
use krilla_svg::{SurfaceExt, SvgSettings};
|
||||
use typst_library::diag::{bail, SourceResult};
|
||||
@ -60,6 +61,15 @@ pub(crate) fn handle_image(
|
||||
SvgSettings { embed_text: true, ..Default::default() },
|
||||
);
|
||||
}
|
||||
ImageKind::Pdf(pdf) => {
|
||||
let pdf_data: Arc<dyn AsRef<[u8]> + Send + Sync> =
|
||||
Arc::new(pdf.data().clone());
|
||||
surface.draw_pdf_page(
|
||||
&PdfDocument::new(pdf_data.into()).unwrap(),
|
||||
size.to_krilla(),
|
||||
pdf.page_index(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if image.alt().is_some() {
|
||||
|
@ -18,6 +18,7 @@ typst-macros = { workspace = true }
|
||||
typst-timing = { workspace = true }
|
||||
bytemuck = { workspace = true }
|
||||
comemo = { workspace = true }
|
||||
hayro-render = { workspace = true }
|
||||
image = { workspace = true }
|
||||
pixglyph = { workspace = true }
|
||||
resvg = { workspace = true }
|
||||
|
@ -1,8 +1,9 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use hayro_render::{InterpreterSettings, RenderSettings};
|
||||
use image::imageops::FilterType;
|
||||
use image::{GenericImageView, Rgba};
|
||||
use tiny_skia as sk;
|
||||
use tiny_skia::IntSize;
|
||||
use typst_library::foundations::Smart;
|
||||
use typst_library::layout::Size;
|
||||
use typst_library::visualize::{Image, ImageKind, ImageScaling};
|
||||
@ -59,9 +60,9 @@ pub fn render_image(
|
||||
/// Prepare a texture for an image at a scaled size.
|
||||
#[comemo::memoize]
|
||||
fn build_texture(image: &Image, w: u32, h: u32) -> Option<Arc<sk::Pixmap>> {
|
||||
let mut texture = sk::Pixmap::new(w, h)?;
|
||||
match image.kind() {
|
||||
let texture = match image.kind() {
|
||||
ImageKind::Raster(raster) => {
|
||||
let mut texture = sk::Pixmap::new(w, h)?;
|
||||
let w = texture.width();
|
||||
let h = texture.height();
|
||||
|
||||
@ -85,15 +86,37 @@ fn build_texture(image: &Image, w: u32, h: u32) -> Option<Arc<sk::Pixmap>> {
|
||||
let Rgba([r, g, b, a]) = src;
|
||||
*dest = sk::ColorU8::from_rgba(r, g, b, a).premultiply();
|
||||
}
|
||||
|
||||
texture
|
||||
}
|
||||
ImageKind::Svg(svg) => {
|
||||
let mut texture = sk::Pixmap::new(w, h)?;
|
||||
let tree = svg.tree();
|
||||
let ts = tiny_skia::Transform::from_scale(
|
||||
w as f32 / tree.size().width(),
|
||||
h as f32 / tree.size().height(),
|
||||
);
|
||||
resvg::render(tree, ts, &mut texture.as_mut());
|
||||
|
||||
texture
|
||||
}
|
||||
}
|
||||
ImageKind::Pdf(pdf) => {
|
||||
let hayro_pix = pdf.with_page(|page| {
|
||||
// TODO: Configure so that PDF standard fonts can be resolved
|
||||
let interpreter_settings = InterpreterSettings::default();
|
||||
let render_settings = RenderSettings {
|
||||
x_scale: w as f32 / pdf.width(),
|
||||
y_scale: h as f32 / pdf.height(),
|
||||
width: Some(w as u16),
|
||||
height: Some(h as u16)
|
||||
};
|
||||
hayro_render::render(page, &interpreter_settings, &render_settings)
|
||||
|
||||
});
|
||||
|
||||
sk::Pixmap::from_vec(hayro_pix.data_as_u8_slice().to_vec(), IntSize::from_wh(w, h)?)?
|
||||
},
|
||||
};
|
||||
|
||||
Some(Arc::new(texture))
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ pub fn convert_image_to_base64_url(image: &Image) -> EcoString {
|
||||
}),
|
||||
},
|
||||
ImageKind::Svg(svg) => ("svg+xml", svg.data()),
|
||||
ImageKind::Pdf(_) => todo!(),
|
||||
};
|
||||
|
||||
let mut url = eco_format!("data:image/{format};base64,");
|
||||
|
Loading…
x
Reference in New Issue
Block a user