~schnouki/schnouki.net

440de0f1ca8436fa5ba24eb0779518c2f7e5f4a5 — Thomas Jost 3 years ago 8a755af
Update Iosevka font to 6.1.0
M static/fonts/iosevka-bold.ttf => static/fonts/iosevka-bold.ttf +0 -0
M static/fonts/iosevka-bold.woff2 => static/fonts/iosevka-bold.woff2 +0 -0
M static/fonts/iosevka-bolditalic.ttf => static/fonts/iosevka-bolditalic.ttf +0 -0
M static/fonts/iosevka-bolditalic.woff2 => static/fonts/iosevka-bolditalic.woff2 +0 -0
M static/fonts/iosevka-italic.ttf => static/fonts/iosevka-italic.ttf +0 -0
M static/fonts/iosevka-italic.woff2 => static/fonts/iosevka-italic.woff2 +0 -0
M static/fonts/iosevka-regular.ttf => static/fonts/iosevka-regular.ttf +0 -0
M static/fonts/iosevka-regular.woff2 => static/fonts/iosevka-regular.woff2 +0 -0
M static/fonts/iosevka-sparkle-bold.ttf => static/fonts/iosevka-sparkle-bold.ttf +0 -0
M static/fonts/iosevka-sparkle-bold.woff2 => static/fonts/iosevka-sparkle-bold.woff2 +0 -0
M static/fonts/iosevka-sparkle-bolditalic.ttf => static/fonts/iosevka-sparkle-bolditalic.ttf +0 -0
M static/fonts/iosevka-sparkle-bolditalic.woff2 => static/fonts/iosevka-sparkle-bolditalic.woff2 +0 -0
M static/fonts/iosevka-sparkle-italic.ttf => static/fonts/iosevka-sparkle-italic.ttf +0 -0
M static/fonts/iosevka-sparkle-italic.woff2 => static/fonts/iosevka-sparkle-italic.woff2 +0 -0
M static/fonts/iosevka-sparkle-regular.ttf => static/fonts/iosevka-sparkle-regular.ttf +0 -0
M static/fonts/iosevka-sparkle-regular.woff2 => static/fonts/iosevka-sparkle-regular.woff2 +0 -0
A update-iosevka => update-iosevka +91 -0
@@ 0,0 1,91 @@
#!/usr/bin/env bash

set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT

tmpd=$(mktemp --directory)
blog_dir=$(pwd)

cleanup() {
    trap - SIGINT SIGTERM ERR EXIT
    rm -rf "$tmpd"
}

setup_colors() {
  if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
    NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
  else
    NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
  fi
}

msg() {
  echo >&2 -e "${1-}"
}

setup_colors

usage() {
    echo "Usage: $(basename $0) [-v version] [-s url]"
    echo "Download updated Iosevka fonts."
    echo "  -v VERSION  Version of the regular Iosevka font to update"
    echo "  -s URL      URL tot he latest Iosevka Sparke archive"
}

extract() {
    file=$1
    dirprefix=$2
    fileprefix=$3
    components=$4
    bsdtar -xvf "$file" -C "$blog_dir/static/fonts" --strip-components $components "$dirprefix"{ttf,woff2}/"$fileprefix"-{bold,bolditalic,italic,regular}.*
}

if [[ $# -eq 0 ]]; then
    usage
    exit 1
fi

VERSION=""
SPARKLE_URL=""

while getopts ":hs:v:" arg; do
    case $arg in
        v)
            VERSION=$OPTARG
            ;;
        s)
            SPARKLE_URL=$OPTARG
            ;;
        h)
            usage
            exit 0
            ;;
        ?)
            echo "Invalid option: -$OPTARG"
            echo
            usage
            exit 1
            ;;
    esac
done

cd "$tmpd"

if [[ $VERSION ]]; then
    zip_url="https://github.com/be5invis/Iosevka/releases/download/v$VERSION/webfont-iosevka-$VERSION.zip"
    zip_fn=$(basename "$zip_url")
    msg "Downloading ${CYAN}$zip_fn${NOFORMAT}..."
    wget -nv --show-progress "$zip_url"
    msg "Extracting ${CYAN}$zip_fn${NOFORMAT}..."
    extract "$zip_fn" "" iosevka 1
fi

if [[ $SPARKLE_URL ]]; then
    zip_fn=$(basename "$SPARKLE_URL")
    msg "Downloading ${PURPLE}$zip_fn${NOFORMAT}..."
    wget -nv --show-progress "$SPARKLE_URL"
    msg "Extracting ${PURPLE}$zip_fn${NOFORMAT}..."
    extract "$zip_fn" iosevka-sparkle/ iosevka-sparkle 2
fi

echo "All done!"