diff --git a/pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh b/pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh index d7cab0e81a60..4fbef4baa512 100644 --- a/pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh +++ b/pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh @@ -92,6 +92,7 @@ convertIconTheme() { echo "desktopToDarwinBundle: resizing icon $in to $out, size $dim" >&2 magick convert -scale "${dim}x${dim}" -density "$density" -units PixelsPerInch "$in" "$out" + convertIfUnsupportedIcon "$out" "$iconSize" "$scale" } function synthesizeIcon() { @@ -107,11 +108,27 @@ convertIconTheme() { echo "desktopToDarwinBundle: rasterizing svg $in to $out, size $dim" >&2 rsvg-convert --keep-aspect-ratio --width "$dim" --height "$dim" "$in" --output "$out" magick convert -density "$density" -units PixelsPerInch "$out" "$out" + convertIfUnsupportedIcon "$out" "$iconSize" "$scale" else return 1 fi } + # macOS does not correctly display 16x and 32x png icons on app bundles + # they need to be converted to rgb+mask (argb is supported only from macOS 11) + function convertIfUnsupportedIcon() { + local -r in=$1 + local -r iconSize=$2 + local -r scale=$3 + local -r out=${in%.png}.rgb + + if [[ ($scale -eq 1) && ($iconSize -eq 32 || $iconSize -eq 16) ]]; then + echo "desktopToDarwinBundle: converting ${iconSize}x icon to rgb" >&2 + icnsutil convert "$out" "$in" + rm "$in" + fi + } + function getIcons() { local -r sharePath=$1 local -r iconname=$2 @@ -151,6 +168,7 @@ convertIconTheme() { fixed) local density=$((72 * scale))x$((72 * scale)) magick convert -density "$density" -units PixelsPerInch "$icon" "$result" + convertIfUnsupportedIcon "$result" "$iconSize" "$scale" foundIcon=OTHER ;; threshold)