font-patcher:
	tmp=$(mktemp); \
	trap "rm -rf '$tmp'" exit; \
	curl -L https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FontPatcher.zip > $tmp; \
	unzip $tmp

LibertinusKeyboard-Regular.otf  LibertinusSans-Bold.otf LibertinusSerif-Bold.otf        LibertinusSerif-Regular.otf LibertinusSerifDisplay-Regular.otf LibertinusMath-Regular.otf LibertinusSans-Italic.otf LibertinusSerif-BoldItalic.otf  LibertinusSerif-Semibold.otf LibertinusSerifInitials-Regular.otf LibertinusMono-Regular.otf LibertinusSans-Regular.otf  LibertinusSerif-Italic.otf LibertinusSerif-SemiboldItalic.otf:
	curl -L https://github.com/alerque/libertinus/releases/download/v7.040/Libertinus-7.040.tar.xz | tar xJ
	ln -sf Libertinus-7.040/static/OTF/* .

LibertinusSerifNerdFontPropo-%.otf: LibertinusSerif-%.otf font-patcher
	./font-patcher $< -c --variable-width-glyphs

LibertinusSansNerdFontPropo-%.otf: LibertinusSans-%.otf font-patcher
	./font-patcher $< -c --variable-width-glyphs

LibertinusMonoNerdFontMono-%.otf: LibertinusMono-%.otf font-patcher
	./font-patcher $< -c --mono

install-%: %
	install -C -D $< $$XDG_DATA_HOME/fonts/$<

install-serif: install-LibertinusSerifNerdFontPropo-Regular.otf install-LibertinusSerifNerdFontPropo-Bold.otf install-LibertinusSerifNerdFontPropo-BoldItalic.otf install-LibertinusSerifNerdFontPropo-Italic.otf

install-mono: install-LibertinusMonoNerdFontMono-Regular.otf

install: install-serif install-mono