这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<#
.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 FiraCode, Hack
Installs all the FiraCode and Hack fonts.
.EXAMPLE
C:\PS> ./install.ps1 DejaVuSansMono -WhatIf
Shows which fonts would be installed without actually installing the fonts.
Remove the "-WhatIf" to install the fonts.
#>
[CmdletBinding(SupportsShouldProcess)]
param ()

dynamicparam {
$Attributes = [Collections.ObjectModel.Collection[Attribute]]::new()
$ParamAttribute = [Parameter]::new()
$ParamAttribute.Position = 0
$ParamAttribute.ParameterSetName = '__AllParameterSets'
$Attributes.Add($ParamAttribute)

[string[]]$FontNames = Join-Path $PSScriptRoot patched-fonts | Get-ChildItem -Directory -Name
$Attributes.Add([ValidateSet]::new(($FontNames)))

$Parameter = [Management.Automation.RuntimeDefinedParameter]::new('FontName', [string[]], $Attributes)
$RuntimeParams = [Management.Automation.RuntimeDefinedParameterDictionary]::new()
$RuntimeParams.Add('FontName', $Parameter)

return $RuntimeParams
}

end {
$FontName = $PSBoundParameters.FontName
if (-not $FontName) {$FontName = '*'}

$fontFiles = [Collections.Generic.List[System.IO.FileInfo]]::new()

Join-Path $PSScriptRoot patched-fonts | Push-Location
foreach ($aFontName in $FontName) {
Get-ChildItem $aFontName -Filter "*.ttf" -Recurse | Foreach-Object {$fontFiles.Add($_)}
Get-ChildItem $aFontName -Filter "*.otf" -Recurse | Foreach-Object {$fontFiles.Add($_)}
}
Pop-Location

$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)
}
}
}
41 changes: 0 additions & 41 deletions patched-fonts/install.ps1

This file was deleted.

14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ _Note_: **Requires cloning** the repo as of now
./install.sh
```

or, in Powershell (Windows only):

```pwsh
./install.ps1
```

#### Single font:

* Installs a single Font of your choice
Expand All @@ -231,6 +237,14 @@ _Note_: **Requires cloning** the repo as of now
./install.sh HeavyData
```

or, in Powershell (Windows only):

```pwsh
./install.ps1 <FontName>
./install.ps1 Hack
./install.ps1 HeavyData
```

### `Option 4: Homebrew Fonts`

> Best option if on **macOS** and want to use **Homebrew**.
Expand Down