Files
ulicraft-server-v1/tooling/fetch-fonts.sh
Oier Bravo Urtasun c3b2d89ddc feat(landing): switch heading font to Block Blueprint
Replace Pixelify Sans with Block Blueprint as the heading font (theme.headFont).
Block Blueprint isn't on Google Fonts, so it's vendored straight from 1001fonts
(License: 1001Fonts Free For Personal Use — fine for this private friends'
server) as a TTF, with a hand-written @font-face appended to fonts.css. The
vendor step is added to fetch-fonts.sh (runs after the Google rewrite so it
survives re-runs). Pixelify stays available as a HEAD_FONTS option + the
hard-coded fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 22:17:52 +02:00

71 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Vendor the landing-page web fonts locally so the apex site works on an
# offline LAN (no Google Fonts CDN at party time).
#
# Pulls woff2 + a rewritten @font-face stylesheet from Google Fonts into
# landing/public/fonts/. Re-run only when the font set changes.
#
# Halts on any error (cautious-by-default).
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
out="$here/landing/public/fonts"
mkdir -p "$out"
# Modern Chrome UA → Google returns woff2 (not ttf).
UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36"
# Families + weights used by the landing (keep in sync with main.css --font-*).
CSS_URL="https://fonts.googleapis.com/css2"
CSS_URL+="?family=Pixelify+Sans:wght@600;700"
CSS_URL+="&family=Space+Grotesk:wght@400;500;600;700"
CSS_URL+="&family=Press+Start+2P"
CSS_URL+="&family=Silkscreen:wght@400;700"
CSS_URL+="&family=VT323"
CSS_URL+="&display=swap"
echo "→ fetching @font-face CSS"
raw="$(curl -fsSL -A "$UA" "$CSS_URL")"
echo "→ downloading woff2 files"
# Pull every gstatic woff2 URL, download to out/, dedupe by basename.
echo "$raw" | grep -oE 'https://fonts\.gstatic\.com/[^)]+\.woff2' | sort -u | while read -r url; do
fn="$(basename "$url")"
if [ ! -f "$out/$fn" ]; then
curl -fsSL -o "$out/$fn" "$url"
echo " $fn"
fi
done
echo "→ writing fonts.css (URLs rewritten to /fonts/…)"
# Rewrite absolute gstatic URLs to local /fonts/<basename>.
echo "$raw" | sed -E 's#https://fonts\.gstatic\.com/[^)]+/([^)/]+\.woff2)#/fonts/\1#g' > "$out/fonts.css"
# Block Blueprint — the heading font. NOT on Google Fonts, so it can't ride the
# css2 request above; vendored straight from 1001fonts (License: 1001Fonts Free
# For Personal Use — fine for this private friends' server). TTF only, no woff2
# (no woff2 toolchain assumed). Appended AFTER the rewrite so it survives re-runs.
echo "→ vendoring Block Blueprint (1001fonts)"
bb_ttf="$out/BlockBlueprint.ttf"
if [ ! -f "$bb_ttf" ]; then
tmpzip="$(mktemp)"
curl -fsSL -A "$UA" -o "$tmpzip" "https://www.1001fonts.com/download/blockblueprint.zip"
unzip -p "$tmpzip" BlockBlueprint.ttf > "$bb_ttf"
rm -f "$tmpzip"
echo " BlockBlueprint.ttf"
fi
cat >> "$out/fonts.css" <<'EOF'
/* Block Blueprint — vendored from 1001fonts (NOT on Google Fonts; appended by
fetch-fonts.sh after the Google rewrite). License: 1001Fonts Free For Personal
Use. Single weight, TTF (no woff2 toolchain on the build box). */
@font-face {
font-family: 'Block Blueprint';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(/fonts/BlockBlueprint.ttf) format('truetype');
}
EOF
echo "✓ fonts vendored into $out"