83 lines
3.7 KiB
Bash
83 lines
3.7 KiB
Bash
#!/usr/bin/env bash
|
|
# get-fonts.sh — Download all self-hosted font assets for Soft UI Dashboard Tailwind
|
|
#
|
|
# Run from your project root:
|
|
# bash path/to/get-fonts.sh
|
|
#
|
|
# Outputs to: public/assets/fonts/ and public/assets/css/fontawesome/
|
|
# Requires: curl, unzip
|
|
|
|
set -e
|
|
|
|
FONTS_DIR="public/assets/fonts"
|
|
CSS_DIR="public/assets/css"
|
|
TMP="$(mktemp -d)"
|
|
|
|
echo "→ Creating directories..."
|
|
mkdir -p "$FONTS_DIR/open-sans"
|
|
mkdir -p "$CSS_DIR/fontawesome"
|
|
|
|
# ─────────────────────────────────────────────────────────────
|
|
# 1. Open Sans (woff2 only — modern browsers, smallest files)
|
|
# Source: fontsource open-sans package on npm registry (public files)
|
|
# ─────────────────────────────────────────────────────────────
|
|
echo "→ Downloading Open Sans woff2 files..."
|
|
|
|
BASE="https://cdn.jsdelivr.net/npm/@fontsource/open-sans@5/files"
|
|
|
|
for WEIGHT in 300 400 600 700; do
|
|
curl -fsSL "${BASE}/open-sans-latin-${WEIGHT}-normal.woff2" \
|
|
-o "${FONTS_DIR}/open-sans/open-sans-${WEIGHT}.woff2"
|
|
curl -fsSL "${BASE}/open-sans-latin-${WEIGHT}-italic.woff2" \
|
|
-o "${FONTS_DIR}/open-sans/open-sans-${WEIGHT}italic.woff2"
|
|
done
|
|
|
|
echo " ✓ Open Sans done (8 files)"
|
|
|
|
# ─────────────────────────────────────────────────────────────
|
|
# 2. Font Awesome Free 6 (CSS + webfonts)
|
|
# Only the files actually needed: all.min.css + webfonts/
|
|
# ─────────────────────────────────────────────────────────────
|
|
echo "→ Downloading Font Awesome Free 6..."
|
|
|
|
FA_VERSION="6.4.0"
|
|
FA_ZIP="$TMP/fontawesome.zip"
|
|
|
|
curl -fsSL "https://github.com/FortAwesome/Font-Awesome/releases/download/${FA_VERSION}/fontawesome-free-${FA_VERSION}-web.zip" \
|
|
-o "$FA_ZIP"
|
|
|
|
unzip -q "$FA_ZIP" -d "$TMP"
|
|
FA_DIR="$TMP/fontawesome-free-${FA_VERSION}-web"
|
|
|
|
# CSS
|
|
cp "${FA_DIR}/css/all.min.css" "${CSS_DIR}/fontawesome/all.min.css"
|
|
cp "${FA_DIR}/css/all.css" "${CSS_DIR}/fontawesome/all.css"
|
|
|
|
# Webfonts (woff2 + woff — skip eot/ttf/svg for modern projects)
|
|
mkdir -p "${CSS_DIR}/fontawesome/webfonts"
|
|
find "${FA_DIR}/webfonts" \( -name "*.woff2" -o -name "*.woff" \) \
|
|
-exec cp {} "${CSS_DIR}/fontawesome/webfonts/" \;
|
|
|
|
# Patch font paths in all.min.css to match our directory structure
|
|
# FA expects webfonts/ relative to the CSS file — already correct since both are in fontawesome/
|
|
echo " ✓ Font Awesome done"
|
|
|
|
# ─────────────────────────────────────────────────────────────
|
|
# 3. Copy open-sans.css into project CSS dir
|
|
# ─────────────────────────────────────────────────────────────
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cp "${SCRIPT_DIR}/open-sans.css" "${CSS_DIR}/open-sans.css"
|
|
echo " ✓ open-sans.css copied"
|
|
|
|
# Cleanup
|
|
rm -rf "$TMP"
|
|
|
|
echo ""
|
|
echo "Done. Add these to your HTML <head>:"
|
|
echo ""
|
|
echo " <link href=\"/assets/css/open-sans.css\" rel=\"stylesheet\" />"
|
|
echo " <link href=\"/assets/css/fontawesome/all.min.css\" rel=\"stylesheet\" />"
|
|
echo " <link href=\"/assets/css/nucleo-icons.css\" rel=\"stylesheet\" />"
|
|
echo " <link href=\"/assets/css/nucleo-svg.css\" rel=\"stylesheet\" />"
|
|
echo " <link href=\"/assets/css/soft-ui-dashboard-tailwind.css\" rel=\"stylesheet\" />"
|