Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Other targets are:
- `config` to generate configuration in `Makefile.config` (automatically called during first build)
- `dev` produces `build/texpresso-dev` which supports hot-reloading to ease development
- `debug` produces debugging tools in `build/`
- `macos-app` (macOS only) bundles the built binaries into `build/TeXpresso.app` with a HIG-compliant dock icon; requires `rsvg-convert` and `iconutil` in `PATH`
- `clean` to remove intermediate build files
- `distclean` to remove all build files (`build/` and `Makefile.config`)

Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,8 @@ test-register:
test-lookup-file:
bash test/test-lookup-file.sh

.PHONY: all dev clean config texpresso common texpresso-xetex re2c compile_commands.json fill-tectonic-cache test-texlive test-tectonic test-texpresso test-stream test-open-base64 test-register test-lookup-file
macos-app: texpresso
@[ "$$(uname)" = "Darwin" ] || { echo "macos-app requires macOS"; exit 1; }
bash scripts/build-macos-app.sh

.PHONY: all dev clean config texpresso common texpresso-xetex re2c compile_commands.json fill-tectonic-cache test-texlive test-tectonic test-texpresso test-stream test-open-base64 test-register test-lookup-file macos-app
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ See the [screencasts](#Screencasts) at the end of this file for a visual demo of

TeXpresso has been tested on Linux and macOS and should work with both AMD64 and Apple Silicon architectures. See [INSTALL.md](./INSTALL.md) for dependency and build instructions.

On macOS, `make macos-app` additionally produces `build/TeXpresso.app`, a bundle whose dock icon renders at the correct HIG size. Launch it with `open build/TeXpresso.app --args /abs/path.tex` or point your editor at `build/TeXpresso.app/Contents/MacOS/texpresso`. The plain `build/texpresso` binary falls back to the default macOS binary icon.

### Design

The TeXpresso system is built of the following parts:
Expand Down
8 changes: 4 additions & 4 deletions doc/texpresso_logo_v3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions scripts/build-macos-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash
# Build a TeXpresso.app bundle for macOS.
#
# Run AFTER `make texpresso` so the binaries exist under build/.
# Output: build/TeXpresso.app/ with proper Info.plist, padded AppIcon.icns,
# and the texpresso + engine binaries under Contents/MacOS/.
#
# Launch via `open build/TeXpresso.app --args path/to/doc.tex` or by
# pointing your editor plugin at build/TeXpresso.app/Contents/MacOS/texpresso.
# macOS will then show the bundle icon in the dock at the correct size.

set -e

REPO="$(cd "$(dirname "$0")/.." && pwd)"
BUILD="$REPO/build"
APP="$BUILD/TeXpresso.app"
SVG="$REPO/doc/texpresso_logo_v3.svg"

if [ ! -x "$BUILD/texpresso" ]; then
echo "error: $BUILD/texpresso not found — run 'make texpresso' first" >&2
exit 1
fi

for tool in rsvg-convert iconutil; do
if ! command -v "$tool" >/dev/null 2>&1; then
echo "error: $tool not found in PATH" >&2
exit 1
fi
done

rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"

# Render the SVG at every size macOS expects, padding so the artwork
# occupies ~80% of the canvas (Apple HIG: icons sit inside a squircle
# that takes 824/1024 = ~80.5% of the canvas).
ICONSET="$(mktemp -d)"
trap 'rm -rf "$ICONSET"' EXIT

render() {
size=$1
name=$2
# SVG already contains the 80% padding (viewBox extends beyond the
# artwork). Just rasterize at the target size.
rsvg-convert -w "$size" -h "$size" "$SVG" -o "$ICONSET/$name"
}

render 16 icon_16x16.png
render 32 icon_16x16@2x.png
render 32 icon_32x32.png
render 64 icon_32x32@2x.png
render 128 icon_128x128.png
render 256 icon_128x128@2x.png
render 256 icon_256x256.png
render 512 icon_256x256@2x.png
render 512 icon_512x512.png
render 1024 icon_512x512@2x.png

# iconutil expects the directory to end in .iconset.
mv "$ICONSET" "$ICONSET.iconset"
iconutil -c icns "$ICONSET.iconset" -o "$APP/Contents/Resources/AppIcon.icns"
rm -rf "$ICONSET.iconset"
trap - EXIT

# Copy texpresso and its engine binary. find_engine() looks for the
# engine in the same directory as the main binary, so both must
# sit together under Contents/MacOS/.
cp "$BUILD/texpresso" "$APP/Contents/MacOS/texpresso"
[ -x "$BUILD/texpresso-xetex" ] && cp "$BUILD/texpresso-xetex" "$APP/Contents/MacOS/"

cat > "$APP/Contents/Info.plist" <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>texpresso</string>
<key>CFBundleIdentifier</key>
<string>net.texpresso.texpresso</string>
<key>CFBundleName</key>
<string>TeXpresso</string>
<key>CFBundleDisplayName</key>
<string>TeXpresso</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
PLIST

echo "built: $APP"
6 changes: 6 additions & 0 deletions src/frontend/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,13 @@ int main(int argc, const char **argv)

SDL_Surface *logo = texpresso_logo();
fprintf(stderr, "texpresso logo: %dx%d\n", logo->w, logo->h);
#ifndef __APPLE__
// SDL_SetWindowIcon on macOS calls [NSApp setApplicationIconImage:]
// which scales the image to fill the Dock cell, ignoring transparent
// padding. On macOS we rely on the .app bundle's AppIcon.icns instead
// (see scripts/build-macos-app.sh).
SDL_SetWindowIcon(window, logo);
#endif
SDL_FreeSurface(logo);

SDL_Renderer *renderer;
Expand Down
Loading
Loading