desktopToDarwinBundle: fix 16x, 32x app icons (#358247)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
fetchFromGitHub,
|
||||
python,
|
||||
pythonOlder,
|
||||
pillow,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
@@ -20,6 +21,8 @@ buildPythonPackage rec {
|
||||
hash = "sha256-tiq8h6s2noWLBIOIWcj8jfSqJFN01ee2uoHN4aFwn7s=";
|
||||
};
|
||||
|
||||
dependencies = [ pillow ];
|
||||
|
||||
checkPhase = ''
|
||||
${python.interpreter} tests/test_icnsutil.py
|
||||
${python.interpreter} tests/test_cli.py
|
||||
|
||||
Reference in New Issue
Block a user