Skip to content

Commit

Permalink
fix PS 5.1 font installation
Browse files Browse the repository at this point in the history
  • Loading branch information
jpawlowski committed Aug 24, 2024
1 parent a39fd50 commit df5de32
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/powershell-extended/Install-NerdFont.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -538,19 +538,7 @@ try {
Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force

# Install the fonts
if ($IsWindows) {
$Destination = (New-Object -ComObject Shell.Application).Namespace(0x14)
Write-Host "`nInstalling font files to Current User Font Directory" -ForegroundColor White
Get-ChildItem -Path $extractPath -Filter "$FontName*.ttf" -Recurse | ForEach-Object {
if ($_.FullName -like '*static*') {
Write-Verbose "Skipping static font file: $($_.Name)"
return
}
Write-Host " $($_.Name)"
$Destination.CopyHere($_.FullName, 0x10)
}
}
elseif ($IsMacOS) {
if ($IsMacOS) {
$Destination = "${HOME}/Library/Fonts"
$null = New-Item -Path $Destination -ItemType Directory -Force
Write-Host "`nInstalling font files to $Destination" -ForegroundColor White
Expand Down Expand Up @@ -579,7 +567,16 @@ try {
$Script:resetFontCache = $Destination
}
else {
throw 'Unsupported operating system.'
$Destination = (New-Object -ComObject Shell.Application).Namespace(0x14)
Write-Host "`nInstalling font files to Current User Font Directory" -ForegroundColor White
Get-ChildItem -Path $extractPath -Filter "$FontName*.ttf" -Recurse | ForEach-Object {
if ($_.FullName -like '*static*') {
Write-Verbose "Skipping static font file: $($_.Name)"
return
}
Write-Host " $($_.Name)"
$Destination.CopyHere($_.FullName, 0x10)
}
}

Write-Host "$FontName font installed successfully.`n" -ForegroundColor Green
Expand All @@ -593,12 +590,7 @@ catch {
Write-Error "Failed to install font:`n$_"
}
finally {
if ($IsWindows) {
Remove-Item -Path "$env:TEMP/NerdFont_*" -Force -Recurse -Confirm:$false
}
else {
Remove-Item -Path "$env:TMPDIR/NerdFont_*" -Force -Recurse -Confirm:$false
}
Remove-Item -Path $([System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'NerdFont_*')) -Force -Recurse -Confirm:$false
}

# Refresh the font cache
Expand Down

0 comments on commit df5de32

Please sign in to comment.