mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-12 09:41:47 +02:00
Adding PowerShell script for Windows to one-key-installation.
The PowerShell script "install.ps1" from the repository of Powerline Fonts works on Nerd Fonts too with the instruction( https://medium.com/@slmeng/how-to-install-powerline-fonts-in-windows-b2eedecace58 ).
This commit is contained in:
parent
bfde19a193
commit
b752a82fd2
1 changed files with 41 additions and 0 deletions
41
patched-fonts/install.ps1
Normal file
41
patched-fonts/install.ps1
Normal file
|
@ -0,0 +1,41 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Installs the provided fonts.
|
||||
.DESCRIPTION
|
||||
Installs all the provided fonts by default. The FontName
|
||||
parameter can be used to pick a subset of fonts to install.
|
||||
.EXAMPLE
|
||||
C:\PS> ./install.ps1
|
||||
Installs all the fonts located in the Git repository.
|
||||
.EXAMPLE
|
||||
C:\PS> ./install.ps1 furamono-, hack-*
|
||||
Installs all the FuraMono and Hack fonts.
|
||||
.EXAMPLE
|
||||
C:\PS> ./install.ps1 d* -WhatIf
|
||||
Shows which fonts would be installed without actually installing the fonts.
|
||||
Remove the "-WhatIf" to install the fonts.
|
||||
#>
|
||||
[CmdletBinding(SupportsShouldProcess)]
|
||||
param(
|
||||
# Specifies the font name to install. Default value will install all fonts.
|
||||
[Parameter(Position=0)]
|
||||
[string[]]
|
||||
$FontName = '*'
|
||||
)
|
||||
|
||||
$fontFiles = New-Object 'System.Collections.Generic.List[System.IO.FileInfo]'
|
||||
foreach ($aFontName in $FontName) {
|
||||
Get-ChildItem $PSScriptRoot -Filter "${aFontName}.ttf" -Recurse | Foreach-Object {$fontFiles.Add($_)}
|
||||
Get-ChildItem $PSScriptRoot -Filter "${aFontName}.otf" -Recurse | Foreach-Object {$fontFiles.Add($_)}
|
||||
}
|
||||
|
||||
$fonts = $null
|
||||
foreach ($fontFile in $fontFiles) {
|
||||
if ($PSCmdlet.ShouldProcess($fontFile.Name, "Install Font")) {
|
||||
if (!$fonts) {
|
||||
$shellApp = New-Object -ComObject shell.application
|
||||
$fonts = $shellApp.NameSpace(0x14)
|
||||
}
|
||||
$fonts.CopyHere($fontFile.FullName)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue