Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add -WindowsCompatibleOnly switch parameter to install.ps1 #841

Merged
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
21 changes: 18 additions & 3 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@
.EXAMPLE
C:\PS> ./install.ps1 FiraCode, Hack
Installs all the FiraCode and Hack fonts.
.EXAMPLE
C:\PS> ./install.ps1 CascadiaCode -WindowsCompatibleOnly
Filters fonts to include only those labeled as 'Windows Compatible'
Can be used in combination with the -FontName and/or -WhatIf parameters
.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 ()
param (
[switch]$WindowsCompatibleOnly
)

dynamicparam {
$Attributes = [Collections.ObjectModel.Collection[Attribute]]::new()
Expand All @@ -44,8 +50,17 @@ end {

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($_)}
Get-ChildItem $aFontName -Recurse | Where-Object {
$IsValidFileExtension = $_.Extension -match 'ttf|otf'

if ($WindowsCompatibleOnly) {
$IsValidFileExtension -and ($_.BaseName -match 'Windows Compatible')
} else {
$IsValidFileExtension
}
} | ForEach-Object {
$fontFiles.Add($_)
}
}
Pop-Location

Expand Down