mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-24 10:08:00 -06:00
app icon: lion (owner's ArtCraft drawing), Dock/taskbar/launcher wiring, palette docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
03fca33d10
commit
1f2e267f32
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate every app icon from assets/app-icon/printcraft.svg (the master vector).
|
||||
#
|
||||
# Needs: resvg (brew install resvg / cargo install resvg) and python3 (stdlib only, for the .ico).
|
||||
# On macOS, iconutil also writes the .icns. The outputs are committed, so building and packaging
|
||||
# never need these tools. After running it, update the sha256 values in ATTRIBUTION.toml, then
|
||||
# `cargo xtask assets --write`.
|
||||
#
|
||||
# packaging/icons.sh
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
DIR="$ROOT/assets/app-icon"
|
||||
SVG="$DIR/printcraft.svg"
|
||||
ID="ai.storyteller.printcraft"
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
command -v resvg >/dev/null || { echo "error: resvg not found (brew install resvg)" >&2; exit 1; }
|
||||
|
||||
# The master is a full-bleed 512 tile (rx=112): right for Windows and Linux. macOS icons follow
|
||||
# Apple's grid instead: an 824 px body centred on a transparent 1024 canvas.
|
||||
MAC="$TMP/macos.svg"
|
||||
{
|
||||
echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1024 1024">'
|
||||
echo '<image x="100" y="100" width="824" height="824" xlink:href="'"$SVG"'"/>'
|
||||
echo '</svg>'
|
||||
} >"$MAC"
|
||||
|
||||
render() { resvg -w "$2" -h "$2" "$1" "$3" </dev/null; }
|
||||
|
||||
# 1024 px PNG on Apple's grid (also the runtime Dock icon on macOS, see apps/printcraft/src/main.rs).
|
||||
render "$MAC" 1024 "$DIR/printcraft-1024.png"
|
||||
|
||||
# Linux hicolor theme (full bleed; hicolor/256x256 is also the runtime icon on Windows and Linux).
|
||||
for s in 16 24 32 48 64 128 256 512; do
|
||||
mkdir -p "$DIR/hicolor/${s}x${s}/apps"
|
||||
render "$SVG" "$s" "$DIR/hicolor/${s}x${s}/apps/$ID.png"
|
||||
done
|
||||
mkdir -p "$DIR/hicolor/scalable/apps"
|
||||
cp "$SVG" "$DIR/hicolor/scalable/apps/$ID.svg"
|
||||
|
||||
# Windows .ico: PNG-compressed entries, 16-256 px.
|
||||
ICO_PNGS=()
|
||||
for s in 16 20 24 32 40 48 64 128 256; do
|
||||
render "$SVG" "$s" "$TMP/ico-$s.png"
|
||||
ICO_PNGS+=("$TMP/ico-$s.png")
|
||||
done
|
||||
python3 - "$DIR/printcraft.ico" "${ICO_PNGS[@]}" <<'PY'
|
||||
import struct, sys
|
||||
out, pngs = sys.argv[1], sys.argv[2:]
|
||||
blobs = [open(p, "rb").read() for p in pngs]
|
||||
head = struct.pack("<HHH", 0, 1, len(blobs))
|
||||
entries, data, offset = b"", b"", 6 + 16 * len(blobs)
|
||||
for b in blobs:
|
||||
w, h = struct.unpack(">II", b[16:24]) # IHDR
|
||||
entries += struct.pack("<BBBBHHII", w % 256, h % 256, 0, 0, 1, 32, len(b), offset)
|
||||
data += b
|
||||
offset += len(b)
|
||||
open(out, "wb").write(head + entries + data)
|
||||
PY
|
||||
|
||||
# macOS .icns.
|
||||
if command -v iconutil >/dev/null; then
|
||||
SET="$TMP/printcraft.iconset"
|
||||
mkdir -p "$SET"
|
||||
for s in 16 32 128 256 512; do
|
||||
render "$MAC" "$s" "$SET/icon_${s}x${s}.png"
|
||||
render "$MAC" $((s * 2)) "$SET/icon_${s}x${s}@2x.png"
|
||||
done
|
||||
iconutil -c icns -o "$DIR/printcraft.icns" "$SET"
|
||||
else
|
||||
echo "warning: iconutil not found (macOS only); printcraft.icns not regenerated" >&2
|
||||
fi
|
||||
echo "icons written to $DIR"
|
||||
@@ -0,0 +1,14 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=PrintCraft
|
||||
GenericName=PDF Editor
|
||||
Comment=Read, organize, combine, split and secure PDFs
|
||||
Exec=printcraft %F
|
||||
TryExec=printcraft
|
||||
Icon=ai.storyteller.printcraft
|
||||
Terminal=false
|
||||
StartupNotify=true
|
||||
StartupWMClass=printcraft
|
||||
Categories=Office;Viewer;Graphics;
|
||||
Keywords=pdf;viewer;editor;annotate;sign;forms;merge;split;
|
||||
MimeType=application/pdf;
|
||||
Reference in New Issue
Block a user