Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

desktopToDarwinBundle: fix 16x, 32x app icons

Changes the script to produce rgb+mask images for 16x and 32x icons
instead of png.

Using icns files containing 16x and 32x png images for app bundles
results in Finder misrendering icons for these sizes (even though the
icns files are rendered correctly when viewed by themselves)

+18
+18
pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh
··· 92 92 93 93 echo "desktopToDarwinBundle: resizing icon $in to $out, size $dim" >&2 94 94 magick convert -scale "${dim}x${dim}" -density "$density" -units PixelsPerInch "$in" "$out" 95 + convertIfUnsupportedIcon "$out" "$iconSize" "$scale" 95 96 } 96 97 97 98 function synthesizeIcon() { ··· 107 108 echo "desktopToDarwinBundle: rasterizing svg $in to $out, size $dim" >&2 108 109 rsvg-convert --keep-aspect-ratio --width "$dim" --height "$dim" "$in" --output "$out" 109 110 magick convert -density "$density" -units PixelsPerInch "$out" "$out" 111 + convertIfUnsupportedIcon "$out" "$iconSize" "$scale" 110 112 else 111 113 return 1 114 + fi 115 + } 116 + 117 + # macOS does not correctly display 16x and 32x png icons on app bundles 118 + # they need to be converted to rgb+mask (argb is supported only from macOS 11) 119 + function convertIfUnsupportedIcon() { 120 + local -r in=$1 121 + local -r iconSize=$2 122 + local -r scale=$3 123 + local -r out=${in%.png}.rgb 124 + 125 + if [[ ($scale -eq 1) && ($iconSize -eq 32 || $iconSize -eq 16) ]]; then 126 + echo "desktopToDarwinBundle: converting ${iconSize}x icon to rgb" >&2 127 + icnsutil convert "$out" "$in" 128 + rm "$in" 112 129 fi 113 130 } 114 131 ··· 151 168 fixed) 152 169 local density=$((72 * scale))x$((72 * scale)) 153 170 magick convert -density "$density" -units PixelsPerInch "$icon" "$result" 171 + convertIfUnsupportedIcon "$result" "$iconSize" "$scale" 154 172 foundIcon=OTHER 155 173 ;; 156 174 threshold)