3 $my_nerdfont_otf = "Droid Sans Mono for Powerline Nerd Font Complete Windows Compatible.otf"
4 $my_fontdir = "$Env:UserProfile\AppData\Local\Microsoft\Windows\Fonts"
6 New-Item -Path "$my_fontdir" -ItemType Directory -Force | out-null
7 IF (!(Test-Path -Path "$my_fontdir\$my_nerdfont_otf"))
10 & curl.exe -fsSLo "$my_nerdfont_otf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete
11 /Droid%20Sans%20Mono%20Nerd%20Font%20Complete%20Windows%20Compatible.otf'
12 & move "$my_nerdfont_otf" "$my_fontdir"
18 $regFontPath = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
19 $fontRegistryPath = "HKCU:$regFontPath"
20 $fontFiles = Get-ChildItem -Recurse -Include *.ttf, *.otf
21 foreach($font in $fontFiles) {
22 # See https://github.com/PPOSHGROUP/PPoShTools/blob/master/PPoShTools/Public/FileSystem/Add-Font.ps1#L80
23 Add-Type -AssemblyName System.Drawing
24 $objFontCollection = New-Object System.Drawing.Text.PrivateFontCollection
25 $objFontCollection.AddFontFile($font.FullName)
26 $FontName = $objFontCollection.Families.Name
28 $regTest = Get-ItemProperty -Path $fontRegistryPath -Name "*$FontName*" -ErrorAction SilentlyContinue
29 if (-not ($regTest)) {
30 New-ItemProperty -Name $FontName -Path $fontRegistryPath -PropertyType string -Value $font.Name
31 Write-Output "Registered font {$($font.Name)} in Current User registry as {$FontName}"
33 echo "Installed $my_nerdfont_otf to $my_fontdir"
34 # because adding to the registry alone doesn't actually take
35 & start $font.FullName
37 echo "IMPORTANT: Click 'Install' to complete installation"