Skip to content

Commit a6f45d5

Browse files
authored
Debian icon no fallback, fixes #4280 (#4282)
1 parent 2c1353f commit a6f45d5

3 files changed

Lines changed: 19 additions & 55 deletions

File tree

.changes/linux-icon-png-only.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Only png files from tauri.conf.json > tauri.bundle.icon are used for app icons for linux targets.
6+
Previously, all sizes from all source files (10 files using tauricon defaults) were used.
7+
This also prevents unexpectedly mixed icons in cases where platform-specific icons are used.

tooling/bundler/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ exclude = [
2323

2424
[dependencies]
2525
tauri-utils = { version = "1.0.0-rc.8", path = "../../core/tauri-utils", features = [ "resources" ] }
26-
icns = "0.3"
2726
image = "0.24.2"
2827
libflate = "1.2"
2928
anyhow = "1.0"
@@ -50,6 +49,7 @@ glob = "0.3"
5049
zip = "0.6"
5150

5251
[target."cfg(target_os = \"macos\")".dependencies]
52+
icns = "0.3"
5353
time = { version = "0.3", features = [ "formatting" ] }
5454

5555
[target."cfg(any(target_os = \"macos\", target_os = \"windows\"))".dependencies]

tooling/bundler/src/bundle/linux/debian.rs

Lines changed: 11 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use super::super::common;
2626
use crate::Settings;
2727
use anyhow::Context;
2828
use heck::ToKebabCase;
29-
use image::{self, codecs::png::PngDecoder, GenericImageView, ImageDecoder};
29+
use image::{self, codecs::png::PngDecoder, ImageDecoder};
3030
use libflate::gzip;
3131
use log::info;
3232
use walkdir::WalkDir;
@@ -281,71 +281,28 @@ fn generate_icon_files(settings: &Settings, data_dir: &Path) -> crate::Result<BT
281281
))
282282
};
283283
let mut icons = BTreeSet::new();
284-
// Prefer PNG files.
285284
for icon_path in settings.icon_files() {
286285
let icon_path = icon_path?;
287286
if icon_path.extension() != Some(OsStr::new("png")) {
288287
continue;
289288
}
290-
let decoder = PngDecoder::new(File::open(&icon_path)?)?;
291-
let width = decoder.dimensions().0;
292-
let height = decoder.dimensions().1;
293-
let is_high_density = common::is_retina(&icon_path);
294-
let dest_path = get_dest_path(width, height, is_high_density);
295-
let deb_icon = DebIcon {
296-
width,
297-
height,
298-
is_high_density,
299-
path: dest_path,
300-
};
301-
if !icons.contains(&deb_icon) {
302-
common::copy_file(&icon_path, &deb_icon.path)?;
303-
icons.insert(deb_icon);
304-
}
305-
}
306-
// Fall back to non-PNG files for any missing sizes.
307-
for icon_path in settings.icon_files() {
308-
let icon_path = icon_path?;
309-
if icon_path.extension() == Some(OsStr::new("png")) {
310-
continue;
311-
} else if icon_path.extension() == Some(OsStr::new("icns")) {
312-
let icon_family = icns::IconFamily::read(File::open(&icon_path)?)?;
313-
for icon_type in icon_family.available_icons() {
314-
let width = icon_type.screen_width();
315-
let height = icon_type.screen_height();
316-
let is_high_density = icon_type.pixel_density() > 1;
317-
let dest_path = get_dest_path(width, height, is_high_density);
318-
let deb_icon = DebIcon {
319-
width,
320-
height,
321-
is_high_density,
322-
path: dest_path,
323-
};
324-
if !icons.contains(&deb_icon) {
325-
if let Ok(icon) = icon_family.get_icon_with_type(icon_type) {
326-
icon.write_png(common::create_file(&deb_icon.path)?)?;
327-
icons.insert(deb_icon);
328-
}
329-
}
330-
}
331-
} else {
332-
let icon = image::open(&icon_path)?;
333-
let (width, height) = icon.dimensions();
289+
// Put file in scope so that it's closed when copying it
290+
let deb_icon = {
291+
let decoder = PngDecoder::new(File::open(&icon_path)?)?;
292+
let width = decoder.dimensions().0;
293+
let height = decoder.dimensions().1;
334294
let is_high_density = common::is_retina(&icon_path);
335295
let dest_path = get_dest_path(width, height, is_high_density);
336-
let deb_icon = DebIcon {
296+
DebIcon {
337297
width,
338298
height,
339299
is_high_density,
340300
path: dest_path,
341-
};
342-
if !icons.contains(&deb_icon) {
343-
icon.write_to(
344-
&mut common::create_file(&deb_icon.path)?,
345-
image::ImageOutputFormat::Png,
346-
)?;
347-
icons.insert(deb_icon);
348301
}
302+
};
303+
if !icons.contains(&deb_icon) {
304+
common::copy_file(&icon_path, &deb_icon.path)?;
305+
icons.insert(deb_icon);
349306
}
350307
}
351308
Ok(icons)

0 commit comments

Comments
 (0)