mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-26 02:59:17 -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.
25 lines
1.4 KiB
PowerShell
25 lines
1.4 KiB
PowerShell
# Font setup for local packaging; dot-sourced by package.ps1.
|
|
function Initialize-CraftFonts([string] $WorkspaceRoot) {
|
|
$fontDir = $env:CRAFT_FONTS_DIR
|
|
if (-not $fontDir) { $fontDir = Join-Path $WorkspaceRoot '../craft-fonts' }
|
|
if (-not [IO.Path]::IsPathRooted($fontDir)) { $fontDir = Join-Path $WorkspaceRoot $fontDir }
|
|
|
|
if (-not $env:CRAFT_FONTS_DIR -and -not (Test-Path -LiteralPath $fontDir)) {
|
|
# Same revision as release.yml and packaging/fonts.sh. Existing checkouts stay untouched.
|
|
$revision = '8dcdacd5153e64560d109541a47d806f26f048c0'
|
|
Write-Output "==> downloading craft-fonts ($revision) to $fontDir"
|
|
& git clone --no-checkout https://github.com/storytold/craft-fonts $fontDir
|
|
if ($LASTEXITCODE -ne 0) { throw 'Could not download craft-fonts; provide a complete checkout with CRAFT_FONTS_DIR' }
|
|
& git -C $fontDir checkout --detach $revision
|
|
if ($LASTEXITCODE -ne 0) { throw 'Could not check out craft-fonts; provide a complete checkout with CRAFT_FONTS_DIR' }
|
|
}
|
|
|
|
$manifest = Join-Path $fontDir 'fonts/manifest.txt'
|
|
if (-not (Test-Path -LiteralPath $manifest -PathType Leaf)) {
|
|
throw "Missing $manifest; set CRAFT_FONTS_DIR to a complete craft-fonts checkout"
|
|
}
|
|
$env:CRAFT_FONTS_DIR = (Resolve-Path -LiteralPath $fontDir).Path
|
|
$env:CRAFT_FONTS_REQUIRED = '1'
|
|
Write-Output "==> embedding fonts from $env:CRAFT_FONTS_DIR"
|
|
}
|