From c3704d83d48416bd355718523ee197372d4eb8c1 Mon Sep 17 00:00:00 2001
From: Von Random <von@mechanus.net>
Date: Mon, 30 Dec 2024 19:12:11 +0200
Subject: [PATCH] move template to the gen script, rewrite generation

---
 README.md   | 12 +++++++-----
 gen-casks   | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 gen.sh      | 21 ---------------------
 template.rb | 28 ----------------------------
 4 files changed, 57 insertions(+), 54 deletions(-)
 create mode 100755 gen-casks
 delete mode 100755 gen.sh
 delete mode 100644 template.rb

diff --git a/README.md b/README.md
index 42ab5d3..83b1087 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,12 @@
 OTF version of cascadia fonts
 =============================
 
-this is the cask that installs cascadia fonts, but not the dynamic ttf version
+These casks provide cascadia fonts in static otf version instead of dynamic ttf.
 
-as terminals on macos display text weird when using ttf
+The reason it may be useful is because terminals on MacOS don't hint properly with dynamic ttf.
 
-to update: set versoin and checksum in gen.sh and run it
-
-depends on envsubst
+In case the font gets updated:
+```
+$EDITOR gen-casks
+./gen-casks
+```
diff --git a/gen-casks b/gen-casks
new file mode 100755
index 0000000..7014dd0
--- /dev/null
+++ b/gen-casks
@@ -0,0 +1,50 @@
+#!/usr/bin/env zsh
+VERSION='2407.24'
+CHECKSUM='e67a68ee3386db63f48b9054bd196ea752bc6a4ebb4df35adce6733da50c8474'
+FONTS=(
+	'Cascadia Code'
+	'Cascadia Code PL'
+	'Cascadia Code NF'
+	'Cascadia Mono'
+	'Cascadia Mono PL'
+	'Cascadia Mono NF'
+)
+
+for font in $FONTS[@]; do
+	base="${font// /}"
+	cask="otf-${${font:l}// /-}"
+	cat > Casks/$cask.rb <<-EOF
+	cask "$cask" do
+	  version "$VERSION"
+	  sha256 "$CHECKSUM"
+
+	  url "https://github.com/microsoft/cascadia-code/releases/download/v#{version}/CascadiaCode-#{version}.zip"
+	  name "$font"
+	  homepage "https://github.com/microsoft/cascadia-code"
+
+	  livecheck do
+	    url :url
+	    strategy :github_latest
+	  end
+
+	  font "otf/static/$base-Bold.otf"
+	  font "otf/static/$base-BoldItalic.otf"
+	  font "otf/static/$base-ExtraLight.otf"
+	  font "otf/static/$base-ExtraLightItalic.otf"
+	  font "otf/static/$base-Italic.otf"
+	  font "otf/static/$base-Light.otf"
+	  font "otf/static/$base-LightItalic.otf"
+	  font "otf/static/$base-Regular.otf"
+	  font "otf/static/$base-SemiBold.otf"
+	  font "otf/static/$base-SemiBoldItalic.otf"
+	  font "otf/static/$base-SemiLight.otf"
+	  font "otf/static/$base-SemiLightItalic.otf"
+	end
+	EOF
+done
+
+[[ $1 != commit ]] && exit
+
+git add Casks
+git commit -m "updated: $VERSION"
+git push
diff --git a/gen.sh b/gen.sh
deleted file mode 100755
index 76398d2..0000000
--- a/gen.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env zsh
-
-export VERSION=2407.24
-export CHECKSUM=e67a68ee3386db63f48b9054bd196ea752bc6a4ebb4df35adce6733da50c8474
-
-NAMES=(
-  'Cascadia Code'
-  'Cascadia Mono'
-  'Cascadia Code PL'
-  'Cascadia Mono PL'
-  'Cascadia Code NF'
-  'Cascadia Mono NF'
-)
-
-for name in $NAMES[@]; do
-  NAME=$name
-  FNAME=${name// /}
-  PKGNAME="otf-${${name:l}// /-}"
-  export NAME FNAME PKGNAME
-  envsubst < template.rb > Casks/$PKGNAME.rb
-done
diff --git a/template.rb b/template.rb
deleted file mode 100644
index f73c1c1..0000000
--- a/template.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-cask "$PKGNAME" do
-  version "$VERSION"
-  sha256 "$CHECKSUM"
-
-  url "https://github.com/microsoft/cascadia-code/releases/download/v#{version}/CascadiaCode-#{version}.zip"
-  name "$NAME"
-  homepage "https://github.com/microsoft/cascadia-code"
-
-  livecheck do
-    url :url
-    strategy :github_latest
-  end
-
-  font "otf/static/$FNAME-Bold.otf"
-  font "otf/static/$FNAME-BoldItalic.otf"
-  font "otf/static/$FNAME-ExtraLight.otf"
-  font "otf/static/$FNAME-ExtraLightItalic.otf"
-  font "otf/static/$FNAME-Italic.otf"
-  font "otf/static/$FNAME-Light.otf"
-  font "otf/static/$FNAME-LightItalic.otf"
-  font "otf/static/$FNAME-Regular.otf"
-  font "otf/static/$FNAME-SemiBold.otf"
-  font "otf/static/$FNAME-SemiBoldItalic.otf"
-  font "otf/static/$FNAME-SemiLight.otf"
-  font "otf/static/$FNAME-SemiLightItalic.otf"
-
-  # No zap stanza required
-end