fix: use upstream SVG (not nonexistent PNG) for .app icon conversion

This commit is contained in:
2026-04-29 12:11:32 -04:00
parent ef4d6c73a8
commit 3542762f53
+16 -8
View File
@@ -62,19 +62,27 @@ class GlabelsQt < Formula
</plist>
PLIST
# Convert upstream PNG icon to .icns using sips (macOS built-in).
# Upstream installs hicolor PNGs at share/icons/hicolor/<size>/apps/glabels.png.
# Pick the largest available; fall back gracefully if none found.
candidate_pngs = Dir[share/"icons/hicolor/*/apps/glabels.png"].sort_by do |path|
# Mac icon: convert upstream's SVG (installed at share/icons/hicolor/<size>/apps/glabels.svg)
# to .icns via sips. Prefer the scalable SVG; fall back to a sized variant if missing.
icon_src = share/"icons/hicolor/scalable/apps/glabels.svg"
unless icon_src.exist?
candidates = Dir[share/"icons/hicolor/*/apps/glabels.svg"].sort_by do |path|
size = path[%r{hicolor/(\d+)x\d+/}, 1].to_i
-size # largest first
end
if candidate_pngs.first
icon_src = Pathname.new(candidates.first) if candidates.first
end
if icon_src && icon_src.exist?
begin
system "sips", "-s", "format", "icns",
candidate_pngs.first,
"--out", resources/"glabels-qt.icns"
icon_src.to_s,
"--out", (resources/"glabels-qt.icns").to_s
rescue => e
opoo "sips icon conversion failed (#{e.message}); .app will use generic Mac icon."
end
else
opoo "No upstream PNG icon found; .app will use generic Mac icon."
opoo "No upstream icon found; .app will use generic Mac icon."
end
end
end