diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbd9be6..2157140 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 @@ -24,7 +24,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: stable components: rustfmt, clippy override: true @@ -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: stable + 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: stable + 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/.gitignore b/.gitignore index 5ff26f3..810d9ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target **/*.rs.bk /.idea -.vscode \ No newline at end of file +.vscode +hello.png diff --git a/Cargo.lock b/Cargo.lock index 3dcbe19..5c0816c 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" @@ -15,25 +15,83 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] -name = "adler32" -version = "1.2.0" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[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 = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" -version = "1.0.40" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" + +[[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 +106,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base64" -version = "0.13.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bincode" @@ -69,9 +127,15 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block" @@ -81,21 +145,24 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "bytemuck" -version = "1.5.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bed57e2090563b83ba8f83366628ce535a7584c9afa4c9fc0612a03925c6df58" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[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.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -103,25 +170,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,31 +210,20 @@ dependencies = [ [[package]] name = "clipboard-win" -version = "4.2.1" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4ea1881992efc993e4dc50a324cdbd03216e41bdc8385720ff47efc9bd2ca8" +checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" dependencies = [ "error-code", - "str-buf", - "winapi", -] - -[[package]] -name = "cmake" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" -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 +235,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 +253,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "conv" version = "0.3.3" @@ -219,9 +270,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -229,17 +280,17 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.2" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[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 +299,12 @@ dependencies = [ [[package]] name = "core-graphics-types" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", - "foreign-types", "libc", ] @@ -272,55 +322,46 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", - "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.0" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "cstr" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68523903c8ae5aacfa32a0d9ae60cadeb764e1da14ee0d26b1f3089f13a54636" dependencies = [ - "cfg-if", - "lazy_static", + "proc-macro2", + "quote", ] [[package]] @@ -330,20 +371,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.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ - "adler32", - "byteorder", + "powerfmt", ] [[package]] name = "dirs" -version = "3.0.2" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ "dirs-sys", ] @@ -360,13 +400,14 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -380,11 +421,20 @@ 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" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" +checksum = "2da3498378ed373237bdef1eddcc64e7be2d3ba4841f4c22a998e81cadeea83c" dependencies = [ "lazy_static", "libc", @@ -394,59 +444,84 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "env_filter" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +dependencies = [ + "log", +] [[package]] name = "env_logger" -version = "0.8.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ - "atty", + "anstream", + "anstyle", + "env_filter", "humantime", "log", - "termcolor", ] [[package]] -name = "error-code" -version = "2.3.0" +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5115567ac25674e0043e472be13d14e537f37ea8aa4bdc4aef0c89add1db1ff" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "str-buf", + "windows-sys 0.52.0", ] [[package]] -name = "expat-sys" -version = "2.1.6" +name = "error-code" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d9305ccc6942a704f4335694ecd3de2ea531b114ac2d51f5f843750787a92f" + +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + +[[package]] +name = "fdeflate" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" +checksum = "d8090f921a24b04994d9929e204f50b498a33ea6ba559ffaa05e04f7ee7fb5ab" dependencies = [ - "cmake", - "pkg-config", + "simd-adler32", ] [[package]] name = "flate2" -version = "1.0.20" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ - "cfg-if", "crc32fast", - "libc", - "miniz_oxide 0.4.4", + "miniz_oxide 0.8.0", ] [[package]] name = "float-ord" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" +checksum = "8ce81f49ae8a0482e4c55ea62ebbd7e5a686af544c00b9d090bba3ff9be97b3d" [[package]] name = "fnv" @@ -456,11 +531,11 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "font-kit" -version = "0.10.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c9a156ec38864999bc9c4156e5f3b50224d4a5578028a64e5a3875caa9ee28" +checksum = "b0504fc23a34d36352540ae5eedcec2623c86607a4efe25494ca9641845c5a50" dependencies = [ - "bitflags", + "bitflags 2.6.0", "byteorder", "core-foundation", "core-graphics", @@ -474,9 +549,9 @@ dependencies = [ "log", "pathfinder_geometry", "pathfinder_simd", - "servo-fontconfig", "walkdir", "winapi", + "yeslogic-fontconfig-sys", ] [[package]] @@ -496,9 +571,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "freetype" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee38378a9e3db1cc693b4f88d166ae375338a0ff75cb8263e1c601d51f35dc6" +checksum = "5a440748e063798e4893ceb877151e84acef9bea9a8c6800645cf3f1b3a7806e" dependencies = [ "freetype-sys", "libc", @@ -506,11 +581,11 @@ dependencies = [ [[package]] name = "freetype-sys" -version = "0.13.1" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" +checksum = "0e7edc5b9669349acfda99533e9e0bcf26a51862ab43b08ee7745c55d28eb134" dependencies = [ - "cmake", + "cc", "libc", "pkg-config", ] @@ -528,13 +603,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -553,9 +628,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.9.1" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" @@ -568,9 +643,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,106 +658,125 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "image" -version = "0.23.14" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", "color_quant", "jpeg-decoder", - "num-iter", - "num-rational", "num-traits", "png", ] [[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.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ - "autocfg", + "equivalent", "hashbrown", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[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.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jpeg-decoder" -version = "0.1.22" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" dependencies = [ "rayon", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] -name = "lazycell" -version = "1.3.0" +name = "libc" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] -name = "libc" -version = "0.2.96" +name = "libloading" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5600b4e6efc5421841a2138a6b082e07fe12f9aaa12783d50e5d13325b26b4fc" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if", + "windows-targets 0.52.6", +] [[package]] -name = "line-wrap" -version = "0.1.1" +name = "libredox" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "safemem", + "bitflags 2.6.0", + "libc", ] [[package]] -name = "log" +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.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if", -] +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "malloc_buf" @@ -695,57 +789,59 @@ dependencies = [ [[package]] name = "matrixmultiply" -version = "0.1.15" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcad67dcec2d58ff56f6292582377e6921afdf3bfbd533e26fb8900ae575e002" +checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a" dependencies = [ + "autocfg", "rawpointer", ] [[package]] -name = "memoffset" -version = "0.6.4" +name = "memchr" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" -dependencies = [ - "autocfg", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.3.7" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ - "adler32", + "adler", + "simd-adler32", ] [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", - "autocfg", + "adler2", ] [[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.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -757,39 +853,43 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.3.2" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d0a3d5e207573f948a9e5376662aa743a2ea13f7c50a554d7af443a73fbfeba" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ - "autocfg", "num-integer", "num-traits", ] [[package]] name = "num-complex" -version = "0.3.1" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.42" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -798,11 +898,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.3.2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -810,23 +909,13 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 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,48 +945,66 @@ dependencies = [ "objc", ] +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + [[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", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "os_info" -version = "3.0.6" +version = "3.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d2536ab8ff7605e8dc7044ec2f3eb0d49750cb559af9e5373c4564a3706cdd" +checksum = "ae99c7fa6dd38c7cafe1ec085e804f8f555a2f8659b0dbe03f1f9963a9b51092" dependencies = [ "log", "serde", - "winapi", + "windows-sys 0.52.0", ] [[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.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pasteboard" version = "0.1.3" @@ -922,58 +1029,58 @@ dependencies = [ [[package]] name = "pathfinder_simd" -version = "0.5.1" -source = "git+https://github.com/servo/pathfinder#62fbfcc91cce8695c77ea3602a38ce11bccdfdb8" +version = "0.5.4" +source = "git+https://github.com/servo/pathfinder#1b7c8bcdaf9da3f045af6a650b5f5c00f0c5a7eb" 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.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plist" -version = "1.1.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "679104537029ed2287c216bfb942bbf723f48ee98f0aef15611634173a74ef21" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64", - "chrono", "indexmap", - "line-wrap", + "quick-xml", "serde", - "xml-rs", + "time", ] [[package]] name = "png" -version = "0.16.8" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", - "deflate", - "miniz_oxide 0.3.7", + "fdeflate", + "flate2", + "miniz_oxide 0.7.4", ] +[[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.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro-error" @@ -984,7 +1091,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1001,45 +1108,42 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] -name = "quote" -version = "1.0.9" +name = "quick-xml" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" dependencies = [ - "proc-macro2", + "memchr", ] [[package]] -name = "rand" -version = "0.7.3" +name = "quote" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" 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 +1153,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 +1165,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 +1180,79 @@ 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.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.1" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "lazy_static", - "num_cpus", -] - -[[package]] -name = "redox_syscall" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" -dependencies = [ - "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom 0.2.3", - "redox_syscall", + "getrandom 0.2.15", + "libredox", + "thiserror", ] [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "rulinalg" -version = "0.4.2" +name = "rustc_version" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ada202c9685e1d72a7420c578e92b358dbf807d3dfabb676a3dab9cc3bb12f" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "matrixmultiply", - "num 0.1.42", + "semver", ] [[package]] -name = "rustc_version" -version = "0.3.3" +name = "rustix" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "semver", + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", ] [[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,15 +1260,18 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] -name = "safemem" -version = "0.3.3" +name = "safe_arch" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +checksum = "c3460605018fdc9612bce72735cba0d27efbcd9904780d44c7e3a9948f96148a" +dependencies = [ + "bytemuck", +] [[package]] name = "same-file" @@ -1222,95 +1282,63 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[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.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.126" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", ] [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "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" +name = "shell-words" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" -dependencies = [ - "expat-sys", - "freetype-sys", - "pkg-config", -] +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] -name = "shell-words" -version = "1.0.0" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "silicon" -version = "0.4.3" +version = "0.5.2" dependencies = [ "anyhow", "clipboard", - "clipboard-win 4.2.1", + "clipboard-win 5.4.0", "conv", "dirs", "env_logger", @@ -1322,6 +1350,7 @@ dependencies = [ "log", "pasteboard", "pathfinder_geometry", + "pathfinder_simd", "rayon", "shell-words", "structopt", @@ -1330,10 +1359,23 @@ dependencies = [ ] [[package]] -name = "str-buf" -version = "1.0.5" +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 = "d44a3643b4ff9caf57abcee9c2c621d6c03d9135e0d8b589bd9afb5992cb176a" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "strsim" @@ -1343,9 +1385,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 +1396,72 @@ 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.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syntect" -version = "4.5.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bfac2b23b4d049dc9a89353b4e06bbc85a8f42020cccbe5409a115cf19031e5" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" 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.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", - "libc", - "rand 0.8.3", - "redox_syscall", - "remove_dir_all", - "winapi", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", ] [[package]] @@ -1421,15 +1474,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" -dependencies = [ - "winapi-util", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -1440,35 +1484,92 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "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.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "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 = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-segmentation" -version = "1.7.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] -name = "unicode-xid" +name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "vec_map" @@ -1478,18 +1579,17 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -1501,9 +1601,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 = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wide" +version = "0.7.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b828f995bf1e9622031f8009f8481a85406ce1f4d4588ff746d872043e855690" +dependencies = [ + "bytemuck", + "safe_arch", +] [[package]] name = "winapi" @@ -1523,11 +1633,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -1536,6 +1646,154 @@ 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 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[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_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[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_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[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_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[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_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "wio" version = "0.2.2" @@ -1565,7 +1823,43 @@ 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 = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb6b23999a8b1a997bf47c7bb4d19ad4029c3327bb3386ebe0a5ff584b33c7a" +dependencies = [ + "cstr", + "dlib", + "once_cell", + "pkg-config", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] diff --git a/Cargo.toml b/Cargo.toml index c480548..c2e4171 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,63 +9,60 @@ 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 = "5.0.1" +imageproc = "0.23.0" clipboard = "0.5.0" -tempfile = "3.1.0" +tempfile = "3.10.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.9.0" +font-kit = "0.12.0" +harfbuzz-sys = { version = "0.5.0", optional = true } +pathfinder_simd = "0.5.3" [dependencies.image] -version = "0.23" +version = "0.24.9" default-features = false features = ["jpeg", "png", "jpeg_rayon"] [dependencies.syntect] -version = "4.4" +version = "5.2.0" default-features = false -features = ["parsing", "dump-load", "regex-onig"] +features = ["parsing", "dump-load", "regex-onig", "plist-load", "yaml-load"] [dependencies.anyhow] -version = "1.0" +version = "1.0.80" optional = true [dependencies.structopt] -version = "0.3" +version = "0.3.26" default-features = false features = ["color", "wrap_help"] optional = true [dependencies.env_logger] -version = "0.8.2" +version = "0.11.2" default-features = false -features = ["termcolor", "atty", "humantime"] +features = ["auto-color", "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 = "5.2.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"] +pathfinder_simd = { version = "0.5.4", git = "https://github.com/servo/pathfinder" } 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..0538589 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 libfontconfig1-dev g++ ``` ### 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 @@ -102,7 +105,7 @@ EOF Highlight specified line ```bash -silicon main.rs -o main.png --highlight-lines '1; 3-4' +silicon main.rs -o main.png --highlight-lines '1;3-4' ``` Custom the image @@ -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..8bf3462 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..e167d46 --- /dev/null +++ b/src/assets.rs @@ -0,0 +1,59 @@ +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(); + let theme_dir = path.join("themes"); + if theme_dir.is_dir() { + self.theme_set.add_from_folder(theme_dir)?; + } + let mut builder = self.syntax_set.clone().into_builder(); + let syntaxes_dir = path.join("syntaxes"); + if syntaxes_dir.is_dir() { + builder.add_from_folder(syntaxes_dir, 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..eb4311f 100644 --- a/src/bin/silicon/config.rs +++ b/src/bin/silicon/config.rs @@ -2,6 +2,7 @@ use anyhow::{Context, Error}; use clipboard::{ClipboardContext, ClipboardProvider}; use image::Rgba; use silicon::directories::PROJECT_DIRS; +use silicon::font::FontCollection; use silicon::formatter::{ImageFormatter, ImageFormatterBuilder}; use silicon::utils::{Background, ShadowAdder, ToRgba}; use std::ffi::OsString; @@ -30,7 +31,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 +40,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)> { @@ -113,7 +114,7 @@ pub struct Config { #[structopt(long, short, value_name = "FONT", parse(from_str = parse_font_str))] pub font: Option, - /// Lines to high light. rg. '1-3; 4' + /// Lines to highlight. eg. '1-3;4' #[structopt(long, value_name = "LINES", parse(try_from_str = parse_line_range))] pub highlight_lines: Option, @@ -125,6 +126,10 @@ pub struct Config { #[structopt(long, value_name = "PAD", default_value = "2")] pub line_pad: u32, + /// Add PAD padding to the right of the code. + #[structopt(long, value_name = "PAD", default_value = "25")] + pub code_pad_right: u32, + /// Line number offset #[structopt(long, value_name = "OFFSET", default_value = "1")] pub line_offset: u32, @@ -142,7 +147,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 +155,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 +204,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 { @@ -258,22 +270,23 @@ impl Config { Ok(theme.clone()) } else { ThemeSet::get_theme(&self.theme) - .context(format!("Canot load the theme: {}", self.theme)) + .context(format!("Cannot load the theme: {}", self.theme)) } } - pub fn get_formatter(&self) -> Result { + pub fn get_formatter(&self) -> Result, Error> { 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()) - .line_offset(self.line_offset); + .line_offset(self.line_offset) + .code_pad_right(self.code_pad_right); Ok(formatter.build()?) } @@ -298,7 +311,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..6591555 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,12 +142,13 @@ 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()?; let image = formatter.format(&highlight, &theme); + let image = DynamicImage::ImageRgba8(image); if config.to_clipboard { dump_image_to_clipboard(&image)?; 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..57c7b01 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; @@ -20,7 +21,7 @@ use font_kit::font::Font; use font_kit::hinting::HintingOptions; use font_kit::properties::{Properties, Style, Weight}; use font_kit::source::SystemSource; -use image::{GenericImage, Pixel}; +use image::{GenericImage, Pixel, Rgba, RgbaImage}; use imageproc::definitions::Clamp; use imageproc::pixelops::weighted_sum; use pathfinder_geometry::transform2d::Transform2F; @@ -28,6 +29,46 @@ use std::collections::HashMap; use std::sync::Arc; use syntect::highlighting; +/// a single line text drawer +pub trait TextLineDrawer { + /// get the height of the text + fn height(&mut self, text: &str) -> u32; + /// get the width of the text + fn width(&mut self, text: &str) -> u32; + /// draw the text + fn draw_text( + &mut self, + image: &mut RgbaImage, + color: Rgba, + x: u32, + y: u32, + font_style: FontStyle, + text: &str, + ); +} + +impl TextLineDrawer for FontCollection { + fn height(&mut self, _text: &str) -> u32 { + self.get_font_height() + } + + fn width(&mut self, text: &str) -> u32 { + self.layout(text, REGULAR).1 + } + + fn draw_text( + &mut self, + image: &mut RgbaImage, + color: Rgba, + x: u32, + y: u32, + font_style: FontStyle, + text: &str, + ) { + self.draw_text_mut(image, color, x, y, font_style, text); + } +} + /// Font style #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub enum FontStyle { @@ -171,11 +212,15 @@ impl ImageFont { /// /// It can be used to draw text on the image. #[derive(Debug)] -pub struct FontCollection(Vec); +pub struct FontCollection { + fonts: Vec, +} impl Default for FontCollection { fn default() -> Self { - Self(vec![ImageFont::default()]) + Self { + fonts: vec![ImageFont::default()], + } } } @@ -190,18 +235,30 @@ impl FontCollection { Err(err) => eprintln!("[error] Error occurs when load font `{}`: {}", name, err), } } - Ok(Self(fonts)) + Ok(Self { fonts }) + } + + fn glyph_for_char(&self, c: char, style: FontStyle) -> Option<(u32, &ImageFont, &Font)> { + for font in &self.fonts { + 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 + self.fonts .iter() .map(|font| font.get_font_height()) .max() .unwrap() } + #[cfg(feature = "harfbuzz")] fn shape_text(&self, font: &mut HBFont, text: &str) -> Result> { // feature tags let features = vec![ @@ -221,19 +278,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 +325,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(); @@ -286,9 +394,9 @@ impl FontCollection { I: GenericImage, ::Subpixel: ValueInto + Clamp, { - let metrics = self.0[0].get_regular().metrics(); + let metrics = self.fonts[0].get_regular().metrics(); let offset = - (metrics.descent / metrics.units_per_em as f32 * self.0[0].size).round() as i32; + (metrics.descent / metrics.units_per_em as f32 * self.fonts[0].size).round() as i32; let (glyphs, width) = self.layout(text, style); @@ -308,6 +416,7 @@ impl FontCollection { } } +#[derive(Debug)] struct PositionedGlyph { id: u32, font: Font, diff --git a/src/formatter.rs b/src/formatter.rs index b021300..5b31d78 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -1,11 +1,11 @@ //! Format the output of syntect into an image use crate::error::FontError; -use crate::font::{FontCollection, FontStyle}; +use crate::font::{FontCollection, FontStyle, TextLineDrawer}; use crate::utils::*; -use image::{DynamicImage, GenericImageView, Rgba, RgbaImage}; +use image::{Rgba, RgbaImage}; use syntect::highlighting::{Color, Style, Theme}; -pub struct ImageFormatter { +pub struct ImageFormatter { /// pad between lines /// Default: 2 line_pad: u32, @@ -15,6 +15,22 @@ pub struct ImageFormatter { /// pad of top of the code area /// Default: 50 code_pad_top: u32, + /// pad of right of the code area + /// Default: 25 + code_pad_right: 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, @@ -29,7 +45,7 @@ pub struct ImageFormatter { line_number_chars: u32, /// font of english character, should be mono space font /// Default: Hack (builtin) - font: FontCollection, + font: T, /// Highlight lines highlight_lines: Vec, /// Shadow adder @@ -44,6 +60,8 @@ pub struct ImageFormatter { pub struct ImageFormatterBuilder { /// Pad between lines line_pad: u32, + /// Padding to the right of the code + code_pad_right: u32, /// Show line number line_number: bool, /// Font of english character, should be mono space font @@ -52,6 +70,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 +89,7 @@ impl + Default> ImageFormatterBuilder { line_pad: 2, line_number: true, window_controls: true, + window_title: None, round_corner: true, tab_width: 4, ..Default::default() @@ -93,6 +114,12 @@ impl + Default> ImageFormatterBuilder { self } + /// Set the pad on the right of the screen + pub fn code_pad_right(mut self, pad: u32) -> Self { + self.code_pad_right = pad; + self + } + /// Set the font pub fn font(mut self, fonts: Vec<(S, f32)>) -> Self { self.font = fonts; @@ -105,6 +132,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; @@ -129,18 +162,25 @@ impl + Default> ImageFormatterBuilder { self } - pub fn build(self) -> Result { + pub fn build(self) -> Result, FontError> { let font = if self.font.is_empty() { FontCollection::default() } else { 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 }, + code_pad_right: self.code_pad_right, + 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 +188,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,41 +200,41 @@ 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 { +impl ImageFormatter { /// calculate the height of a line - fn get_line_height(&self) -> u32 { - self.font.get_font_height() + self.line_pad + fn get_line_height(&mut self) -> u32 { + self.font.height(" ") + self.line_pad } /// calculate the Y coordinate of a line - fn get_line_y(&self, lineno: u32) -> u32 { + fn get_line_y(&mut self, lineno: u32) -> u32 { lineno * self.get_line_height() + self.code_pad + self.code_pad_top } /// calculate the size of code area - fn get_image_size(&self, max_width: u32, lineno: u32) -> (u32, u32) { + fn get_image_size(&mut self, max_width: u32, lineno: u32) -> (u32, u32) { ( - (max_width + self.code_pad).max(150), + (max_width + self.code_pad_right).max(150), self.get_line_y(lineno + 1) + self.code_pad, ) } /// Calculate where code start - fn get_left_pad(&self) -> u32 { + fn get_left_pad(&mut self) -> u32 { self.code_pad + if self.line_number { let tmp = format!("{:>width$}", 0, width = self.line_number_chars as usize); - 2 * self.line_number_pad + self.font.get_text_len(&tmp) + 2 * self.line_number_pad + self.font.width(&tmp) } else { 0 } } /// create - fn create_drawables(&self, v: &[Vec<(Style, &str)>]) -> Drawable { + fn create_drawables(&mut self, v: &[Vec<(Style, &str)>]) -> Drawable { // tab should be replaced to whitespace so that it can be rendered correctly let tab = " ".repeat(self.tab_width as usize); let mut drawables = vec![]; @@ -214,18 +253,41 @@ impl ImageFormatter { drawables.push(( width, height, - style.foreground, + Some(style.foreground), style.font_style.into(), text.to_owned(), )); - width += self.font.get_text_len(&text); + width += self.font.width(&text); max_width = max_width.max(width); } max_lineno = i as u32; } + if self.window_title.is_some() { + let title = self.window_title.as_ref().unwrap(); + let title_width = self.font.width(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.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, @@ -233,46 +295,47 @@ impl ImageFormatter { } } - fn draw_line_number(&self, image: &mut DynamicImage, lineno: u32, mut color: Rgba) { + fn draw_line_number(&mut self, image: &mut RgbaImage, lineno: u32, mut color: Rgba) { for i in color.0.iter_mut() { *i = (*i).saturating_sub(20); } for i in 0..=lineno { - let line_mumber = format!( + let line_number = format!( "{:>width$}", i + self.line_offset, width = self.line_number_chars as usize ); - self.font.draw_text_mut( + let y = self.get_line_y(i); + self.font.draw_text( image, color, self.code_pad, - self.get_line_y(i), + y, FontStyle::REGULAR, - &line_mumber, + &line_number, ); } } - fn highlight_lines>(&self, image: &mut DynamicImage, lines: I) { + fn highlight_lines>(&mut self, image: &mut RgbaImage, lines: I) { let width = image.width(); - let height = self.font.get_font_height() + self.line_pad; - let mut color = image.get_pixel(20, 20); + let height = self.get_line_height(); + let color = image.get_pixel_mut(20, 20); for i in color.0.iter_mut() { *i = (*i).saturating_add(40); } - let shadow = RgbaImage::from_pixel(width, height, color); + let shadow = RgbaImage::from_pixel(width, height, *color); for i in lines { let y = self.get_line_y(i - 1); - copy_alpha(&shadow, image.as_mut_rgba8().unwrap(), 0, y); + copy_alpha(&shadow, image, 0, y); } } // TODO: use &T instead of &mut T ? - pub fn format(&mut self, v: &[Vec<(Style, &str)>], theme: &Theme) -> DynamicImage { + pub fn format(&mut self, v: &[Vec<(Style, &str)>], theme: &Theme) -> RgbaImage { if self.line_number { self.line_number_chars = (((v.len() + self.line_offset as usize) as f32).log10() + 1.0).floor() as u32; @@ -288,32 +351,34 @@ 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 = RgbaImage::from_pixel(size.0, size.1, background.to_rgba()); if !self.highlight_lines.is_empty() { let highlight_lines = self .highlight_lines .iter() .cloned() - .filter(|&n| n >= 1 && n <= drawables.max_lineno + 1); + .filter(|&n| n >= 1 && n <= drawables.max_lineno + 1) + .collect::>(); 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(); - self.font - .draw_text_mut(&mut image, color, x, y, style, &text); + let color = color.unwrap_or(foreground).to_rgba(); + self.font.draw_text(&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..124e968 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 image::{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,38 +66,53 @@ 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 RgbaImage, params: &WindowControlsParams) { let color = [ ("#FF5F56", "#E0443E"), ("#FFBD2E", "#DEA123"), ("#27C93F", "#1AAB29"), ]; - let mut background = image.get_pixel(37, 37); + let background = image.get_pixel_mut(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, params.padding, params.padding); } #[derive(Clone, Debug)] @@ -214,7 +199,7 @@ impl ShadowAdder { self } - pub fn apply_to(&self, image: &DynamicImage) -> DynamicImage { + pub fn apply_to(&self, image: &RgbaImage) -> RgbaImage { // the size of the final image let width = image.width() + self.pad_horiz * 2; let height = image.height() + self.pad_vert * 2; @@ -236,14 +221,9 @@ impl ShadowAdder { // shadow = blur(&shadow, self.blur_radius); // copy the original image to the top of it - copy_alpha( - image.as_rgba8().unwrap(), - &mut shadow, - self.pad_horiz, - self.pad_vert, - ); + copy_alpha(image, &mut shadow, self.pad_horiz, self.pad_vert); - DynamicImage::ImageRgba8(shadow) + shadow } } @@ -276,37 +256,54 @@ pub(crate) fn copy_alpha(src: &RgbaImage, dst: &mut RgbaImage, x: u32, y: u32) { } /// Round the corner of the image -pub(crate) fn round_corner(image: &mut DynamicImage, radius: u32) { +pub(crate) fn round_corner(image: &mut RgbaImage, 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, - foreground, + (((radius + 1) * 2) as i32, ((radius + 1) * 2) as i32), + radius as i32 * 2, + *foreground, + ); + + // scale down the circle to the correct size + let circle = resize( + &circle, + (radius + 1) * 2, + (radius + 1) * 2, + FilterType::Triangle, ); - let part = crop(&mut circle, 0, 0, radius, radius); - image.copy_from(&part, 0, 0).unwrap(); + // 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(); }