#!/usr/bin/make -f CODEPOINT := \\([0-9a-fA-F]{2,5}) .DELETE_ON_ERROR: .SECONDARY: .PHONY: all clean superclean FORMATS := ttf woff FONTSTANDARD := $(addprefix fontstandard.,$(FORMATS)) FAVERSION ?= v4.2.0 URL := https://github.com/FortAwesome/Font-Awesome/raw/$(FAVERSION) SUBVERSION := 1 VERSION := $(shell echo $(FAVERSION) | sed -E 's/[^0-9]//g').$(SUBVERSION) FONTAWESOME := FontAwesome_$(VERSION).otf VARIABLES := variables_$(VERSION).less all: $(FONTSTANDARD) FONTFORGE ?= fontforge CONVERT.ttf.woff := echo 'Open($$1); Generate($$2)' | $(FONTFORGE) fontstandard.ttf: $(FONTAWESOME) fontstandard.fontforge $(FONTFORGE) $< $@ < fontstandard.fontforge %.woff: %.ttf $(CONVERT.ttf.woff) $< $@ $(FONTAWESOME): wget -O $@ $(URL)/fonts/FontAwesome.otf $(VARIABLES): wget -O $@ $(URL)/less/variables.less %.fontforge: $(VARIABLES) %.remove.txt %.preamble.txt %.remap.txt echo 'Open($$1); Reencode("unicode4");' > $@ sed -E 's/__VERSION__/$(VERSION)/' < $*.preamble.txt >> $@ grep -E "@fa-var-("$$(grep -v '^#' $*.remove.txt \ | paste -sd '|' -)")[-a-z]*:" $(VARIABLES) \ | sed -E 's/.*$(CODEPOINT).*/SelectMore(0u\1);/g' >> $@ echo 'DetachAndRemoveGlyphs();' >> $@ grep -v '^#' $*.remap.txt | while read -r dst src rest; do \ (grep -E -m 1 "@fa-var-$${src}:" $(VARIABLES) \ || echo "$${src} not found." >&2) \ | sed -E 's/.*$(CODEPOINT).*/Select(0u\1); CopyReference(); Select(0u'$${dst}'); Paste();/g' >> $@ \ ; done echo 'Generate($$2)' >> $@ clean: $(RM) fontstandard.fontforge $(RM) $(FONTSTANDARD) superclean: clean $(RM) $(FONTAWESOME) $(RM) $(VARIABLES)