Inkscape and Installing New Fonts [Pro-Tip]
Inkscape does not recognize newly installed fonts on Windows computers.
I use Inkscape when I need vector graphics, and it does an outstanding job. However, in some ways, it’s also a bit clunky and behind the times.
Microsoft changed the way fonts are installed on Windows computers, and this change appears to be why Inkscape doesn’t recognize the new fonts when they are installed.
Installing a new font used to be as easy as copying the font file to the C:\Windows\Fonts folder, and voila! Windows did it. Now, it’s more complicated, and I needed to install many fonts, so I created a Powershell script to do this task for me. I thought there’s probably someone else out there who could use it, so I’m releasing it as Open-Source.
This post’s end is a link to this code compiled into an EXE (Windows Font Installer) for easy use–otherwise, you need to open Powershell ISE as an Administrator to get it to work.
Here’s the code:
$DebugPreference = "SilentlyContinue";
class FontInstaller{
$fontpath = "";
$fontname = "";
$filename = "";
$filenamenoext = "";
$windowsfontpaths = @("C:\Windows\Fonts\", "$($env:USERPROFILE)\AppData\Local\Microsoft\Windows\Fonts\","C:\Users\Default\AppData\Local\Microsoft\Windows\Fonts\");
FontInstaller(){
Add-Type -AssemblyName System.Windows.Forms;
if(!$this.openFont()){
break;
}else{
Write-Host "Fonts have been copied and are ready for use. Please restart any programs that need to use the new fonts.";
pause;
}
}
[bool] openFont(){
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
InitialDirectory = [Environment]::GetFolderPath('MyComputer');
Filter = 'TTF Font (*.ttf)|*.ttf|OTF Font (*.otf)|*.otf';
Multiselect = $true;
}
$null = $FileBrowser.ShowDialog();
if($($FileBrowser.FileName)){
Write-Debug "Font path is: $($FileBrowser.FileName)";
$this.fontpath = (Split-Path -Path $($FileBrowser.FileName) -Parent);
Set-Location -Path $this.fontpath;
Write-Debug "fontpath is: $($this.fontpath)";
$FileBrowser.SafeFileNames.ForEach({
$this.filename = $($_);
$this.filenamenoext = [io.path]::GetFileNameWithoutExtension($this.fontpath);
Write-Debug "Filename: $($this.filename)";
Write-Debug "FilenameNoExt: $($this.filenamenoext)";
switch (($this.filename -split "\.")[-1]) {
"TTF" {
$this.fontname = "$(($this.filename -split "\.")[0]) (TrueType)";
break;
}
"OTF" {
$this.fontname = "$(($this.filename -split "\.")[0]) (OpenType)";
break;
}
}
if(!$this.copyFont()){
return $false;
}
});
return $true;
}else{
Write-Host "No file selected. Cancelling.";
return $false;
}
}
[bool] copyFont(){
try{
if($this.fontpath -and $this.filename){
$this.windowsfontpaths.ForEach({
$wpath = $_;
$source = "$($this.fontpath)\$($this.filename)";
Write-Debug "Source: $($source)";
Copy-Item -LiteralPath $source -Destination "$($wpath)$($this.filename)" -Force -PassThru;
if($wpath -eq $this.windowsfontpaths[1]){
New-ItemProperty -Name $this.fontname -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value "$($wpath)$($this.filename)";
New-ItemProperty -Name $this.fontname -Path "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value "$($wpath)$($this.filename)";
}
if(Test-Path "$($wpath)$($this.filename)"){
Write-Debug "$($this.filename) was copied successfully to $($wpath)";
}else{
Write-Host "The font file was not copied. This is all I know.";
return $false;
}
});
return $true;
}else{
Write-Host "No file selected. Cancelling";
return $false;
}
}catch{
return $false;
}
}
}
$fontinstaller = [FontInstaller]::new();
To use the compiled file, right-click and select “Run as Administrator”. Then, select the font(s) you want to install. At the end, it tells you if it was successful. That’s it! Now, restart Inkscape, and bask in all the glory that your fonts are there!
It all started when I watched my dad fix a very expensive RC car after I ran it to death, when I was a kid.