Created
April 26, 2023 09:39
-
-
Save longnguyen2004/eb5f71bbde259c759cfed8a2f9f3fb0b to your computer and use it in GitHub Desktop.
Generating static fonts from VF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Weights = @{ | |
"ExtraLight" = 200; | |
"Light" = 300; | |
"SemiLight" = 350; | |
"Regular" = 400; | |
"SemiBold" = 600; | |
"Bold" = 700; | |
} | |
$Font = "CascadiaCode"; | |
New-Item -ItemType Directory "generated" -Force | |
foreach ($Weight in $Weights.GetEnumerator()) | |
{ | |
$Name, $Value = $Weight.Name, $Weight.Value; | |
Write-Output "Generating $Name variation"; | |
fonttools varLib.mutator -o "output.ttf" "$Font.ttf" "wght=$Value"; | |
$ttx = fonttools ttx -o - -f ./output.ttf; | |
$ttx -replace "Regular",$Name | Out-File "output.ttx"; | |
fonttools ttx -f -o "generated/$Font-$Name.ttf" ./output.ttx; | |
Remove-Item .\output*; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment