Skip to content

Instantly share code, notes, and snippets.

@longnguyen2004
Created April 26, 2023 09:39
Show Gist options
  • Select an option

  • Save longnguyen2004/eb5f71bbde259c759cfed8a2f9f3fb0b to your computer and use it in GitHub Desktop.

Select an option

Save longnguyen2004/eb5f71bbde259c759cfed8a2f9f3fb0b to your computer and use it in GitHub Desktop.

Revisions

  1. longnguyen2004 created this gist Apr 26, 2023.
    22 changes: 22 additions & 0 deletions generate-static.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    $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*;
    }