Skip to content

Generate a real .icns for the macOS bundle - #86

Merged
aweeri merged 1 commit into
extremelywipfrom
fix/macos-icns
Nov 12, 2026
Merged

aweeri merged 1 commit into
extremelywipfrom
fix/macos-icns

Conversation

@weerbot

@weerbot weerbot commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Implements the second option in #85: the macOS icon is now generated from src/ui/logo_raster.h instead of being a committed binary, and the dead .ico copy is gone.

What changed

  • scripts/gen_icon.cpp picks the container from the output extension and writes either the existing multi-size .ico or a real .icns with PNG representations for every slot macOS 10.7+ reads: icp4/icp5/icp6, ic07-ic10 (16, 32, 64, 128, 256, 512, 1024) plus the @2x slots ic11-ic14. The PNG encoder and its fixed-Huffman deflate are ~180 lines of self-contained C++ so the generator still builds with the bare host compiler (HOST_CXX, no zlib, no image library) on every platform we cross-compile from.
  • Makefile: the generator is its own rule now, so build/logo.ico and build/AppIcon.icns are separate outputs. make macos depends on the .icns, ships it in the portable directory as AppIcon.icns, and no longer copies logo.ico.
  • macos_bundle.sh fails early with a clear message if the portable directory has no AppIcon.icns. It already copies the portable contents into Contents/Resources/, so the generated icon lands over CFBundleIconFile=AppIcon with no extra step.
  • bundle/Contents/Resources/AppIcon.icns deleted (363 KB): after the above it is unreachable and would silently drift from the rasterizer. The repo now has one source for the icon, as the .gitignore rule for build/logo.ico already intended.
  • CI: the bundle step asserts Contents/Resources/AppIcon.icns exists.

How it was verified (Linux host, since no macOS runner here)

  • Regenerated both containers from scratch: .ico 370 070 bytes / 6 sizes, .icns 193 410 bytes / 11 representations, 0.27 s, and the .icns header length matches the file size exactly.
  • Every one of the 11 representations decodes (Python zlib + Pillow, two independent PNG implementations) and is byte-identical to logo_raster::Render() output at the same pixel size — so the icon really is the app's own logo, not an approximation.
  • Ran macos_bundle.sh end-to-end against a stub portable directory: TLEscope.app/Contents/{MacOS,Resources} correct, generated 193 KB AppIcon.icns in Resources/, Info.plist untouched. Negative case (no .icns) exits 1 with Missing app icon: ... (run: make macos).
  • Linux/Windows icon paths unchanged, make build/logo.ico still works.

Not verified: an actual macOS build and Finder/Dock rendering — that needs the CI macOS runners on this PR.

gen_icon now writes either container, picked from the output extension:
the existing multi-size .ico, or an .icns with PNG representations for
16-1024 px (icp4/5/6, ic07-ic10, @2x ic11-ic14). The PNG/deflate writer
is self-contained so the generator still builds with the bare host
compiler on every platform.

make macos drops the unused logo.ico from the portable directory and
ships build/AppIcon.icns instead; macos_bundle.sh already copies the
portable contents into Contents/Resources, so the icon now lands over
CFBundleIconFile=AppIcon from source rather than a committed binary.
The committed bundle/Contents/Resources/AppIcon.icns is removed: it was
never reached by macos_bundle.sh after this change and would only drift
from logo_raster.h.

Closes #85
@aweeri
aweeri merged commit 741c3ac into extremelywip Nov 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants