mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-25 10:37:11 -06:00
Detect ../craft-fonts or use CRAFT_FONTS_DIR on macOS, Linux and Windows. Download the pinned release revision when the checkout is missing and require Chinese and Japanese fonts during the build. Document font setup and preserve skip-build behavior.
32 lines
1.3 KiB
Bash
32 lines
1.3 KiB
Bash
# shellcheck shell=bash
|
|
# Font setup for local packaging; sourced after packaging/env.sh.
|
|
prepare_fonts() {
|
|
local font_dir="${CRAFT_FONTS_DIR:-$ROOT/../craft-fonts}"
|
|
# Relative overrides are documented relative to the workspace, regardless of the caller's cwd.
|
|
case "$font_dir" in
|
|
/*) ;;
|
|
*) font_dir="$ROOT/$font_dir" ;;
|
|
esac
|
|
|
|
if [ -z "${CRAFT_FONTS_DIR:-}" ] && [ ! -e "$font_dir" ]; then
|
|
# Same revision as release.yml. Never update or reset an existing checkout.
|
|
local revision=8dcdacd5153e64560d109541a47d806f26f048c0
|
|
echo "==> downloading craft-fonts ($revision) to $font_dir"
|
|
if ! git clone --no-checkout https://github.com/storytold/craft-fonts "$font_dir" ||
|
|
! git -C "$font_dir" checkout --detach "$revision"; then
|
|
echo "error: could not prepare craft-fonts; provide a complete checkout with CRAFT_FONTS_DIR" >&2
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
if [ ! -f "$font_dir/fonts/manifest.txt" ]; then
|
|
echo "error: missing $font_dir/fonts/manifest.txt; set CRAFT_FONTS_DIR to a complete craft-fonts checkout" >&2
|
|
return 1
|
|
fi
|
|
CRAFT_FONTS_DIR="$(cd "$font_dir" && pwd)" || return 1
|
|
export CRAFT_FONTS_DIR
|
|
# Fail the build if required faces are missing, rather than ship empty glyph boxes.
|
|
export CRAFT_FONTS_REQUIRED=1
|
|
echo "==> embedding fonts from $CRAFT_FONTS_DIR"
|
|
}
|