Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

41 lignes
1.4 KiB

  1. <#
  2. .SYNOPSIS
  3. Installs the provided fonts.
  4. .DESCRIPTION
  5. Installs all the provided fonts by default. The FontName
  6. parameter can be used to pick a subset of fonts to install.
  7. .EXAMPLE
  8. C:\PS> ./install.ps1
  9. Installs all the fonts located in the Git repository.
  10. .EXAMPLE
  11. C:\PS> ./install.ps1 furamono-, hack-*
  12. Installs all the FuraMono and Hack fonts.
  13. .EXAMPLE
  14. C:\PS> ./install.ps1 d* -WhatIf
  15. Shows which fonts would be installed without actually installing the fonts.
  16. Remove the "-WhatIf" to install the fonts.
  17. #>
  18. [CmdletBinding(SupportsShouldProcess)]
  19. param(
  20. # Specifies the font name to install. Default value will install all fonts.
  21. [Parameter(Position=0)]
  22. [string[]]
  23. $FontName = '*'
  24. )
  25. $fontFiles = New-Object 'System.Collections.Generic.List[System.IO.FileInfo]'
  26. foreach ($aFontName in $FontName) {
  27. Get-ChildItem $PSScriptRoot -Filter "${aFontName}.ttf" -Recurse | Foreach-Object {$fontFiles.Add($_)}
  28. Get-ChildItem $PSScriptRoot -Filter "${aFontName}.otf" -Recurse | Foreach-Object {$fontFiles.Add($_)}
  29. }
  30. $fonts = $null
  31. foreach ($fontFile in $fontFiles) {
  32. if ($PSCmdlet.ShouldProcess($fontFile.Name, "Install Font")) {
  33. if (!$fonts) {
  34. $shellApp = New-Object -ComObject shell.application
  35. $fonts = $shellApp.NameSpace(0x14)
  36. }
  37. $fonts.CopyHere($fontFile.FullName)
  38. }
  39. }