From 8758ba45c549f725b042543cd9434ff2d6d3d8e9 Mon Sep 17 00:00:00 2001 From: Ducky Date: Mon, 13 Dec 2021 06:52:25 +0000 Subject: [PATCH] add script to install fonts --- scripts/install-fonts.ps1 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/install-fonts.ps1 diff --git a/scripts/install-fonts.ps1 b/scripts/install-fonts.ps1 new file mode 100644 index 0000000..64209a2 --- /dev/null +++ b/scripts/install-fonts.ps1 @@ -0,0 +1,32 @@ +$fontsPath = [System.IO.Path]::Combine($PSScriptRoot, "..", "assets", "fonts") +$fontFiles = Get-ChildItem -Recurse $fontsPath | ForEach-Object { if ($_.Extension -eq ".ttf") { $_ } } + +function Install-FontFiles { + param( + [System.IO.FileInfo[]]$InFonts, + [string]$OutFontsPath + ) + + foreach ($fontFile in $InFonts) { + Write-Output "Installing $($fontFile.BaseName)..." + $installPath = ([System.IO.Path]::Combine($OutFontsPath, $fontFile.Name)) + + if (-not(Test-Path -Path $installPath)) { + Copy-Item -Force $fontFile $installPath + } + } +} + +if ( + ($PSVersionTable.PSVersion.Major -eq 5 -and $PSVersionTable.PSVersion.Minor -gt 0) -or + $IsWindows +) { + Install-FontFiles -InFonts $fontFiles -OutFontsPath ([System.IO.Path]::Combine("C:", "Windows", "Fonts")) +} +elseif ($IsLinux) { + Install-FontFiles -InFonts $fontFiles -OutFontsPath ([System.IO.Path]::Combine("usr", "local", "share", "fonts")) +} +else { + Write-Error "Platform not supported." + exit +} \ No newline at end of file