diff --git a/Cargo.lock b/Cargo.lock index 613f9f8e..73b35403 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,16 +9,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] -name = "ahash" -version = "0.8.11" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -35,12 +29,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" -[[package]] -name = "allocator-api2" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" - [[package]] name = "anyhow" version = "1.0.86" @@ -135,15 +123,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcde5f311c85b8ca30c2e4198d4326bc342c76541590106f5fa4a50946ea499" -[[package]] -name = "block2" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" -dependencies = [ - "objc2", -] - [[package]] name = "built" version = "0.7.4" @@ -221,58 +200,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "core-graphics" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types", - "libc", -] - -[[package]] -name = "core-graphics-types" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "libc", -] - -[[package]] -name = "core-text" -version = "20.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d2790b5c08465d49f8dc05c8bcae9fea467855947db39b0f8145c091aaced5" -dependencies = [ - "core-foundation", - "core-graphics", - "foreign-types", - "libc", -] - [[package]] name = "core_maths" version = "0.1.0" @@ -285,7 +212,7 @@ dependencies = [ [[package]] name = "cosmic-text" version = "0.12.1" -source = "git+https://github.com/pop-os/cosmic-text?rev=6f78d23#6f78d23a8cde3d9c25e9d27965dd326e297b4ec2" +source = "git+https://github.com/LaurenzV/cosmic-text?rev=d8cad28#d8cad281e9bcd6378aea94c0c501a6a248fe4073" dependencies = [ "bitflags 2.6.0", "fontdb", @@ -293,7 +220,7 @@ dependencies = [ "rangemap", "rayon", "rustc-hash", - "rustybuzz 0.17.0", + "rustybuzz", "self_cell", "swash", "sys-locale", @@ -356,31 +283,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "dwrote" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" -dependencies = [ - "lazy_static", - "libc", - "serde", - "serde_derive", - "winapi", - "wio", -] - [[package]] name = "either" version = "1.13.0" @@ -403,7 +305,7 @@ dependencies = [ "flume", "half", "lebe", - "miniz_oxide", + "miniz_oxide 0.7.4", "rayon-core", "smallvec", "zune-inflate", @@ -425,7 +327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.7.4", ] [[package]] @@ -446,15 +348,6 @@ dependencies = [ "spin", ] -[[package]] -name = "font-types" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34fd7136aca682873d859ef34494ab1a7d3f57ecd485ed40eb6437ee8c85aa29" -dependencies = [ - "bytemuck", -] - [[package]] name = "font-types" version = "0.6.0" @@ -466,20 +359,11 @@ dependencies = [ [[package]] name = "font-types" -version = "0.6.0" -source = "git+https://github.com/LaurenzV/fontations?rev=0ed7955#0ed7955144921786be33b38b0c4530f8c4c8a316" -dependencies = [ - "bytemuck", -] - -[[package]] -name = "fontconfig-cache-parser" -version = "0.2.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f8afb20c8069fd676d27b214559a337cc619a605d25a87baa90b49a06f3b18" +checksum = "a3ade9a548352698c7f1e340fd5caf76b9f06c0b587e6b4840ea077e1524c685" dependencies = [ "bytemuck", - "thiserror", ] [[package]] @@ -488,14 +372,14 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1fcfcd44ca6e90c921fee9fa665d530b21ef1327a4c1a6c5250ea44b776ada7" dependencies = [ - "roxmltree 0.20.0", + "roxmltree", ] [[package]] name = "fontdb" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f874d3f04ab8bf6f591358b03e4f1e084e396c4263a1c29ebbaa0feff7ba99" +checksum = "37be9fc20d966be438cd57a45767f73349477fb0f85ce86e000557f787298afb" dependencies = [ "fontconfig-parser", "log", @@ -505,55 +389,6 @@ dependencies = [ "ttf-parser", ] -[[package]] -name = "fontique" -version = "0.1.0" -source = "git+https://github.com/linebender/parley?rev=66979c5#66979c500e393945e743b30f96501c5838a5725f" -dependencies = [ - "core-foundation", - "core-text", - "dwrote", - "fontconfig-cache-parser", - "hashbrown", - "icu_locid", - "memmap2", - "objc2", - "objc2-foundation", - "peniko", - "roxmltree 0.19.0", - "skrifa 0.19.3", - "smallvec", - "winapi", - "wio", -] - -[[package]] -name = "foreign-types" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" -dependencies = [ - "foreign-types-macros", - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-macros" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "foreign-types-shared" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -596,10 +431,6 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", - "allocator-api2", -] [[package]] name = "heck" @@ -607,18 +438,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "icu_locid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", -] - [[package]] name = "image" version = "0.24.9" @@ -676,6 +495,12 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" +[[package]] +name = "imagesize" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285" + [[package]] name = "imgref" version = "1.10.1" @@ -746,16 +571,15 @@ dependencies = [ "float-cmp", "fontdb", "image 0.25.2", - "miniz_oxide", + "miniz_oxide 0.8.0", "once_cell", - "parley", "paste", "pdf-writer", "resvg", - "rustybuzz 0.18.0", + "rustybuzz", "siphasher", "sitro", - "skrifa 0.20.0 (git+https://github.com/LaurenzV/fontations?rev=0ed7955)", + "skrifa 0.21.0", "subsetter", "tiny-skia", "tiny-skia-path", @@ -773,12 +597,6 @@ dependencies = [ "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" @@ -808,12 +626,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "litemap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" - [[package]] name = "lock_api" version = "0.4.12" @@ -879,6 +691,15 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -951,57 +772,12 @@ dependencies = [ "autocfg", ] -[[package]] -name = "objc-sys" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" - -[[package]] -name = "objc2" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" -dependencies = [ - "objc-sys", - "objc2-encode", -] - -[[package]] -name = "objc2-encode" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7891e71393cd1f227313c9379a26a584ff3d7e6e7159e988851f0934c993f0f8" - -[[package]] -name = "objc2-foundation" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" -dependencies = [ - "bitflags 2.6.0", - "block2", - "libc", - "objc2", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parley" -version = "0.1.0" -source = "git+https://github.com/linebender/parley?rev=66979c5#66979c500e393945e743b30f96501c5838a5725f" -dependencies = [ - "fontique", - "peniko", - "skrifa 0.19.3", - "swash", -] - [[package]] name = "paste" version = "1.0.15" @@ -1019,16 +795,6 @@ dependencies = [ "ryu", ] -[[package]] -name = "peniko" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c28d7294093837856bb80ad191cc46a2fcec8a30b43b7a3b0285325f0a917a9" -dependencies = [ - "kurbo", - "smallvec", -] - [[package]] name = "pico-args" version = "0.5.0" @@ -1051,7 +817,7 @@ dependencies = [ "crc32fast", "fdeflate", "flate2", - "miniz_oxide", + "miniz_oxide 0.7.4", ] [[package]] @@ -1257,16 +1023,6 @@ dependencies = [ "rand_core 0.3.1", ] -[[package]] -name = "read-fonts" -version = "0.19.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b8af39d1f23869711ad4cea5e7835a20daa987f80232f7f2a2374d648ca64d" -dependencies = [ - "bytemuck", - "font-types 0.5.5", -] - [[package]] name = "read-fonts" version = "0.20.0" @@ -1274,16 +1030,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c141b9980e1150201b2a3a32879001c8f975fe313ec3df5471a9b5c79a880cd" dependencies = [ "bytemuck", - "font-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "font-types 0.6.0", ] [[package]] name = "read-fonts" -version = "0.20.0" -source = "git+https://github.com/LaurenzV/fontations?rev=0ed7955#0ed7955144921786be33b38b0c4530f8c4c8a316" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baa1d3f6c6449e4299e17814855468617c2924753ce4f0601b16cba9f8e7bd8" dependencies = [ "bytemuck", - "font-types 0.6.0 (git+https://github.com/LaurenzV/fontations?rev=0ed7955)", + "font-types 0.7.0", ] [[package]] @@ -1326,8 +1083,9 @@ dependencies = [ [[package]] name = "resvg" -version = "0.42.0" -source = "git+https://github.com/LaurenzV/resvg?rev=1c2b6bd0#1c2b6bd005ba1874d20afe8f3aa5b6298997901f" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7314563c59c7ce31c18e23ad3dd092c37b928a0fa4e1c0a1a6504351ab411d1" dependencies = [ "gif", "image-webp", @@ -1349,12 +1107,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "roxmltree" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f" - [[package]] name = "roxmltree" version = "0.20.0" @@ -1367,23 +1119,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustybuzz" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23288ca94acc914c882928fe4fae313ebaa58aa55400f2b08f2c4b01538e3464" -dependencies = [ - "bitflags 2.6.0", - "bytemuck", - "core_maths", - "smallvec", - "ttf-parser", - "unicode-bidi-mirroring", - "unicode-ccc", - "unicode-properties", - "unicode-script", -] - [[package]] name = "rustybuzz" version = "0.18.0" @@ -1500,7 +1235,7 @@ version = "0.1.0" source = "git+https://github.com/LaurenzV/sitro?rev=b475ddc3#b475ddc323fe724f3a5377b831dd7100ae75f1ec" dependencies = [ "image 0.24.9", - "imagesize", + "imagesize 0.12.0", "rayon", "regex", "tempdir", @@ -1508,16 +1243,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "skrifa" -version = "0.19.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab45fb68b53576a43d4fc0e9ec8ea64e29a4d2cc7f44506964cb75f288222e9" -dependencies = [ - "bytemuck", - "read-fonts 0.19.3", -] - [[package]] name = "skrifa" version = "0.20.0" @@ -1525,16 +1250,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abea4738067b1e628c6ce28b2c216c19e9ea95715cdb332680e821c3bec2ef23" dependencies = [ "bytemuck", - "read-fonts 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "read-fonts 0.20.0", ] [[package]] name = "skrifa" -version = "0.20.0" -source = "git+https://github.com/LaurenzV/fontations?rev=0ed7955#0ed7955144921786be33b38b0c4530f8c4c8a316" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a49b2de0351f3b8c6dc852c83be4b5a0095e607a29c5731597c0204ed5ec78e" dependencies = [ "bytemuck", - "read-fonts 0.20.0 (git+https://github.com/LaurenzV/fontations?rev=0ed7955)", + "read-fonts 0.21.0", ] [[package]] @@ -1597,7 +1323,7 @@ version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93cdc334a50fcc2aa3f04761af3b28196280a6aaadb1ef11215c478ae32615ac" dependencies = [ - "skrifa 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "skrifa 0.20.0", "yazi", "zeno", ] @@ -1711,22 +1437,14 @@ dependencies = [ [[package]] name = "tiny-skia-path" version = "0.11.4" -source = "git+https://github.com/RazrFalcon/tiny-skia?rev=eec0a47#eec0a4701a8413759a3dd51b443b8851ce4c546a" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" dependencies = [ "arrayref", "bytemuck", "strict-num", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", -] - [[package]] name = "tinyvec" version = "1.8.0" @@ -1841,19 +1559,20 @@ checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" [[package]] name = "usvg" -version = "0.42.0" -source = "git+https://github.com/LaurenzV/resvg?rev=1c2b6bd0#1c2b6bd005ba1874d20afe8f3aa5b6298997901f" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6803057b5cbb426e9fb8ce2216f3a9b4ca1dd2c705ba3cbebc13006e437735fd" dependencies = [ "base64", "data-url", "flate2", "fontdb", - "imagesize", + "imagesize 0.13.0", "kurbo", "log", "pico-args", - "roxmltree 0.20.0", - "rustybuzz 0.17.0", + "roxmltree", + "rustybuzz", "simplecss", "siphasher", "strict-num", @@ -2078,21 +1797,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "wio" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" -dependencies = [ - "winapi", -] - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - [[package]] name = "xmlwriter" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index f4a98884..97634ded 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,31 +5,27 @@ edition = "2021" [dependencies] image = { version = "0.25.1", default-features = false, features = ["jpeg", "png", "gif", "webp"] } -miniz_oxide = "0.7.4" +miniz_oxide = "0.8.0" once_cell = "1.19.0" pdf-writer = {git = "https://github.com/LaurenzV/pdf-writer", rev = "34c991f5"} -resvg = {git = "https://github.com/LaurenzV/resvg", rev = "1c2b6bd0"} +resvg = "0.43.0" siphasher = "1.0.1" -skrifa = {git="https://github.com/LaurenzV/fontations", rev="0ed7955"} +skrifa = "0.21.0" tiny-skia = "0.11.4" subsetter = {git = "https://github.com/typst/subsetter/", rev="67bde74"} -tiny-skia-path = {git = "https://github.com/RazrFalcon/tiny-skia", rev="eec0a47"} -usvg = {git = "https://github.com/LaurenzV/resvg", rev="1c2b6bd0"} -cosmic-text = {git = "https://github.com/pop-os/cosmic-text", rev = "6f78d23"} -parley = {git = "https://github.com/linebender/parley", rev = "66979c5"} +tiny-skia-path = "0.11.4" +usvg = "0.43.0" flate2 = "1.0.30" -fontdb = "0.20.0" +fontdb = "0.21.0" yoke = { version = "0.7.4", features = ["derive"] } float-cmp = "0.9.0" -[patch.crates-io] -tiny-skia-path = {git = "https://github.com/RazrFalcon/tiny-skia", rev="eec0a47"} - [dev-dependencies] difference = "2.0.0" image = "0.25.1" paste = "1.0.15" rustybuzz = "0.18.0" sitro = {git = "https://github.com/LaurenzV/sitro", rev = "b475ddc3"} +cosmic-text = {git = "https://github.com/LaurenzV/cosmic-text", rev = "d8cad28"} diff --git a/src/font/mod.rs b/src/font/mod.rs index 605fe443..724a5e69 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -2,7 +2,7 @@ use crate::chunk_container::ChunkContainer; use crate::serialize::{Object, SerializerContext, SvgSettings}; use crate::surface::Surface; use crate::type3_font::Type3ID; -use crate::util::Prehashed; +use crate::util::{Prehashed, RectWrapper}; use pdf_writer::{Chunk, Ref}; use skrifa::instance::Location; use skrifa::outline::OutlinePen; @@ -58,13 +58,30 @@ impl OutlinePen for OutlineBuilder { } } +#[derive(Debug)] +struct LocationWrapper(Location); + +impl Hash for LocationWrapper { + fn hash(&self, state: &mut H) { + self.0.coords().hash(state); + } +} + +impl PartialEq for LocationWrapper { + fn eq(&self, other: &Self) -> bool { + self.0.coords().eq(other.0.coords()) + } +} + +impl Eq for LocationWrapper {} + #[derive(Debug, Hash, Eq, PartialEq)] pub struct FontInfo { index: u32, checksum: u32, - location: Location, + location: LocationWrapper, pub(crate) units_per_em: u16, - global_bbox: Rect, + global_bbox: RectWrapper, postscript_name: Option, ascent: FiniteF32, descent: FiniteF32, @@ -76,6 +93,7 @@ pub struct FontInfo { struct Repr { font_info: Arc, + font_data: Arc + Send + Sync>, font_ref_yoke: Yoke, Arc + Send + Sync>>, } @@ -141,7 +159,7 @@ impl FontInfo { Some(FontInfo { index, checksum, - location, + location: LocationWrapper(location), units_per_em, postscript_name, ascent, @@ -150,7 +168,7 @@ impl FontInfo { is_monospaced, weight, italic_angle, - global_bbox, + global_bbox: RectWrapper(global_bbox), }) } } @@ -184,6 +202,7 @@ impl Font { ); Some(Font(Arc::new(Prehashed::new(Repr { + font_data: data, font_ref_yoke, font_info, })))) @@ -230,17 +249,21 @@ impl Font { } pub fn bbox(&self) -> Rect { - self.0.font_info.global_bbox + self.0.font_info.global_bbox.0 } pub fn location_ref(&self) -> LocationRef { - (&self.0.font_info.location).into() + (&self.0.font_info.location.0).into() } pub fn font_ref(&self) -> &FontRef { &self.0.font_ref_yoke.get().font_ref } + pub fn font_data(&self) -> Arc + Send + Sync> { + self.0.font_data.clone() + } + pub fn advance_width(&self, glyph_id: GlyphId) -> Option { self.font_ref() .glyph_metrics(Size::unscaled(), self.location_ref()) diff --git a/src/font/svg.rs b/src/font/svg.rs index 7cb443f6..26c7dfe3 100644 --- a/src/font/svg.rs +++ b/src/font/svg.rs @@ -18,7 +18,7 @@ pub fn draw_glyph( .svg() .and_then(|svg_table| svg_table.glyph_data(glyph)) { - let mut data = svg_data.get(); + let mut data = svg_data; let mut decoded = vec![]; if data.starts_with(&[0x1f, 0x8b]) { diff --git a/src/lib.rs b/src/lib.rs index 8309165f..11457da6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,7 +103,8 @@ pub(crate) mod test_utils { } pub fn simple_shape(text: &str, dir: Direction, font: Font, size: f32) -> Vec { - let rb_font = rustybuzz::Face::from_slice(font.font_ref().data().as_bytes(), 0).unwrap(); + let data = font.font_data(); + let rb_font = rustybuzz::Face::from_slice(data.as_ref().as_ref(), 0).unwrap(); let mut buffer = UnicodeBuffer::new(); buffer.push_str(text); diff --git a/src/object/cid_font.rs b/src/object/cid_font.rs index c0f89b45..8139aa0b 100644 --- a/src/object/cid_font.rs +++ b/src/object/cid_font.rs @@ -5,7 +5,7 @@ use pdf_writer::types::{CidFontType, FontFlags, SystemInfo, UnicodeCmap}; use pdf_writer::{Chunk, Filter, Finish, Name, Ref, Str}; use skrifa::raw::tables::cff::Cff; use skrifa::raw::{TableProvider, TopLevelTable}; -use skrifa::{FontRef, GlyphId}; +use skrifa::GlyphId; use std::collections::BTreeMap; use subsetter::GlyphRemapper; @@ -104,7 +104,7 @@ impl CIDFont { let is_cff = self.font.font_ref().cff().is_ok(); let (subsetted_font, filter) = - subset_font(sc, self.font.font_ref(), self.font.index(), &glyph_remapper); + subset_font(sc, &self.font, self.font.index(), &glyph_remapper); let postscript_name = self.font.postscript_name().unwrap_or("unknown"); let subset_tag = subset_tag(&subsetted_font); @@ -214,11 +214,12 @@ impl CIDFont { /// Subset a font with the given glyphs. fn subset_font( sc: &SerializerContext, - font_ref: &FontRef, + font: &Font, index: u32, glyph_remapper: &GlyphRemapper, ) -> (Vec, Filter) { - let subsetted = subsetter::subset(font_ref.data().as_bytes(), index, glyph_remapper).unwrap(); + let font_data = font.font_data(); + let subsetted = subsetter::subset(font_data.as_ref().as_ref(), index, glyph_remapper).unwrap(); let mut data = subsetted.as_slice(); // If we have a CFF font, only embed the standalone CFF program. diff --git a/src/object/image.rs b/src/object/image.rs index f256bb4b..8607dacc 100644 --- a/src/object/image.rs +++ b/src/object/image.rs @@ -1,7 +1,7 @@ use crate::chunk_container::ChunkContainer; use crate::object::color_space::DEVICE_GRAY; use crate::serialize::{Object, SerializerContext}; -use crate::util::{NameExt, Prehashed}; +use crate::util::{NameExt, Prehashed, SizeWrapper}; use image::{ColorType, DynamicImage, Luma, Rgb, Rgba}; use pdf_writer::{Chunk, Finish, Name, Ref}; use std::sync::Arc; @@ -10,7 +10,7 @@ use tiny_skia_path::Size; #[derive(Debug, Hash, Eq, PartialEq)] pub struct Repr { image_data: Vec, - size: Size, + size: SizeWrapper, mask_data: Option>, color_type: ColorType, } @@ -31,12 +31,12 @@ impl Image { image_data, mask_data, color_type, - size, + size: SizeWrapper(size), }))) } pub fn size(&self) -> Size { - self.0.size + self.0.size.0 } } diff --git a/src/object/mask.rs b/src/object/mask.rs index b31399af..f2b2512c 100644 --- a/src/object/mask.rs +++ b/src/object/mask.rs @@ -7,6 +7,7 @@ use crate::surface::StreamBuilder; use crate::transform::TransformWrapper; use pdf_writer::{Chunk, Finish, Name, Ref}; use tiny_skia_path::Rect; +use crate::util::RectWrapper; /// A mask. #[derive(PartialEq, Eq, Debug, Hash, Clone)] @@ -19,7 +20,7 @@ pub struct Mask { /// transparencies, we create a custom mask where we call the shading operator. In this case, /// we want to manually set the bbox of the underlying XObject to match the shape that the /// gradient is being applied to. - custom_bbox: Option, + custom_bbox: Option, } impl Mask { @@ -67,7 +68,7 @@ impl Mask { Some(Self { stream: shading_stream, mask_type: MaskType::Luminosity, - custom_bbox: Some(bbox), + custom_bbox: Some(RectWrapper(bbox)), }) } } @@ -103,7 +104,7 @@ impl Object for Mask { self.stream.clone(), false, true, - self.custom_bbox, + self.custom_bbox.map(|c| c.0), )); let mut dict = chunk.indirect(root_ref).dict(); diff --git a/src/object/shading_function.rs b/src/object/shading_function.rs index 3a7702b9..8f8e9fa0 100644 --- a/src/object/shading_function.rs +++ b/src/object/shading_function.rs @@ -3,7 +3,7 @@ use crate::object::color_space::{Color, ColorSpace}; use crate::paint::SpreadMethod; use crate::serialize::{Object, SerializerContext}; use crate::transform::TransformWrapper; -use crate::util::RectExt; +use crate::util::{RectExt, RectWrapper}; use crate::{LinearGradient, RadialGradient, SweepGradient}; use pdf_writer::types::FunctionShadingType; use pdf_writer::{Chunk, Finish, Name, Ref}; @@ -36,7 +36,7 @@ pub struct PostScriptGradient { pub min: FiniteF32, pub max: FiniteF32, pub stops: Vec, - pub domain: Rect, + pub domain: RectWrapper, pub spread_method: SpreadMethod, pub gradient_type: GradientType, } @@ -110,7 +110,7 @@ where .into_iter() .map(|s| s.into()) .collect::>(), - domain: get_expanded_bbox(bbox, self.transform.post_concat(ts)), + domain: RectWrapper(get_expanded_bbox(bbox, self.transform.post_concat(ts))), spread_method: self.spread_method, gradient_type: GradientType::Linear, }), @@ -141,7 +141,7 @@ where .into_iter() .map(|s| s.into()) .collect::>(), - domain: get_expanded_bbox(bbox, transform), + domain: RectWrapper(get_expanded_bbox(bbox, transform)), spread_method: self.spread_method, gradient_type: GradientType::Sweep, }), diff --git a/src/object/xobject.rs b/src/object/xobject.rs index c557b28a..71e083e7 100644 --- a/src/object/xobject.rs +++ b/src/object/xobject.rs @@ -1,7 +1,7 @@ use crate::chunk_container::ChunkContainer; use crate::serialize::{Object, SerializerContext}; use crate::stream::Stream; -use crate::util::RectExt; +use crate::util::{RectExt, RectWrapper}; use pdf_writer::{Chunk, Finish, Name, Ref}; use tiny_skia_path::Rect; @@ -10,7 +10,7 @@ pub struct XObject { stream: Stream, isolated: bool, transparency_group_color_space: bool, - custom_bbox: Option, + custom_bbox: Option, } impl XObject { @@ -24,12 +24,12 @@ impl XObject { stream, isolated, transparency_group_color_space, - custom_bbox, + custom_bbox: custom_bbox.map(|c| RectWrapper(c)), } } pub fn bbox(&self) -> Rect { - self.custom_bbox.unwrap_or(self.stream.bbox()) + self.custom_bbox.map(|c| c.0).unwrap_or(self.stream.bbox()) } } @@ -53,7 +53,7 @@ impl Object for XObject { self.stream .resource_dictionary() .to_pdf_resources(sc, &mut x_object); - x_object.bbox(self.custom_bbox.unwrap_or(self.stream.bbox()).to_pdf_rect()); + x_object.bbox(self.custom_bbox.map(|c| c.0).unwrap_or(self.stream.bbox()).to_pdf_rect()); if self.isolated || self.transparency_group_color_space { let mut group = x_object.group(); diff --git a/src/stream.rs b/src/stream.rs index 836b21f5..faf280cb 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -17,7 +17,7 @@ use crate::resource::{ }; use crate::serialize::{FontContainer, PDFGlyph, SerializerContext}; use crate::transform::TransformWrapper; -use crate::util::{calculate_stroke_bbox, LineCapExt, LineJoinExt, NameExt, RectExt, TransformExt}; +use crate::util::{calculate_stroke_bbox, LineCapExt, LineJoinExt, NameExt, RectExt, RectWrapper, TransformExt}; use crate::{Fill, FillRule, LineCap, LineJoin, Paint, Stroke}; use float_cmp::approx_eq; use pdf_writer::types::TextRenderingMode; @@ -31,7 +31,7 @@ use tiny_skia_path::{FiniteF32, NormalizedF32, Path, PathSegment, Rect, Size, Tr #[derive(Debug, Hash, Eq, PartialEq, Clone)] struct Repr { content: Vec, - bbox: Rect, + bbox: RectWrapper, resource_dictionary: ResourceDictionary, } @@ -46,7 +46,7 @@ impl Stream { ) -> Self { Self(Arc::new(Repr { content, - bbox, + bbox: RectWrapper(bbox), resource_dictionary, })) } @@ -56,7 +56,7 @@ impl Stream { } pub(crate) fn bbox(&self) -> Rect { - self.0.bbox + self.0.bbox.0 } pub(crate) fn resource_dictionary(&self) -> &ResourceDictionary { @@ -66,7 +66,7 @@ impl Stream { pub fn empty() -> Self { Self(Arc::new(Repr { content: vec![], - bbox: Rect::from_xywh(0.0, 0.0, 0.0, 0.0).unwrap(), + bbox: RectWrapper(Rect::from_xywh(0.0, 0.0, 0.0, 0.0).unwrap()), resource_dictionary: ResourceDictionaryBuilder::new().finish(), })) } diff --git a/src/util.rs b/src/util.rs index b2961112..a801d94a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -7,7 +7,7 @@ use std::fmt; use std::fmt::Debug; use std::hash::{Hash, Hasher}; use std::ops::Deref; -use tiny_skia_path::{Path, PathBuilder, Rect}; +use tiny_skia_path::{FiniteF32, Path, PathBuilder, Rect, Size}; pub trait NameExt { fn to_pdf_name(&self) -> Name; @@ -202,3 +202,46 @@ where Some((key, head)) } } + +// TODO: Remove with new resvg release +#[derive(Copy, Clone, PartialEq, Debug)] +pub struct RectWrapper(pub Rect); + +impl Deref for RectWrapper { + type Target = Rect; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl Eq for RectWrapper {} + +impl Hash for RectWrapper { + fn hash(&self, state: &mut H) { + FiniteF32::new(self.0.left()).unwrap().hash(state); + FiniteF32::new(self.0.top()).unwrap().hash(state); + FiniteF32::new(self.0.right()).unwrap().hash(state); + FiniteF32::new(self.0.bottom()).unwrap().hash(state); + } +} + +#[derive(Copy, Clone, PartialEq, Debug)] +pub struct SizeWrapper(pub Size); + +impl Deref for SizeWrapper { + type Target = Size; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl Eq for SizeWrapper {} + +impl Hash for SizeWrapper { + fn hash(&self, state: &mut H) { + FiniteF32::new(self.0.width()).unwrap().hash(state); + FiniteF32::new(self.0.height()).unwrap().hash(state); + } +}