Skip to content

Instantly share code, notes, and snippets.

@longnguyen2004
Created April 26, 2023 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save longnguyen2004/eb5f71bbde259c759cfed8a2f9f3fb0b to your computer and use it in GitHub Desktop.
Save longnguyen2004/eb5f71bbde259c759cfed8a2f9f3fb0b to your computer and use it in GitHub Desktop.
Generating static fonts from VF
$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