Files
chandra/scripts/fetch-emoji-font.sh
T
nandiandClaude Sonnet 5.5 7912a0b32b
CI / test (push) Failing after 44m48s
Emoji font: install it readable, and retry a failed load
The fetch script downloaded through mktemp (0600) and the installer kept
that mode, so the session couldn't read the root-owned font and reported
it missing. The failure was also cached until the next session.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 00:12:06 -08:00

33 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Fetch Chandra's colour emoji font: Noto Color Emoji 2.051, the bitmap (CBDT) edition, into
# assets/fonts/NotoColorEmoji.ttf (SIL Open Font License 1.1, see assets/fonts/LICENSE-NotoColorEmoji).
#
# Chandra reads its own copy rather than the system's: distributions ship different editions, and
# Fedora's is COLRv1 (vector paint graphs), which Chandra's emoji picker can't draw. `just install`,
# `just run*` and `just test` run this; it downloads only when the file is missing or different.
set -euo pipefail
cd "$(dirname "$0")/.."
version=v2.051
sha=72a635cb3d2f3524c51620cdde406b217204e8a6a06c6a096ff8ed4b5fd6e27b
url=https://raw.githubusercontent.com/googlefonts/noto-emoji/$version/fonts/NotoColorEmoji.ttf
dst=assets/fonts/NotoColorEmoji.ttf
if [ -f "$dst" ] && echo "$sha $dst" | sha256sum --check --status; then
chmod 644 "$dst"
exit 0
fi
echo "fetching Noto Color Emoji $version (10 MB) from $url" >&2
tmp=$(mktemp "$dst.XXXXXX")
trap 'rm -f "$tmp"' EXIT
if ! curl -fL --retry 3 -o "$tmp" "$url"; then
echo "error: couldn't download Noto Color Emoji from $url; the emoji picker (Super+.) needs it at $dst" >&2
exit 1
fi
if ! echo "$sha $tmp" | sha256sum --check --status; then
echo "error: $url is not the expected Noto Color Emoji $version (sha256 differs: $(sha256sum "$tmp" | cut -d' ' -f1))" >&2
exit 1
fi
chmod 644 "$tmp" # mktemp made it 0600; the installed copy must be readable by the session's user
mv "$tmp" "$dst"
trap - EXIT
echo "installed $dst" >&2