Tuesday, November 26, 2019

Installing the Cascadia Code Font (using PowerShell)

In a recent article, I wrote about the new font Microsoft has created, Cascadia Code. I just love the new font and am using it with PowerShell, VS Code and more. I also use it in a variety of VMs, so automating the download and installation is important.

It turns out that downloading and installing a new font is relatively straightforward, like this:

# Install Cascadia Code
# 1. Download Cascadia Code font from GitHub$DLPath = 'https://github.com/microsoft/cascadia-code/releases/'+          'download/v1911.20/Cascadia.ttf'$DLFile = 'C:\Foo\Cascadia.TTF'Invoke-WebRequest -Uri $DLPath -OutFile $DLFile
# 2. Now Install it $Font = New-Object -Com Shell.Application$Destination = (New-Object -ComObject Shell.Application).Namespace(0x14)$Destination.CopyHere($DLFile,0x10)
Simples as they say.

One thing - the URL download path is hardcoded. You may need to adjust it going forward. Maybe someone can show me how to work out the latest version programmatically. 

No comments: