dotfiles/win/get-fontname.ps1
2020-11-17 16:26:46 +08:00

25 lines
547 B
PowerShell

[CmdletBinding()]
param (
[Parameter()]
[string]
$FontPath
)
Add-Type -AssemblyName PresentationCore
$face = New-Object System.Windows.Media.GlyphTypeface -ArgumentList "$(Resolve-Path $FontPath)"
$style = "$($face.Style)"
$weight = "$($face.Weight)"
$stretch = "$($face.Stretch)"
$name = $face.FamilyNames["en-US"] -replace '\W',''
if ($style -ne "Normal") {
$name += "-$($style)"
}
if ($weight -ne "Normal") {
$name += "-$($weight)"
}
if ($stretch -ne "Normal") {
$name += "-$(stretch)"
}
$name