simplify workflow using make

This commit is contained in:
Daylin Morgan 2022-08-12 13:37:15 -05:00
parent 312b059e67
commit 870329f52a
6 changed files with 92 additions and 14 deletions

38
Makefile Normal file
View file

@ -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/*

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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!"