From 3542762f53cfc89da06b66a5cddd7343f76b1939 Mon Sep 17 00:00:00 2001 From: Seth Freiberg Date: Wed, 29 Apr 2026 12:11:32 -0400 Subject: [PATCH] fix: use upstream SVG (not nonexistent PNG) for .app icon conversion --- Formula/glabels-qt.rb | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Formula/glabels-qt.rb b/Formula/glabels-qt.rb index fdcfa6c..173b8df 100644 --- a/Formula/glabels-qt.rb +++ b/Formula/glabels-qt.rb @@ -62,19 +62,27 @@ class GlabelsQt < Formula PLIST - # Convert upstream PNG icon to .icns using sips (macOS built-in). - # Upstream installs hicolor PNGs at share/icons/hicolor//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| - size = path[%r{hicolor/(\d+)x\d+/}, 1].to_i - -size # largest first + # Mac icon: convert upstream's SVG (installed at share/icons/hicolor//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 + icon_src = Pathname.new(candidates.first) if candidates.first end - if candidate_pngs.first - system "sips", "-s", "format", "icns", - candidate_pngs.first, - "--out", resources/"glabels-qt.icns" + + if icon_src && icon_src.exist? + begin + system "sips", "-s", "format", "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