Use Rust report artwork as the application icon

This commit is contained in:
Dandaedre 2026-10-20 13:33:32 +02:00
parent 0558a92c2b
commit c15d236662
8 changed files with 78 additions and 3 deletions

51
Cargo.lock generated
View File

@ -3205,6 +3205,7 @@ dependencies = [
"typst",
"typst-pdf",
"uuid",
"winresource",
"zip",
]
@ -4257,6 +4258,18 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "toml"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime 0.6.11",
"toml_edit 0.19.15",
]
[[package]]
name = "toml"
version = "0.8.23"
@ -4287,6 +4300,19 @@ dependencies = [
"serde_core",
]
[[package]]
name = "toml_edit"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime 0.6.11",
"winnow 0.5.40",
]
[[package]]
name = "toml_edit"
version = "0.22.27"
@ -4437,7 +4463,7 @@ dependencies = [
"if_chain",
"indexmap",
"stacker",
"toml",
"toml 0.8.23",
"typst-library",
"typst-macros",
"typst-syntax",
@ -4538,7 +4564,7 @@ dependencies = [
"smallvec",
"syntect",
"time",
"toml",
"toml 0.8.23",
"ttf-parser 0.24.1",
"two-face",
"typed-arena",
@ -4641,7 +4667,7 @@ checksum = "5ba949ac75a374ea6b2f61d32e6c63acb818e6179d16f78b2cba988fbb5e23a8"
dependencies = [
"ecow",
"serde",
"toml",
"toml 0.8.23",
"typst-timing",
"typst-utils",
"unicode-ident",
@ -5521,6 +5547,15 @@ dependencies = [
"xkbcommon-dl",
]
[[package]]
name = "winnow"
version = "0.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
dependencies = [
"memchr",
]
[[package]]
name = "winnow"
version = "0.7.15"
@ -5539,6 +5574,16 @@ dependencies = [
"memchr",
]
[[package]]
name = "winresource"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77e2aaaf8cfa92078c0c0375423d631f82f2f57979c2884fdd5f604a11e45329"
dependencies = [
"toml 0.7.8",
"version_check",
]
[[package]]
name = "wit-bindgen"
version = "0.57.1"

View File

@ -27,6 +27,9 @@ open = { version = "5", optional = true }
typst = { version = "0.13.1", optional = true }
typst-pdf = { version = "0.13.1", optional = true }
[build-dependencies]
winresource = "0.1.17"
[[bin]]
name = "pptx-reporter"
path = "src/main.rs"

BIN
assets/rust-report-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
assets/rust-report.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 KiB

BIN
assets/rust-report.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

11
build.rs Normal file
View File

@ -0,0 +1,11 @@
fn main() {
println!("cargo:rerun-if-changed=assets/rust-report.ico");
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")
&& std::env::var_os("CARGO_FEATURE_DESKTOP").is_some()
{
winresource::WindowsResource::new()
.set_icon("assets/rust-report.ico")
.compile()
.expect("Could not embed the Windows application icon");
}
}

View File

@ -43,6 +43,20 @@ supports X11/Wayland on Linux and Windows. On Linux, windowing/OpenGL libraries
must be present at runtime. `--no-default-features` builds the CLI/core without
desktop or PDF dependencies; `--features pdf` restores embedded PDF generation.
The app uses `assets/rust-report.png` as its icon. Its square, transparent PNG
derivative is embedded in the desktop window; the multi-resolution ICO is also
embedded into Windows executables by `build.rs` using `winresource`. Cross's
Windows GNU image supplies the resource compiler. Normal builds need no image
conversion tools. To regenerate the committed icon derivatives after changing
the source artwork, use ImageMagick:
```sh
magick assets/rust-report.png -resize 256x256 -background none -gravity center \
-extent 256x256 assets/rust-report-icon.png
magick assets/rust-report-icon.png \
-define icon:auto-resize=256,128,64,48,32,24,16 assets/rust-report.ico
```
```sh
cargo fmt --check
cargo clippy --locked --all-targets --all-features -- -D warnings

View File

@ -360,8 +360,10 @@ impl App {
}
pub fn launch() -> anyhow::Result<()> {
let icon = eframe::icon_data::from_png_bytes(include_bytes!("../assets/rust-report-icon.png"))?;
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_icon(icon)
.with_inner_size([860.0, 760.0])
.with_min_inner_size([620.0, 500.0])
.with_drag_and_drop(true),