Skip to content

Commit

Permalink
Only register user fonts that we installed
Browse files Browse the repository at this point in the history
Close #19

Signed-off-by: Christopher Larson <kergoth@gmail.com>
  • Loading branch information
kergoth committed Jan 20, 2024
1 parent d334d8d commit 7673dea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scripts/setup-user-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if (Test-Path "C:\Program Files\SyncTrayzor") {
}

# Install fonts
. $PSScriptRoot\windows\install-fonts.ps1
. $PSScriptRoot\windows\register-fonts.ps1

# Apply my dotfiles
$env:DOTFILES_DIR = $PSScriptRoot | Split-Path -Parent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# https://www.alkanesolutions.co.uk/2021/12/06/installing-fonts-with-powershell/
function Install-Font {
function Register-Font {
param
(
[System.IO.FileInfo]$fontFile
Expand Down Expand Up @@ -32,8 +32,20 @@ function Install-Font {
Add-Type -AssemblyName PresentationCore

Write-Output "Adding user fonts to the registry"

$FontsPath = Join-Path -Path ([Environment]::GetFolderPath('LocalApplicationData')) -ChildPath 'Microsoft\Windows\Fonts'
foreach ($FontItem in (Get-ChildItem -Path $FontsPath |
Where-Object { ($_.Name -like '*.ttf') -or ($_.Name -like '*.otf') })) {
Install-Font -fontFile $FontItem.FullName
if (Get-Command -Name chezmoi -ErrorAction SilentlyContinue) {
$fonts = chezmoi data |
ConvertFrom-Json |
Select-Object -ExpandProperty fonts |
ForEach-Object { Join-Path $FontsPath $_ }
}
else {
$fonts = Get-ChildItem -Path $FontsPath |
Where-Object { ($_.Name -like '*.ttf') -or ($_.Name -like '*.otf') } |
ForEach-Object { $_.FullName }
}

foreach ($font in $fonts) {
Register-Font -fontFile $font
}

0 comments on commit 7673dea

Please sign in to comment.