From 870329f52a078272ff7b1014203ac529aeebdfbb Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Fri, 12 Aug 2022 13:37:15 -0500 Subject: [PATCH] simplify workflow using make --- Makefile | 38 ++++++++++++++++++++ README.md | 52 +++++++++++++++++++++++----- font-patcher => bin/font-patcher | 0 patch-monolisa => bin/patch-monolisa | 3 +- update-fonts => bin/update-fonts | 11 ++++-- update-src => bin/update-src | 2 +- 6 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 Makefile rename font-patcher => bin/font-patcher (100%) rename patch-monolisa => bin/patch-monolisa (81%) rename update-fonts => bin/update-fonts (80%) rename update-src => bin/update-src (89%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7b2b280 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +ARGS ?= -c +OK_TYPES := otf ttf woff woff2 +NF_SRC := $(shell find src -type f) +ML_TYPES := $(shell find MonoLisa -mindepth 1 -type d -printf "%f ") + +UNKNOWN := $(filter-out $(OK_TYPES),$(ML_TYPES)) +$(if $(UNKNOWN),$(error unknown font type in ./MonoLisa: $(UNKNOWN))) + +.PHONY: patch +patch: $(addprefix patch-,$(ML_TYPES)) + +patch-%: ./bin/font-patcher + @echo "==> Patching MonoLisa $* Files <==" + @./bin/patch-monolisa $* $(ARGS) + +.PHONY: update-fonts +update-fonts: + @echo "==> Adding Fonts To System <==" + @./bin/update-fonts + @fc-cache -f -v + +.PHONY: check +check: + @echo "==> Checking System For Fonts <==" + @fc-list | grep "MonoLisa" + +.PHONY: update-src +update-src: + @echo "==> Updating Source File <==" + @./bin/update-src + +.PHONY: lint +lint: + @shfmt -w -s $(shell shfmt -f bin/) + +.PHONY: clean +clean: + @rm -r patched/* diff --git a/README.md b/README.md index d66fce5..bc0aade 100644 --- a/README.md +++ b/README.md @@ -2,38 +2,72 @@ *Most* Batteries inlcuded repo to patch MonoLisa with Nerd Fonts glyphs +tested w/ MonoLisa v1.808 + ## Before You Begin First you will need to install `fontforge` There are a number of caveats to invoking the `font-patcher` script. Some of which are explained by [nerd fonts](https://github.com/ryanoasis/nerd-fonts#font-patcher). -Using `patch-monolisa` assumes you have installed fontforge using your system dependency manager. -On ubuntu: `sudo apt-get install fontforge`. +On Arch: + +```bash +sudo pacman -S fontforge +``` + +You can also download the version for your system from the releases in the fontforge [repo](https://github.com/fontforge/fontforge). ## Downloading MonoLisa Once you have acquired MonoLisa, follow the link in your email to download it. -Then extract the `.zip` into `MonoLisa/`. +Then extract the `.zip` file of the type you've downloaded into `MonoLisa/`. + +The expected directory structure is below. +You only need to download the font types you plan to use. + +```bash +MonoLisa +├── otf +├── ttf +├── woff +└── woff2 +``` ## Patching your font Once you have downloaded MonoLisa and `fontforge` -you can easily apply the nerd font patches using the `patch-monolisa` script. -The only required argument is the font file extension you want to patch. -All remaining supplied arguments are passed to the `font-patcher` script. +you can easily apply the nerd font patches with `make`. + +To patch all font types use the default `patch` rule. + ```bash -./patch-monolisa otf -c -w +make +``` + +By default the complete (`-c`) flag is passed to the font-patcher script to include all icons/symbols. +You can change this by specifying the `ARGS` at runtime. + + +```bash +ARGS="-c -w" make patch ``` You can find your patched fonts in the `patched/` directory -If like me you want to place your patched fonts in a standard location on your Unix system you can move them to `~/.local/share/fonts/MonoLisa` with the `update-fonts` script. +If like me you want to place your patched fonts in a standard location on your Unix system you can move them to `~/.local/share/fonts/MonoLisa` with the `bin/update-fonts` script. + +Or for simplicity you can copy the fonts and update the cache with: +```bash +make update-fonts +``` + +You can verify the fonts have been added with `make check`. ## Changing the Batteries -If I haven't committed to this repo in a while it's likely a good idea to run `update-src` to update the fonts, icons and patcher script. +If I haven't committed to this repo in a while it's likely a good idea to run `make update-src` to update the fonts, icons and patcher script from nerd fonts. ## Special Thanks diff --git a/font-patcher b/bin/font-patcher similarity index 100% rename from font-patcher rename to bin/font-patcher diff --git a/patch-monolisa b/bin/patch-monolisa similarity index 81% rename from patch-monolisa rename to bin/patch-monolisa index 03d1310..c3d0f3d 100755 --- a/patch-monolisa +++ b/bin/patch-monolisa @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -e exts=(otf ttf woff woff2) ext=$1 @@ -22,6 +23,6 @@ echo "Using the following arguments for font-patcher $fp_args" for fontfile in MonoLisa/$ext/*.$ext; do - fontforge -script font-patcher $fontfile -o patched/$ext $fp_args + fontforge -script ./bin/font-patcher $fontfile --glyphdir ./src/glyphs/ -o ./patched/$ext $fp_args done diff --git a/update-fonts b/bin/update-fonts similarity index 80% rename from update-fonts rename to bin/update-fonts index ce720ff..6acf934 100755 --- a/update-fonts +++ b/bin/update-fonts @@ -1,18 +1,23 @@ #!/usr/bin/env bash +set -e + PATCHED_FONTS=./patched INSTALL_DIR=~/.local/share/fonts/MonoLisa +mkdir -p $INSTALL_DIR + for font_dir in $PATCHED_FONTS/*; do patched_dir="${font_dir##*/}" echo ">>> $patched_dir" - if [[ -d "${INSTALL_DIR}/${patched_dir}" ]]; then + dest=$INSTALL_DIR/$patched_dir + + if [[ -d ${dest} ]]; then echo "deleting existing version" - rm -rf $INSTALL_DIR/$patched_dir + rm -rf $dest fi - dest=$INSTALL_DIR/$patched_dir mkdir $dest && cp -v $font_dir/* $dest done diff --git a/update-src b/bin/update-src similarity index 89% rename from update-src rename to bin/update-src index 9f09a16..293c051 100755 --- a/update-src +++ b/bin/update-src @@ -9,7 +9,7 @@ cd nerd-fonts git sparse-checkout add src/glyphs git checkout -cp font-patcher ../font-patcher +cp font-patcher ../bin/font-patcher cp src/glyphs/** ../src/glyphs -r echo "don't forget to commit your changes!"