diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbd9be6..4ca55aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,8 +11,8 @@ env: jobs: - test: - name: Test + test-linux: + name: x86_64-unknown-linux-gnu runs-on: ubuntu-latest steps: - name: Checkout @@ -32,7 +32,7 @@ jobs: run: sudo apt-get update - name: Install dependencies - run: sudo apt-get install libx11-xcb-dev libxcb-shape0-dev libxcb-xfixes0-dev + run: sudo apt-get install libx11-xcb-dev libxcb-shape0-dev libxcb-xfixes0-dev libharfbuzz-dev - name: Cargo fmt uses: actions-rs/cargo@v1 @@ -56,3 +56,58 @@ jobs: with: command: test args: -- --nocapture + + test-windows: + name: x86_64-pc-windows-msvc + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + + - name: Cargo check + uses: actions-rs/cargo@v1 + with: + command: check + args: --no-default-features --features=bin + + - name: Cargo test + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features=bin -- --nocapture + + test-macos: + name: x86_64-apple-darwin + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + + - name: Cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + - name: Cargo test + uses: actions-rs/cargo@v1 + with: + command: test + args: -- --nocapture diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 791fb50..86fab98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: steps: - run: | sudo apt-get update - sudo apt-get install libx11-xcb-dev libxcb-shape0-dev libxcb-xfixes0-dev + sudo apt-get install libx11-xcb-dev libxcb-shape0-dev libxcb-xfixes0-dev libharfbuzz-dev - uses: actions/checkout@v2 with: fetch-depth: 1 @@ -95,7 +95,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: build - args: --release + args: --release --no-default-features --features=bin - id: get_name shell: bash run: | diff --git a/Cargo.lock b/Cargo.lock index 3dcbe19..0133214 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ab_glyph_rasterizer" -version = "0.1.4" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9fe5e32de01730eb1f6b7f5b51c17e03e2325bf40a74f754f04f130043affff" +checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "adler" @@ -14,26 +14,29 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] [[package]] name = "anyhow" -version = "1.0.40" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] [[package]] name = "atty" @@ -48,15 +51,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.13.0" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bincode" @@ -69,9 +72,15 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "block" @@ -81,21 +90,24 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "bytemuck" -version = "1.5.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bed57e2090563b83ba8f83366628ce535a7584c9afa4c9fc0612a03925c6df58" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.68" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -103,25 +115,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "term_size", "textwrap", @@ -153,9 +155,9 @@ dependencies = [ [[package]] name = "clipboard-win" -version = "4.2.1" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4ea1881992efc993e4dc50a324cdbd03216e41bdc8385720ff47efc9bd2ca8" +checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" dependencies = [ "error-code", "str-buf", @@ -164,20 +166,20 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.45" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" dependencies = [ "cc", ] [[package]] name = "cocoa" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63902e9223530efb4e26ccd0cf55ec30d592d3b42e21a28defc42a9586e832" +checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "cocoa-foundation", "core-foundation", @@ -189,15 +191,14 @@ dependencies = [ [[package]] name = "cocoa-foundation" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" +checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "core-foundation", "core-graphics-types", - "foreign-types", "libc", "objc", ] @@ -208,6 +209,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "const-cstr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6" + [[package]] name = "conv" version = "0.3.3" @@ -219,9 +226,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", @@ -229,17 +236,17 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "core-graphics" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "269f35f69b542b80e736a20a89a05215c0ce80c2c03c514abb2e318b78379d86" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-graphics-types", "foreign-types", @@ -248,13 +255,12 @@ dependencies = [ [[package]] name = "core-graphics-types" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", - "foreign-types", "libc", ] @@ -272,28 +278,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -302,25 +298,24 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ + "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", "memoffset", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", - "lazy_static", ] [[package]] @@ -330,20 +325,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" [[package]] -name = "deflate" -version = "0.8.6" +name = "deranged" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" dependencies = [ - "adler32", - "byteorder", + "powerfmt", ] [[package]] name = "dirs" -version = "3.0.2" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ "dirs-sys", ] @@ -360,9 +354,9 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", @@ -380,6 +374,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "dlib" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" +dependencies = [ + "libloading", +] + [[package]] name = "dwrote" version = "0.11.0" @@ -394,15 +397,15 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "env_logger" -version = "0.8.3" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", @@ -410,36 +413,55 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "error-code" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5115567ac25674e0043e472be13d14e537f37ea8aa4bdc4aef0c89add1db1ff" +checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" dependencies = [ "libc", "str-buf", ] [[package]] -name = "expat-sys" -version = "2.1.6" +name = "fastrand" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "fdeflate" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d6dafc854908ff5da46ff3f8f473c6984119a2876a383a860246dd7841a868" dependencies = [ - "cmake", - "pkg-config", + "simd-adler32", ] [[package]] name = "flate2" -version = "1.0.20" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ - "cfg-if", "crc32fast", - "libc", - "miniz_oxide 0.4.4", + "miniz_oxide", ] [[package]] @@ -456,11 +478,11 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "font-kit" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c9a156ec38864999bc9c4156e5f3b50224d4a5578028a64e5a3875caa9ee28" +checksum = "21fe28504d371085fae9ac7a3450f0b289ab71e07c8e57baa3fb68b9e57d6ce5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "core-foundation", "core-graphics", @@ -474,9 +496,9 @@ dependencies = [ "log", "pathfinder_geometry", "pathfinder_simd", - "servo-fontconfig", "walkdir", "winapi", + "yeslogic-fontconfig-sys", ] [[package]] @@ -528,13 +550,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -553,9 +575,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.9.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "heck" @@ -568,9 +590,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] @@ -583,15 +605,14 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "image" -version = "0.23.14" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1" +checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" dependencies = [ "bytemuck", "byteorder", "color_quant", "jpeg-decoder", - "num-iter", "num-rational", "num-traits", "png", @@ -599,51 +620,52 @@ dependencies = [ [[package]] name = "imageproc" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7923654f3ce7cb6849d5dc9e544aaeab49c508a90b56c721b046e7234c74ab53" +checksum = "b6aee993351d466301a29655d628bfc6f5a35a0d062b6160ca0808f425805fd7" dependencies = [ + "approx", "conv", "image", "itertools", - "num 0.3.1", - "rand 0.7.3", + "nalgebra", + "num", + "rand", "rand_distr", "rayon", - "rulinalg", "rusttype", ] [[package]] name = "indexmap" -version = "1.6.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ - "autocfg", + "equivalent", "hashbrown", ] [[package]] name = "itertools" -version = "0.9.0" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jpeg-decoder" -version = "0.1.22" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" dependencies = [ "rayon", ] @@ -655,16 +677,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] -name = "lazycell" -version = "1.3.0" +name = "libc" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] -name = "libc" -version = "0.2.96" +name = "libloading" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +dependencies = [ + "cfg-if", + "windows-sys", +] + +[[package]] +name = "libredox" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5600b4e6efc5421841a2138a6b082e07fe12f9aaa12783d50e5d13325b26b4fc" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] [[package]] name = "line-wrap" @@ -675,14 +712,23 @@ dependencies = [ "safemem", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" + [[package]] name = "log" -version = "0.4.14" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "malloc_buf" @@ -695,57 +741,59 @@ dependencies = [ [[package]] name = "matrixmultiply" -version = "0.1.15" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcad67dcec2d58ff56f6292582377e6921afdf3bfbd533e26fb8900ae575e002" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" dependencies = [ + "autocfg", "rawpointer", ] [[package]] -name = "memoffset" -version = "0.6.4" +name = "memchr" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" -dependencies = [ - "autocfg", -] +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] -name = "miniz_oxide" -version = "0.3.7" +name = "memoffset" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ - "adler32", + "autocfg", ] [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", - "autocfg", + "simd-adler32", ] [[package]] -name = "num" -version = "0.1.42" +name = "nalgebra" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" +checksum = "4fb2d0de08694bed883320212c18ee3008576bfe8c306f4c3c4a58b4876998be" dependencies = [ - "num-integer", - "num-iter", + "approx", + "matrixmultiply", + "num-complex", + "num-rational", "num-traits", + "simba", + "typenum", ] [[package]] name = "num" -version = "0.3.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" dependencies = [ "num-bigint", "num-complex", @@ -757,9 +805,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.3.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d0a3d5e207573f948a9e5376662aa743a2ea13f7c50a554d7af443a73fbfeba" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -768,18 +816,18 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.3.1" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ "num-traits", ] [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -787,9 +835,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" dependencies = [ "autocfg", "num-integer", @@ -798,9 +846,9 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", "num-bigint", @@ -810,23 +858,13 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "objc" version = "0.2.7" @@ -856,23 +894,29 @@ dependencies = [ "objc", ] +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + [[package]] name = "onig" -version = "6.1.1" +version = "6.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b46fd9edbc018f0be4e366c24c46db44fac49cd01c039ae85308088b089dd5" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" dependencies = [ - "bitflags", - "lazy_static", + "bitflags 1.3.2", "libc", + "once_cell", "onig_sys", ] [[package]] name = "onig_sys" -version = "69.6.0" +version = "69.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed063c96cf4c0f2e5d09324409d158b38a0a85a7b90fbd68c8cad75c495d5775" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" dependencies = [ "cc", "pkg-config", @@ -880,9 +924,9 @@ dependencies = [ [[package]] name = "os_info" -version = "3.0.6" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d2536ab8ff7605e8dc7044ec2f3eb0d49750cb559af9e5373c4564a3706cdd" +checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" dependencies = [ "log", "serde", @@ -891,13 +935,19 @@ dependencies = [ [[package]] name = "owned_ttf_parser" -version = "0.6.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f923fb806c46266c02ab4a5b239735c144bdeda724a50ed058e5226f594cde3" +checksum = "05e6affeb1632d6ff6a23d2cd40ffed138e82f1532571a26f527c8a284bb2fbb" dependencies = [ "ttf-parser", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "pasteboard" version = "0.1.3" @@ -922,58 +972,56 @@ dependencies = [ [[package]] name = "pathfinder_simd" -version = "0.5.1" -source = "git+https://github.com/servo/pathfinder#62fbfcc91cce8695c77ea3602a38ce11bccdfdb8" +version = "0.5.2" +source = "git+https://github.com/servo/pathfinder#a3ceb814cac4a817e2883da73df84c3eeddb70de" dependencies = [ "rustc_version", ] -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "plist" -version = "1.1.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "679104537029ed2287c216bfb942bbf723f48ee98f0aef15611634173a74ef21" +checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" dependencies = [ "base64", - "chrono", "indexmap", "line-wrap", + "quick-xml", "serde", - "xml-rs", + "time", ] [[package]] name = "png" -version = "0.16.8" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" +checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", - "deflate", - "miniz_oxide 0.3.7", + "fdeflate", + "flate2", + "miniz_oxide", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-error" @@ -984,7 +1032,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1001,45 +1049,42 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] -name = "quote" -version = "1.0.9" +name = "quick-xml" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" dependencies = [ - "proc-macro2", + "memchr", ] [[package]] -name = "rand" -version = "0.7.3" +name = "quote" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", + "proc-macro2", ] [[package]] name = "rand" -version = "0.8.3" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ + "getrandom 0.1.16", "libc", - "rand_chacha 0.3.0", - "rand_core 0.6.2", - "rand_hc 0.3.0", + "rand_chacha", + "rand_core", + "rand_hc", ] [[package]] @@ -1049,17 +1094,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.2", + "rand_core", ] [[package]] @@ -1071,22 +1106,13 @@ dependencies = [ "getrandom 0.1.16", ] -[[package]] -name = "rand_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" -dependencies = [ - "getrandom 0.2.3", -] - [[package]] name = "rand_distr" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96977acbdd3a6576fb1d27391900035bf3863d4a16422973a409b488cf29ffb2" dependencies = [ - "rand 0.7.3", + "rand", ] [[package]] @@ -1095,107 +1121,88 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_hc" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" -dependencies = [ - "rand_core 0.6.2", + "rand_core", ] [[package]] name = "rawpointer" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebac11a9d2e11f2af219b8b8d833b76b1ea0e054aa0e8d8e9e4cbde353bdf019" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.5.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "lazy_static", - "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.2.8" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ - "getrandom 0.2.3", - "redox_syscall", + "getrandom 0.2.11", + "libredox", + "thiserror", ] [[package]] name = "regex-syntax" -version = "0.6.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] -name = "rulinalg" -version = "0.4.2" +name = "rustc_version" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ada202c9685e1d72a7420c578e92b358dbf807d3dfabb676a3dab9cc3bb12f" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "matrixmultiply", - "num 0.1.42", + "semver", ] [[package]] -name = "rustc_version" -version = "0.3.3" +name = "rustix" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ - "semver", + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", ] [[package]] name = "rusttype" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc7c727aded0be18c5b80c1640eae0ac8e396abf6fa8477d96cb37d18ee5ec59" +checksum = "3ff8374aa04134254b7995b63ad3dc41c7f7236f69528b28553da7d72efaa967" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -1203,9 +1210,18 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "safe_arch" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" +dependencies = [ + "bytemuck", +] [[package]] name = "safemem" @@ -1224,93 +1240,60 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.126" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", "serde", ] -[[package]] -name = "servo-fontconfig" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c" -dependencies = [ - "libc", - "servo-fontconfig-sys", -] - -[[package]] -name = "servo-fontconfig-sys" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" -dependencies = [ - "expat-sys", - "freetype-sys", - "pkg-config", -] - [[package]] name = "shell-words" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "silicon" -version = "0.4.3" +version = "0.5.2" dependencies = [ "anyhow", "clipboard", - "clipboard-win 4.2.1", + "clipboard-win 4.5.0", "conv", "dirs", "env_logger", @@ -1329,11 +1312,30 @@ dependencies = [ "tempfile", ] +[[package]] +name = "simba" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3fd720c48c53cace224ae62bef1bbff363a70c68c4802a78b5cc6159618176" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] + +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "str-buf" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d44a3643b4ff9caf57abcee9c2c621d6c03d9135e0d8b589bd9afb5992cb176a" +checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" [[package]] name = "strsim" @@ -1343,9 +1345,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ "clap", "lazy_static", @@ -1354,61 +1356,71 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.14" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "syn" -version = "1.0.72" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syntect" -version = "4.5.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bfac2b23b4d049dc9a89353b4e06bbc85a8f42020cccbe5409a115cf19031e5" +checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" dependencies = [ "bincode", - "bitflags", + "bitflags 1.3.2", "flate2", "fnv", - "lazy_static", - "lazycell", + "once_cell", "onig", "plist", "regex-syntax", "serde", - "serde_derive", "serde_json", + "thiserror", "walkdir", + "yaml-rust", ] [[package]] name = "tempfile" -version = "3.2.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", - "libc", - "rand 0.8.3", + "fastrand", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys", ] [[package]] @@ -1423,9 +1435,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] @@ -1440,35 +1452,84 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "time" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +dependencies = [ + "time-core", +] + [[package]] name = "ttf-parser" -version = "0.6.2" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc" +checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd" [[package]] -name = "ucd-trie" -version = "0.1.3" +name = "typenum" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "unicode-segmentation" -version = "1.7.1" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "unicode-width" -version = "0.1.8" +name = "unicode-segmentation" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-width" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "vec_map" @@ -1478,18 +1539,17 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -1501,9 +1561,19 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wide" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" +dependencies = [ + "bytemuck", + "safe_arch", +] [[package]] name = "winapi" @@ -1523,9 +1593,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -1536,6 +1606,72 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "wio" version = "0.2.2" @@ -1565,7 +1701,22 @@ dependencies = [ ] [[package]] -name = "xml-rs" -version = "0.8.3" +name = "yaml-rust" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "yeslogic-fontconfig-sys" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2bbd69036d397ebbff671b1b8e4d918610c181c5a16073b96f984a38d08c386" +dependencies = [ + "const-cstr", + "dlib", + "once_cell", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index c480548..c6a4cdf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "silicon" -version = "0.4.3" +version = "0.5.2" description = "Create beautiful image of your code" authors = ["Aloxaf "] categories = ["command-line-utilities"] @@ -9,34 +9,36 @@ repository = "https://github.com/Aloxaf/silicon" license = "MIT" edition = "2018" +[features] +# bin fearure is required for silicon as a application +# disable it when using as a library +default = ["bin", "harfbuzz"] +bin = ["structopt", "env_logger", "anyhow", "shell-words"] +harfbuzz = ["harfbuzz-sys", "font-kit/loader-freetype-default", "font-kit/source-fontconfig-default"] + [dependencies] -dirs = "3.0" -imageproc = "0.22.0" +dirs = "4.0" +imageproc = "0.23.0" clipboard = "0.5.0" -tempfile = "3.1.0" +tempfile = "3.8.1" conv = "0.3.3" pathfinder_geometry = "0.5.1" -log = "0.4.11" +log = "0.4.20" lazy_static = "1.4.0" -shell-words = { version = "1.0.0", optional = true } -rayon = "1.5.1" - -[target.'cfg(target_os = "macos")'.dependencies] -pasteboard = "0.1.3" - -[target.'cfg(target_os = "windows")'.dependencies] -clipboard-win = "4.0.2" -image = { version = "0.23", default-features = false, features = ["jpeg", "bmp", "jpeg_rayon"] } +shell-words = { version = "1.1.0", optional = true } +rayon = "1.8.0" +font-kit = "0.11" +harfbuzz-sys = { version = "0.5.0", optional = true } [dependencies.image] -version = "0.23" +version = "0.24" default-features = false features = ["jpeg", "png", "jpeg_rayon"] [dependencies.syntect] -version = "4.4" +version = "5.1" default-features = false -features = ["parsing", "dump-load", "regex-onig"] +features = ["parsing", "dump-load", "regex-onig", "plist-load", "yaml-load"] [dependencies.anyhow] version = "1.0" @@ -49,23 +51,17 @@ features = ["color", "wrap_help"] optional = true [dependencies.env_logger] -version = "0.8.2" +version = "0.9.3" default-features = false features = ["termcolor", "atty", "humantime"] optional = true -[dependencies.font-kit] -version= "0.10" -features= ["loader-freetype-default", "source-fontconfig-default"] +[target.'cfg(target_os = "macos")'.dependencies] +pasteboard = "0.1.3" -[dependencies.harfbuzz-sys] -version="0.5.0" +[target.'cfg(target_os = "windows")'.dependencies] +clipboard-win = "4.5.0" +image = { version = "0.24", default-features = false, features = ["jpeg", "bmp", "jpeg_rayon"] } [patch.crates-io] pathfinder_simd = { version = "0.5.0", git = "https://github.com/servo/pathfinder" } - -[features] -# fearures required for silicon as a application -# disable it when using as a library -default = ["bin"] -bin = ["structopt", "env_logger", "anyhow", "shell-words"] diff --git a/LICENSE b/LICENSE index 4d4738c..7c678d2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019-2020 Aloxaf +Copyright (c) 2019-2023 Aloxaf Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 785b71f..1bc941d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Silicon is an alternative to [Carbon](https://github.com/dawnlabs/carbon) implem It can render your source code into a beautiful image. - + ## Why Silicon @@ -36,15 +36,14 @@ It's not as beautiful as Carbon... cargo install silicon ``` -### AUR +NOTE: harfbuzz feature is enabled by default. If you are using Windows, I suggest you disable it to get it build easier. -Silicon is available on AUR (Thanks to @radmen). +### AUR -You can install it with any AUR helpers you like. +Silicon is available in the official repository: -eg. ```bash -pikaur -S silicon +pacman -S silicon ``` ### Homebrew @@ -61,18 +60,22 @@ brew install silicon ```bash sudo apt install expat sudo apt install libxml2-dev -sudo apt install pkg-config libasound2-dev libssl-dev cmake libfreetype6-dev libexpat1-dev libxcb-composite0-dev +sudo apt install pkg-config libasound2-dev libssl-dev cmake libfreetype6-dev libexpat1-dev libxcb-composite0-dev libharfbuzz-dev ``` ### Fedora ```bash -sudo dnf install cmake expat-devel libxcb-devel freetype-devel libxml2-devel +sudo dnf install \ + cmake \ + expat-devel fontconfig-devel libxcb-devel \ + freetype-devel libxml2-devel \ + harfbuzz ``` ### Arch Linux ```bash -sudo pacman -S --needed pkgconf freetype2 fontconfig libxcb xclip +sudo pacman -S --needed pkgconf freetype2 fontconfig libxcb xclip harfbuzz ``` ## Examples @@ -121,13 +124,20 @@ The color can be `#RGB[A]` or `#RRGGBB[AA]` silicon ./target/test.rs -o test.png --background '#fff0' ``` +Show window title + +```bash +silicon ./target/test.rs -o test.png --window-title "target/test.rs" +``` + see `silicon --help` for detail ## Adding new syntaxes / themes -Silicon reads syntax-definition and theme cache from bat's cache directory. +Silicon reads syntax-definition and theme cache from user's cache directory. -You can find the steps to add new syntaxes / themes for bat here: [sharkdp/bat#adding-new-syntaxes--language-definitions](https://github.com/sharkdp/bat#adding-new-syntaxes--language-definitions). +The steps to add new syntaxes / themes is as same as bat: [sharkdp/bat#adding-new-syntaxes--language-definitions](https://github.com/sharkdp/bat#adding-new-syntaxes--language-definitions). +Just replace `bat cache --build` to `silicon --build-cache`. ## Configuration file @@ -146,3 +156,4 @@ Example: - [vim-silicon](https://github.com/segeljakt/vim-silicon) - [silicon.el](https://github.com/iensu/silicon-el) +- [silicon.lua](https://github.com/narutoxy/silicon.lua) diff --git a/assets/sync_from_bat.py b/assets/sync_from_bat.py deleted file mode 100644 index a0a255b..0000000 --- a/assets/sync_from_bat.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -# Sync themes and syntaxes from [bat](https://github.com/sharkdp/bat/tree/master/assets) - -import os -from glob import glob -from shutil import copy - -if not os.path.exists('../../bat'): - os.system('git clone https://github.com/sharkdp/bat ../../bat') -else: - os.system('git -C ../../bat pull') - -for syntax_file in glob('../../bat/assets/syntaxes/**/*.sublime-syntax'): - copy(syntax_file, './syntaxes/') - -for theme_file in glob('../../bat/assets/themes/**/*.tmTheme'): - copy(theme_file, './themes/') - -os.system('bat cache --build --source . --target .') - -print('Finished.') diff --git a/assets/sync_from_bat.sh b/assets/sync_from_bat.sh new file mode 100755 index 0000000..4d7b3f5 --- /dev/null +++ b/assets/sync_from_bat.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +if [[ -d ../../bat ]]; then + git -C ../../bat pull +else + git clone --recurse-submodules https://github.com/sharkdp/bat ../../bat +fi + +rm -rf ./syntaxes/* ./themes/* +cp -r ../../bat/assets/syntaxes/* ./syntaxes/ +cp -r ../../bat/assets/themes/* ./themes/ + +silicon --build-cache . + +echo Finished. \ No newline at end of file diff --git a/assets/syntaxes.bin b/assets/syntaxes.bin index 0f3b7f2..cc2641d 100644 Binary files a/assets/syntaxes.bin and b/assets/syntaxes.bin differ diff --git a/assets/themes.bin b/assets/themes.bin index b5a173e..6311878 100644 Binary files a/assets/themes.bin and b/assets/themes.bin differ diff --git a/assets/themes/Dracula.tmTheme b/assets/themes/Dracula.tmTheme deleted file mode 100644 index c3434ec..0000000 --- a/assets/themes/Dracula.tmTheme +++ /dev/null @@ -1,940 +0,0 @@ - - - - - - - - name - Dracula - settings - - - settings - - background - #282a36 - caret - #f8f8f0 - block_caret - #999a9e - foreground - #f8f8f2 - invisibles - #3B3A32 - lineHighlight - #44475a - selection - #44475a - findHighlight - #effb7b - findHighlightForeground - #000000 - selectionBorder - #222218 - activeGuide - #9D550FB0 - bracketsForeground - #F8F8F2A5 - bracketsOptions - underline - bracketContentsForeground - #F8F8F2A5 - bracketContentsOptions - underline - tagsOptions - stippled_underline - - - - name - Comment - scope - comment - settings - - foreground - #6272a4 - fontStyle - - - - - name - String - scope - string - settings - - foreground - #f1fa8c - - - - name - Number - scope - constant.numeric - settings - - foreground - #bd93f9 - - - - name - Built-in constant - scope - constant.language - settings - - foreground - #bd93f9 - - - - name - User-defined constant - scope - constant.character, constant.other - settings - - foreground - #bd93f9 - - - - name - Variable - scope - variable - settings - - fontStyle - - - - - name - Ruby's @variable - scope - variable.other.readwrite.instance - settings - - fontStyle - - foreground - #ffb86c - - - - name - String interpolation - scope - constant.character.escaped, constant.character.escape, string source, string source.ruby - settings - - fontStyle - - foreground - #ff79c6 - - - - name - Ruby Regexp - scope - source.ruby string.regexp.classic.ruby,source.ruby string.regexp.mod-r.ruby - settings - - fontStyle - - foreground - #ff5555 - - - - name - Keyword - scope - keyword - settings - - foreground - #ff79c6 - - - - name - Storage - scope - storage - settings - - fontStyle - - foreground - #ff79c6 - - - - name - Storage type - scope - storage.type - settings - - fontStyle - italic - foreground - #8be9fd - - - - name - Storage Type Namespace - scope - storage.type.namespace - settings - - fontStyle - italic - foreground - #8be9fd - - - - name - Storage Type Class - scope - storage.type.class - settings - - fontStyle - italic - foreground - #ff79c6 - - - - name - Class name - scope - entity.name.class - settings - - fontStyle - underline - foreground - #8be9fd - - - - name - Meta Path - scope - meta.path - settings - - fontStyle - underline - foreground - #66d9ef - - - - name - Inherited class - scope - entity.other.inherited-class - settings - - fontStyle - italic underline - foreground - #8be9fd - - - - name - Function name - scope - entity.name.function - settings - - fontStyle - - foreground - #50fa7b - - - - name - Function argument - scope - variable.parameter - settings - - fontStyle - italic - foreground - #ffb86c - - - - name - Tag name - scope - entity.name.tag - settings - - fontStyle - - foreground - #ff79c6 - - - - name - Tag attribute - scope - entity.other.attribute-name - settings - - fontStyle - - foreground - #50fa7b - - - - name - Library function - scope - support.function - settings - - fontStyle - - foreground - #8be9fd - - - - name - Library constant - scope - support.constant - settings - - fontStyle - - foreground - #6be5fd - - - - name - Library class/type - scope - support.type, support.class - settings - - fontStyle - italic - foreground - #66d9ef - - - - name - Library variable - scope - support.other.variable - settings - - fontStyle - - - - - name - Support Other Namespace - scope - support.other.namespace - settings - - fontStyle - italic - foreground - #66d9ef - - - - name - Invalid - scope - invalid - settings - - background - #ff79c6 - fontStyle - - foreground - #F8F8F0 - - - - name - Invalid deprecated - scope - invalid.deprecated - settings - - background - #bd93f9 - foreground - #F8F8F0 - - - - name - JSON String - scope - meta.structure.dictionary.json string.quoted.double.json - settings - - foreground - #CFCFC2 - - - - name - diff.header - scope - meta.diff, meta.diff.header - settings - - foreground - #6272a4 - - - - name - diff.deleted - scope - markup.deleted - settings - - foreground - #ff79c6 - - - - name - diff.inserted - scope - markup.inserted - settings - - foreground - #50fa7b - - - - name - diff.changed - scope - markup.changed - settings - - foreground - #E6DB74 - - - - scope - constant.numeric.line-number.find-in-files - match - settings - - foreground - #bd93f9 - - - - scope - entity.name.filename - settings - - foreground - #E6DB74 - - - - scope - message.error - settings - - foreground - #F83333 - - - - name - JSON Punctuation - scope - punctuation.definition.string.begin.json - meta.structure.dictionary.value.json, punctuation.definition.string.end.json - meta.structure.dictionary.value.json - settings - - foreground - #EEEEEE - - - - name - JSON Structure - scope - meta.structure.dictionary.json string.quoted.double.json - settings - - foreground - #8be9fd - - - - name - JSON String - scope - meta.structure.dictionary.value.json string.quoted.double.json - settings - - foreground - #f1fa8c - - - - name - JSON: 6 deep - scope - meta meta meta meta meta meta meta.structure.dictionary.value string - settings - - foreground - #50fa7b - - - - name - JSON: 5 deep - scope - meta meta meta meta meta meta.structure.dictionary.value string - settings - - foreground - #ffb86c - - - - name - JSON: 4 deep - scope - meta meta meta meta meta.structure.dictionary.value string - settings - - foreground - #ff79c6 - - - - name - JSON: 3 deep - scope - meta meta meta meta.structure.dictionary.value string - settings - - foreground - #bd93f9 - - - - name - JSON: 2 deep - scope - meta meta meta.structure.dictionary.value string - settings - - foreground - #50fa7b - - - - name - JSON: 1 deep - scope - meta meta.structure.dictionary.value string - settings - - foreground - #ffb86c - - - - - - name - Markup: strike - scope - markup.strike - settings - - fontStyle - italic - foreground - #FFB86C - - - - name - Markup: bold - scope - markup.bold - settings - - fontStyle - bold - foreground - #FFB86C - - - - name - Markup: italic - scope - markup.italic - settings - - fontStyle - italic - foreground - #FFB86C - - - - name - Markdown: heading - scope - markup.heading - settings - - foreground - #8BE9FD - - - - name - Markdown: List Items Punctuation - scope - punctuation.definition.list_item.markdown - settings - - foreground - #FF79C6 - - - - name - Markdown: Blockquote - scope - markup.quote - settings - - fontStyle - italic - foreground - #6272A4 - - - - name - Markdown: Blockquote Punctuation - scope - punctuation.definition.blockquote.markdown - settings - - fontStyle - italic - background - #6272A4 - foreground - #6272A4 - - - - name - Markdown: Separator - scope - meta.separator - settings - - foreground - #6272A4 - - - - name - Markup: raw inline - scope - text.html.markdown markup.raw.inline - settings - - foreground - #50FA7B - - - - name - Markup: underline - scope - markup.underline - settings - - fontStyle - underline - foreground - #BD93F9 - - - - name - Markup: Raw block - scope - markup.raw.block - settings - - foreground - #CFCFC2 - - - - name - Markdown: Raw Block fenced source - scope - markup.raw.block.fenced.markdown source - settings - - foreground - #F8F8F2 - - - - name - Markdown: Fenced Bode Block - scope - punctuation.definition.fenced.markdown, variable.language.fenced.markdown - settings - - fontStyle - italic - foreground - #6272A4 - - - - name - Markdown: Fenced Language - scope - variable.language.fenced.markdown - settings - - fontStyle - italic - foreground - #6272A4 - - - - name - Punctuation Accessor - scope - punctuation.accessor - settings - - foreground - #FF79C6 - - - - name - Meta Function Return Type - scope - meta.function.return-type - settings - - foreground - #FF79C6 - - - - name - Punctuation Section Block Begin - scope - punctuation.section.block.begin - settings - - foreground - #ffffff - - - - name - Punctuation Section Block End - scope - punctuation.section.block.end - settings - - foreground - #ffffff - - - - name - Punctuation Section Embedded Begin - scope - punctuation.section.embedded.begin - settings - - foreground - #ff79c6 - - - - name - Punctuation Section Embedded End - scope - punctuation.section.embedded.end - settings - - foreground - #ff79c6 - - - - name - Punctuation Separator Namespace - scope - punctuation.separator.namespace - settings - - foreground - #ff79c6 - - - - name - Variable Function - scope - variable.function - settings - - foreground - #50fa7b - - - - name - Variable Other - scope - variable.other - settings - - foreground - #ffffff - - - - name - Variable Language - scope - variable.language - settings - - foreground - #bd93f9 - - - - name - Entity Name Module Ruby - scope - entity.name.module.ruby - settings - - foreground - #8be9fd - - - - name - Entity Name Constant Ruby - scope - entity.name.constant.ruby - settings - - foreground - #bd93f9 - - - - name - Support Function Builtin Ruby - scope - support.function.builtin.ruby - settings - - foreground - #ffffff - - - - name - Storage Type Namespace CS - scope - storage.type.namespace.cs - settings - - foreground - #ff79c6 - - - - name - Entity Name Namespace CS - scope - entity.name.namespace.cs - settings - - foreground - #8be9fd - - - - uuid - 83091B89-765E-4F0D-9275-0EC6CB084126 - colorSpaceName - sRGB - semanticClass - theme.dracula - author - Zeno Rocha - - diff --git a/example/example.png b/example/example.png new file mode 100644 index 0000000..d7df881 Binary files /dev/null and b/example/example.png differ diff --git a/example/example.rs b/example/example.rs new file mode 100644 index 0000000..1e72f2c --- /dev/null +++ b/example/example.rs @@ -0,0 +1,10 @@ +fn factorial(n: u64) -> u64 { + match n { + 0 => 1, + _ => n * factorial(n - 1), + } +} + +fn main() { + println!("10! = {}", factorial(10)); +} \ No newline at end of file diff --git a/example/example.sh b/example/example.sh new file mode 100644 index 0000000..1b2d552 --- /dev/null +++ b/example/example.sh @@ -0,0 +1 @@ +silicon example.rs -o example.png diff --git a/src/assets.rs b/src/assets.rs new file mode 100644 index 0000000..6cae6ba --- /dev/null +++ b/src/assets.rs @@ -0,0 +1,53 @@ +use std::path::Path; + +use crate::directories::PROJECT_DIRS; +use anyhow::Result; +use syntect::dumps; +use syntect::highlighting::ThemeSet; +use syntect::parsing::SyntaxSet; + +const DEFAULT_SYNTAXSET: &[u8] = include_bytes!("../assets/syntaxes.bin"); +const DEFAULT_THEMESET: &[u8] = include_bytes!("../assets/themes.bin"); + +pub struct HighlightingAssets { + pub syntax_set: SyntaxSet, + pub theme_set: ThemeSet, +} + +impl Default for HighlightingAssets { + fn default() -> Self { + Self::new() + } +} + +impl HighlightingAssets { + pub fn new() -> Self { + Self::from_dump_file().unwrap_or_else(|_| Self { + syntax_set: dumps::from_binary(DEFAULT_SYNTAXSET), + theme_set: dumps::from_binary(DEFAULT_THEMESET), + }) + } + + pub fn from_dump_file() -> Result { + let cache_dir = PROJECT_DIRS.cache_dir(); + Ok(Self { + syntax_set: dumps::from_dump_file(cache_dir.join("syntaxes.bin"))?, + theme_set: dumps::from_dump_file(cache_dir.join("themes.bin"))?, + }) + } + + pub fn add_from_folder>(&mut self, path: P) -> Result<()> { + let path = path.as_ref(); + self.theme_set.add_from_folder(path.join("themes"))?; + let mut builder = self.syntax_set.clone().into_builder(); + builder.add_from_folder(path.join("syntaxes"), true)?; + self.syntax_set = builder.build(); + Ok(()) + } + + pub fn dump_to_file>(&self, path: P) -> Result<()> { + dumps::dump_to_file(&self.syntax_set, path.as_ref().join("syntaxes.bin"))?; + dumps::dump_to_file(&self.theme_set, path.as_ref().join("themes.bin"))?; + Ok(()) + } +} diff --git a/src/bin/silicon/config.rs b/src/bin/silicon/config.rs index 1ea40e6..516dde3 100644 --- a/src/bin/silicon/config.rs +++ b/src/bin/silicon/config.rs @@ -30,7 +30,7 @@ pub fn get_args_from_config_file() -> Vec { .split('\n') .map(|line| line.trim()) .filter(|line| !line.starts_with('#') && !line.is_empty()) - .map(|line| shell_words::split(line)) + .map(shell_words::split) .collect::, _>>() .ok() }) @@ -39,8 +39,8 @@ pub fn get_args_from_config_file() -> Vec { } fn parse_str_color(s: &str) -> Result, Error> { - Ok(s.to_rgba() - .map_err(|_| format_err!("Invalid color: `{}`", s))?) + s.to_rgba() + .map_err(|_| format_err!("Invalid color: `{}`", s)) } fn parse_font_str(s: &str) -> Vec<(String, f32)> { @@ -142,7 +142,7 @@ pub struct Config { short, long, value_name = "PATH", - required_unless_one = &["config-file", "list-fonts", "list-themes", "to-clipboard"] + required_unless_one = &["config-file", "list-fonts", "list-themes", "to-clipboard", "build-cache"] )] pub output: Option, @@ -150,6 +150,10 @@ pub struct Config { #[structopt(long)] pub no_window_controls: bool, + /// Show window title + #[structopt(long, value_name = "WINDOW_TITLE")] + pub window_title: Option, + /// Hide the line number. #[structopt(long)] pub no_line_number: bool, @@ -195,12 +199,15 @@ pub struct Config { #[structopt(long, value_name = "THEME", default_value = "Dracula")] pub theme: String, - // Copy the output image to clipboard. + /// Copy the output image to clipboard. #[structopt(short = "c", long)] pub to_clipboard: bool, // Draw a custom text on the bottom right corner // #[structopt(long)] // watermark: Option, + /// build syntax definition and theme cache + #[structopt(long, value_name = "OUTPUT_DIR")] + pub build_cache: Option>, } impl Config { @@ -266,10 +273,10 @@ impl Config { let formatter = ImageFormatterBuilder::new() .line_pad(self.line_pad) .window_controls(!self.no_window_controls) + .window_title(self.window_title.clone()) .line_number(!self.no_line_number) .font(self.font.clone().unwrap_or_default()) .round_corner(!self.no_round_corner) - .window_controls(!self.no_window_controls) .shadow_adder(self.get_shadow_adder()?) .tab_width(self.tab_width) .highlight_lines(self.highlight_lines.clone().unwrap_or_default()) @@ -298,7 +305,7 @@ impl Config { if let (Ok(home_dir), true) = (std::env::var("HOME"), need_expand) { self.output .as_ref() - .map(|p| p.to_string_lossy().replacen("~", &home_dir, 1).into()) + .map(|p| p.to_string_lossy().replacen('~', &home_dir, 1).into()) } else { self.output.clone() } diff --git a/src/bin/silicon/main.rs b/src/bin/silicon/main.rs index 1e917be..93dff16 100644 --- a/src/bin/silicon/main.rs +++ b/src/bin/silicon/main.rs @@ -3,6 +3,7 @@ extern crate anyhow; use anyhow::Error; use image::DynamicImage; +use std::env; use structopt::StructOpt; use syntect::easy::HighlightLines; use syntect::util::LinesWithEndings; @@ -13,28 +14,54 @@ use { }; #[cfg(target_os = "macos")] use {image::ImageOutputFormat, pasteboard::Pasteboard}; + #[cfg(target_os = "linux")] use {image::ImageOutputFormat, std::process::Command}; mod config; -use crate::config::{config_file, get_args_from_config_file}; -use config::Config; -use silicon::utils::init_syntect; +use crate::config::{config_file, get_args_from_config_file, Config}; +use silicon::assets::HighlightingAssets; +use silicon::directories::PROJECT_DIRS; #[cfg(target_os = "linux")] pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> { - let mut temp = tempfile::NamedTempFile::new()?; - image.write_to(&mut temp, ImageOutputFormat::Png)?; - Command::new("xclip") - .args(&[ - "-sel", - "clip", - "-t", - "image/png", - temp.path().to_str().unwrap(), - ]) - .status() - .map_err(|e| format_err!("Failed to copy image to clipboard: {}", e))?; + use std::io::{Cursor, Write}; + + match std::env::var(r#"XDG_SESSION_TYPE"#).ok() { + Some(x) if x == "wayland" => { + let mut command = Command::new("wl-copy") + .args(["--type", "image/png"]) + .stdin(std::process::Stdio::piped()) + .spawn()?; + + let mut cursor = Cursor::new(Vec::new()); + image.write_to(&mut cursor, ImageOutputFormat::Png)?; + + { + let stdin = command.stdin.as_mut().unwrap(); + stdin.write_all(cursor.get_ref())?; + } + + command + .wait() + .map_err(|e| format_err!("Failed to copy image to clipboard: {}", e))?; + } + _ => { + let mut temp = tempfile::NamedTempFile::new()?; + image.write_to(&mut temp, ImageOutputFormat::Png)?; + + Command::new(r#"xclip"#) + .args([ + "-sel", + "clip", + "-t", + "image/png", + temp.path().to_str().unwrap(), + ]) + .status() + .map_err(|e| format_err!("Failed to copy image to clipboard: {} (Tip: do you have xclip installed ?)", e))?; + } + }; Ok(()) } @@ -50,11 +77,11 @@ pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> { #[cfg(target_os = "windows")] pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> { - let mut temp: Vec = Vec::new(); + let mut temp = std::io::Cursor::new(Vec::new()); // Convert the image to RGB without alpha because the clipboard // of windows doesn't support it. - let image = DynamicImage::ImageRgb8(image.to_rgb()); + let image = DynamicImage::ImageRgb8(image.to_rgb8()); image.write_to(&mut temp, ImageOutputFormat::Bmp)?; @@ -62,7 +89,7 @@ pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> { Clipboard::new_attempts(10).map_err(|e| format_err!("Couldn't open clipboard: {}", e))?; formats::Bitmap - .write_clipboard(&temp) + .write_clipboard(temp.get_ref()) .map_err(|e| format_err!("Failed copy image: {}", e))?; Ok(()) } @@ -81,9 +108,19 @@ fn run() -> Result<(), Error> { args.extend(args_cli); let config: Config = Config::from_iter(args); - let (ps, ts) = init_syntect(); + let ha = HighlightingAssets::new(); + let (ps, ts) = (ha.syntax_set, ha.theme_set); - if config.list_themes { + if let Some(path) = config.build_cache { + let mut ha = HighlightingAssets::new(); + ha.add_from_folder(env::current_dir()?)?; + if let Some(path) = path { + ha.dump_to_file(path)?; + } else { + ha.dump_to_file(PROJECT_DIRS.cache_dir())?; + } + return Ok(()); + } else if config.list_themes { for i in ts.themes.keys() { println!("{}", i); } @@ -105,8 +142,8 @@ fn run() -> Result<(), Error> { let mut h = HighlightLines::new(syntax, &theme); let highlight = LinesWithEndings::from(&code) - .map(|line| h.highlight(line, &ps)) - .collect::>(); + .map(|line| h.highlight_line(line, &ps)) + .collect::, _>>()?; let mut formatter = config.get_formatter()?; diff --git a/src/blur.rs b/src/blur.rs index 32415da..b9c011f 100644 --- a/src/blur.rs +++ b/src/blur.rs @@ -9,11 +9,12 @@ use image::RgbaImage; use rayon::prelude::*; #[derive(Copy, Clone)] -struct SharedMutPtr<>(*mut [[u8; 4]]); +struct SharedMutPtr(*mut [[u8; 4]]); unsafe impl Sync for SharedMutPtr {} impl SharedMutPtr { + #[allow(clippy::mut_from_ref)] unsafe fn get(&self) -> &mut [[u8; 4]] { &mut *self.0 } @@ -37,9 +38,9 @@ pub fn gaussian_blur(image: RgbaImage, sigma: f32) -> RgbaImage { RgbaImage::from_raw(width, height, raw).unwrap() } -fn gaussian_blur_impl(data: &mut Vec<[u8; 4]>, width: usize, height: usize, blur_radius: f32) { +fn gaussian_blur_impl(data: &mut [[u8; 4]], width: usize, height: usize, blur_radius: f32) { let bxs = create_box_gauss(blur_radius, 3); - let mut backbuf = data.clone(); + let mut backbuf = data.to_vec(); box_blur( &mut backbuf, @@ -102,8 +103,8 @@ fn create_box_gauss(sigma: f32, n: usize) -> Vec { /// Needs 2x the same image #[inline] fn box_blur( - backbuf: &mut Vec<[u8; 4]>, - frontbuf: &mut Vec<[u8; 4]>, + backbuf: &mut [[u8; 4]], + frontbuf: &mut [[u8; 4]], width: usize, height: usize, blur_radius: usize, diff --git a/src/directories.rs b/src/directories.rs index a098c63..407da43 100644 --- a/src/directories.rs +++ b/src/directories.rs @@ -1,5 +1,6 @@ use lazy_static::lazy_static; use std::env; +use std::fs::create_dir_all; use std::path::{Path, PathBuf}; pub struct SiliconProjectDirs { @@ -22,16 +23,18 @@ impl SiliconProjectDirs { let config_dir = config_dir_op.map(|d| d.join("silicon"))?; + create_dir_all(&config_dir).expect("cannot create config dir"); + create_dir_all(&cache_dir).expect("cannot create cache dir"); + Some(Self { cache_dir, config_dir, }) } - // silicon use bat's cache directory fn get_cache_dir() -> Option { - // on all OS prefer BAT_CACHE_PATH if set - let cache_dir_op = env::var_os("BAT_CACHE_PATH").map(PathBuf::from); + // on all OS prefer SILICON_CACHE_PATH if set + let cache_dir_op = env::var_os("SILICON_CACHE_PATH").map(PathBuf::from); if cache_dir_op.is_some() { return cache_dir_op; } @@ -45,7 +48,7 @@ impl SiliconProjectDirs { #[cfg(not(target_os = "macos"))] let cache_dir_op = dirs::cache_dir(); - cache_dir_op.map(|d| d.join("bat")) + cache_dir_op.map(|d| d.join("silicon")) } pub fn cache_dir(&self) -> &Path { diff --git a/src/font.rs b/src/font.rs index c0a11e3..7f8e43c 100644 --- a/src/font.rs +++ b/src/font.rs @@ -12,6 +12,7 @@ //! font.draw_text_mut(&mut image, Rgb([255, 0, 0]), 0, 0, FontStyle::REGULAR, "Hello, world"); //! ``` use crate::error::FontError; +#[cfg(feature = "harfbuzz")] use crate::hb_wrapper::{feature_from_tag, HBBuffer, HBFont}; use anyhow::Result; use conv::ValueInto; @@ -193,6 +194,17 @@ impl FontCollection { Ok(Self(fonts)) } + fn glyph_for_char(&self, c: char, style: FontStyle) -> Option<(u32, &ImageFont, &Font)> { + for font in &self.0 { + let result = font.get_by_style(style); + if let Some(id) = result.glyph_for_char(c) { + return Some((id, font, result)); + } + } + eprintln!("[warning] No font found for character `{}`", c); + None + } + /// get max height of all the fonts pub fn get_font_height(&self) -> u32 { self.0 @@ -202,6 +214,7 @@ impl FontCollection { .unwrap() } + #[cfg(feature = "harfbuzz")] fn shape_text(&self, font: &mut HBFont, text: &str) -> Result> { // feature tags let features = vec![ @@ -221,19 +234,34 @@ impl FontCollection { Ok(glyph_ids) } + #[cfg(feature = "harfbuzz")] + fn split_by_font(&self, text: &str, style: FontStyle) -> Vec<(&ImageFont, &Font, String)> { + let mut result: Vec<(&ImageFont, &Font, String)> = vec![]; + for c in text.chars() { + if let Some((_, imfont, font)) = self.glyph_for_char(c, style) { + if result.is_empty() || !std::ptr::eq(result.last().unwrap().0, imfont) { + result.push((imfont, font, String::new())); + } + if std::ptr::eq(result.last().unwrap().0, imfont) { + result.last_mut().unwrap().2.push(c); + } + } + } + log::trace!("{:#?}", &result); + result + } + + #[cfg(feature = "harfbuzz")] fn layout(&self, text: &str, style: FontStyle) -> (Vec, u32) { let mut delta_x = 0; let height = self.get_font_height(); - let imfont = self.0.get(0).unwrap(); - let font = imfont.get_by_style(style); - let mut hb_font = HBFont::new(font); - // apply font features especially ligature with a shape engine - let shaped_glyphs = self.shape_text(&mut hb_font, text).unwrap(); - - let glyphs = shaped_glyphs - .iter() - .map(|id| { + let mut glyphs = Vec::with_capacity(text.len()); + for (imfont, font, text) in self.split_by_font(text, style) { + let mut hb_font = HBFont::new(font); + // apply font features especially ligature with a shape engine + let shaped_glyphs = self.shape_text(&mut hb_font, &text).unwrap(); + glyphs.extend(shaped_glyphs.iter().map(|id| { let raster_rect = font .raster_bounds( *id, @@ -253,6 +281,42 @@ impl FontCollection { raster_rect, position, } + })) + } + + (glyphs, delta_x) + } + + #[cfg(not(feature = "harfbuzz"))] + fn layout(&self, text: &str, style: FontStyle) -> (Vec, u32) { + let mut delta_x = 0; + let height = self.get_font_height(); + + let glyphs = text + .chars() + .filter_map(|c| { + self.glyph_for_char(c, style).map(|(id, imfont, font)| { + let raster_rect = font + .raster_bounds( + id, + imfont.size, + Transform2F::default(), + HintingOptions::None, + RasterizationOptions::GrayscaleAa, + ) + .unwrap(); + let position = + Vector2I::new(delta_x as i32, height as i32) + raster_rect.origin(); + delta_x += Self::get_glyph_width(font, id, imfont.size); + + PositionedGlyph { + id, + font: font.clone(), + size: imfont.size, + raster_rect, + position, + } + }) }) .collect(); diff --git a/src/formatter.rs b/src/formatter.rs index b021300..7a6c3f3 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -15,6 +15,19 @@ pub struct ImageFormatter { /// pad of top of the code area /// Default: 50 code_pad_top: u32, + /// Title bar padding + /// Default: 15 + title_bar_pad: u32, + /// Whether to show window controls or not + window_controls: bool, + /// Width for window controls + /// Default: 120 + window_controls_width: u32, + /// Height for window controls + /// Default: 40 + window_controls_height: u32, + /// Window title + window_title: Option, /// show line number /// Default: true line_number: bool, @@ -52,6 +65,8 @@ pub struct ImageFormatterBuilder { highlight_lines: Vec, /// Whether show the window controls window_controls: bool, + /// Window title + window_title: Option, /// Whether round the corner of the image round_corner: bool, /// Shadow adder, @@ -69,6 +84,7 @@ impl + Default> ImageFormatterBuilder { line_pad: 2, line_number: true, window_controls: true, + window_title: None, round_corner: true, tab_width: 4, ..Default::default() @@ -105,6 +121,12 @@ impl + Default> ImageFormatterBuilder { self } + /// Window title + pub fn window_title(mut self, title: Option) -> Self { + self.window_title = title; + self + } + /// Whether round the corner pub fn round_corner(mut self, b: bool) -> Self { self.round_corner = b; @@ -136,11 +158,17 @@ impl + Default> ImageFormatterBuilder { FontCollection::new(&self.font)? }; - let code_pad_top = if self.window_controls { 50 } else { 0 }; + let title_bar = self.window_controls || self.window_title.is_some(); Ok(ImageFormatter { line_pad: self.line_pad, code_pad: 25, + code_pad_top: if title_bar { 50 } else { 0 }, + title_bar_pad: 15, + window_controls: self.window_controls, + window_controls_width: 120, + window_controls_height: 40, + window_title: self.window_title, line_number: self.line_number, line_number_pad: 6, line_number_chars: 0, @@ -148,7 +176,6 @@ impl + Default> ImageFormatterBuilder { round_corner: self.round_corner, shadow_adder: self.shadow_adder, tab_width: self.tab_width, - code_pad_top, font, line_offset: self.line_offset, }) @@ -161,7 +188,7 @@ struct Drawable { /// max number of line of the picture max_lineno: u32, /// arguments for draw_text_mut - drawables: Vec<(u32, u32, Color, FontStyle, String)>, + drawables: Vec<(u32, u32, Option, FontStyle, String)>, } impl ImageFormatter { @@ -214,7 +241,7 @@ impl ImageFormatter { drawables.push(( width, height, - style.foreground, + Some(style.foreground), style.font_style.into(), text.to_owned(), )); @@ -226,6 +253,29 @@ impl ImageFormatter { max_lineno = i as u32; } + if self.window_title.is_some() { + let title = self.window_title.as_ref().unwrap(); + let title_width = self.font.get_text_len(title); + + let ctrls_offset = if self.window_controls { + self.window_controls_width + self.title_bar_pad + } else { + 0 + }; + let ctrls_center = self.window_controls_height / 2; + + drawables.push(( + ctrls_offset + self.title_bar_pad, + self.title_bar_pad + ctrls_center - self.font.get_font_height() / 2, + None, + FontStyle::BOLD, + title.to_string(), + )); + + let title_bar_width = ctrls_offset + title_width + self.title_bar_pad * 2; + max_width = max_width.max(title_bar_width); + } + Drawable { max_width, max_lineno, @@ -288,10 +338,8 @@ impl ImageFormatter { let foreground = theme.settings.foreground.unwrap(); let background = theme.settings.background.unwrap(); - let foreground = foreground.to_rgba(); - let background = background.to_rgba(); - - let mut image = DynamicImage::ImageRgba8(RgbaImage::from_pixel(size.0, size.1, background)); + let mut image = + DynamicImage::ImageRgba8(RgbaImage::from_pixel(size.0, size.1, background.to_rgba())); if !self.highlight_lines.is_empty() { let highlight_lines = self @@ -302,18 +350,23 @@ impl ImageFormatter { self.highlight_lines(&mut image, highlight_lines); } if self.line_number { - self.draw_line_number(&mut image, drawables.max_lineno, foreground); + self.draw_line_number(&mut image, drawables.max_lineno, foreground.to_rgba()); } for (x, y, color, style, text) in drawables.drawables { - let color = color.to_rgba(); + let color = color.unwrap_or(foreground).to_rgba(); self.font .draw_text_mut(&mut image, color, x, y, style, &text); } - // draw_window_controls == true - if self.code_pad_top != 0 { - add_window_controls(&mut image); + if self.window_controls { + let params = WindowControlsParams { + width: self.window_controls_width, + height: self.window_controls_height, + padding: self.title_bar_pad, + radius: self.window_controls_width / 3 / 4, + }; + add_window_controls(&mut image, ¶ms); } if self.round_corner { diff --git a/src/hb_wrapper.rs b/src/hb_wrapper.rs index 771254f..7d3bee0 100644 --- a/src/hb_wrapper.rs +++ b/src/hb_wrapper.rs @@ -14,7 +14,7 @@ pub fn feature_from_tag(tag: &str) -> Result { let mut feature = mem::zeroed(); ensure!( hb_feature_from_string( - tag.as_ptr() as *const i8, + tag.as_ptr() as *const ::std::os::raw::c_char, tag.len() as i32, &mut feature as *mut _ ) != 0, @@ -88,7 +88,7 @@ impl HBBuffer { unsafe { hb_buffer_add_utf8( self.buffer, - s.as_ptr() as *const i8, + s.as_ptr() as *const ::std::os::raw::c_char, s.len() as i32, 0, s.len() as i32, diff --git a/src/lib.rs b/src/lib.rs index a9076dc..67551d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,10 +5,12 @@ //! ``` //! use syntect::easy::HighlightLines; //! use syntect::util::LinesWithEndings; -//! use silicon::utils::{init_syntect, ShadowAdder}; +//! use silicon::utils::ShadowAdder; //! use silicon::formatter::ImageFormatterBuilder; +//! use silicon::assets::HighlightingAssets; //! -//! let (ps, ts) = init_syntect(); +//! let ha = HighlightingAssets::new(); +//! let (ps, ts) = (ha.syntax_set, ha.theme_set); //! let code = r#"fn main() { //! println!("Hello, world!"); //! } @@ -19,8 +21,9 @@ //! //! let mut h = HighlightLines::new(syntax, theme); //! let highlight = LinesWithEndings::from(&code) -//! .map(|line| h.highlight(line, &ps)) -//! .collect::>(); +//! .map(|line| h.highlight_line(line, &ps)) +//! .collect::, _>>() +//! .unwrap(); //! //! let mut formatter = ImageFormatterBuilder::new() //! .font(vec![("Hack", 26.0)]) @@ -34,10 +37,12 @@ #[macro_use] extern crate log; +pub mod assets; pub mod blur; pub mod directories; pub mod error; pub mod font; pub mod formatter; +#[cfg(feature = "harfbuzz")] pub mod hb_wrapper; pub mod utils; diff --git a/src/utils.rs b/src/utils.rs index d013e46..7a27824 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,39 +1,9 @@ -use crate::directories::PROJECT_DIRS; use crate::error::ParseColorError; -use image::imageops::{crop, resize, FilterType}; +use image::imageops::{crop_imm, resize, FilterType}; use image::Pixel; use image::{DynamicImage, GenericImage, GenericImageView, Rgba, RgbaImage}; use imageproc::drawing::{draw_filled_rect_mut, draw_line_segment_mut}; use imageproc::rect::Rect; -use syntect::dumps; -use syntect::highlighting::ThemeSet; -use syntect::parsing::SyntaxSet; - -pub fn read_from_bat_cache() -> Option<(SyntaxSet, ThemeSet)> { - let cache_dir = PROJECT_DIRS.cache_dir(); - let syntax_cache = cache_dir.join("syntaxes.bin"); - let theme_cache = cache_dir.join("themes.bin"); - if syntax_cache.exists() && theme_cache.exists() { - if let (Ok(a), Ok(b)) = ( - dumps::from_dump_file(syntax_cache), - dumps::from_dump_file(theme_cache), - ) { - return Some((a, b)); - } - } - None -} - -/// Load the default SyntaxSet and ThemeSet. -pub fn init_syntect() -> (SyntaxSet, ThemeSet) { - // try to use bat's cache - read_from_bat_cache().unwrap_or_else(|| { - ( - dumps::from_binary(include_bytes!("../assets/syntaxes.bin")), - dumps::from_binary(include_bytes!("../assets/themes.bin")), - ) - }) -} pub trait ToRgba { type Target; @@ -96,8 +66,15 @@ impl ToRgba for syntect::highlighting::Color { } } +pub struct WindowControlsParams { + pub width: u32, + pub height: u32, + pub padding: u32, + pub radius: u32, +} + /// Add the window controls for image -pub(crate) fn add_window_controls(image: &mut DynamicImage) { +pub(crate) fn add_window_controls(image: &mut DynamicImage, params: &WindowControlsParams) { let color = [ ("#FF5F56", "#E0443E"), ("#FFBD2E", "#DEA123"), @@ -107,27 +84,40 @@ pub(crate) fn add_window_controls(image: &mut DynamicImage) { let mut background = image.get_pixel(37, 37); background.0[3] = 0; - let mut title_bar = RgbaImage::from_pixel(120 * 3, 40 * 3, background); + let mut title_bar = RgbaImage::from_pixel(params.width * 3, params.height * 3, background); + let step = (params.radius * 2) as i32; + let spacer = step * 2; + let center_y = (params.height / 2) as i32; for (i, (fill, outline)) in color.iter().enumerate() { draw_filled_circle_mut( &mut title_bar, - (((i * 40) as i32 + 20) * 3, 20 * 3), - 11 * 3, + ((i as i32 * spacer + step) * 3, center_y * 3), + (params.radius + 1) as i32 * 3, outline.to_rgba().unwrap(), ); draw_filled_circle_mut( &mut title_bar, - (((i * 40) as i32 + 20) * 3, 20 * 3), - 10 * 3, + ((i as i32 * spacer + step) * 3, center_y * 3), + params.radius as i32 * 3, fill.to_rgba().unwrap(), ); } // create a big image and resize it to blur the edge // it looks better than `blur()` - let title_bar = resize(&title_bar, 120, 40, FilterType::Triangle); + let title_bar = resize( + &title_bar, + params.width, + params.height, + FilterType::Triangle, + ); - copy_alpha(&title_bar, image.as_mut_rgba8().unwrap(), 15, 15); + copy_alpha( + &title_bar, + image.as_mut_rgba8().unwrap(), + params.padding, + params.padding, + ); } #[derive(Clone, Debug)] @@ -279,34 +269,51 @@ pub(crate) fn copy_alpha(src: &RgbaImage, dst: &mut RgbaImage, x: u32, y: u32) { pub(crate) fn round_corner(image: &mut DynamicImage, radius: u32) { // draw a circle with given foreground on given background // then split it into four pieces and paste them to the four corner of the image + // + // the circle is drawn on a bigger image to avoid the aliasing + // later it will be scaled to the correct size + // we add +1 (to the radius) to make sure that there is also space for the border to mitigate artefacts when scaling + // note that the +1 isn't added to the radius when drawing the circle let mut circle = - RgbaImage::from_pixel(radius * 2 + 1, radius * 2 + 1, Rgba([255, 255, 255, 0])); + RgbaImage::from_pixel((radius + 1) * 4, (radius + 1) * 4, Rgba([255, 255, 255, 0])); let width = image.width(); let height = image.height(); + // use the bottom right pixel to get the color of the foreground let foreground = image.get_pixel(width - 1, height - 1); - // TODO: need a blur on edge draw_filled_circle_mut( &mut circle, - (radius as i32, radius as i32), - radius as i32, + (((radius + 1) * 2) as i32, ((radius + 1) * 2) as i32), + radius as i32 * 2, foreground, ); - let part = crop(&mut circle, 0, 0, radius, radius); - image.copy_from(&part, 0, 0).unwrap(); + // scale down the circle to the correct size + let circle = resize( + &circle, + (radius + 1) * 2, + (radius + 1) * 2, + FilterType::Triangle, + ); + + // top left + let part = crop_imm(&circle, 1, 1, radius, radius); + image.copy_from(&*part, 0, 0).unwrap(); - let part = crop(&mut circle, radius + 1, 0, radius, radius); - image.copy_from(&part, width - radius, 0).unwrap(); + // top right + let part = crop_imm(&circle, radius + 1, 1, radius, radius - 1); + image.copy_from(&*part, width - radius, 0).unwrap(); - let part = crop(&mut circle, 0, radius + 1, radius, radius); - image.copy_from(&part, 0, height - radius).unwrap(); + // bottom left + let part = crop_imm(&circle, 1, radius + 1, radius, radius); + image.copy_from(&*part, 0, height - radius).unwrap(); - let part = crop(&mut circle, radius + 1, radius + 1, radius, radius); + // bottom right + let part = crop_imm(&circle, radius + 1, radius + 1, radius, radius); image - .copy_from(&part, width - radius, height - radius) + .copy_from(&*part, width - radius, height - radius) .unwrap(); }