Skip to content

Instantly share code, notes, and snippets.

@puzrin
Last active May 13, 2023 07:17
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save puzrin/5537065 to your computer and use it in GitHub Desktop.
Save puzrin/5537065 to your computer and use it in GitHub Desktop.
Makefile example for fontello.com API
# Edit here - set path to you directory with config.json & fonts
FONT_DIR ?= ./assets/vendor/fontello/src
### Don't edit below ###
FONTELLO_HOST ?= https://fontello.com
fontopen:
@if test ! `which curl` ; then \
echo 'Install curl first.' >&2 ; \
exit 128 ; \
fi
curl --silent --show-error --fail --output .fontello \
--form "config=@${FONT_DIR}/config.json" \
${FONTELLO_HOST}
x-www-browser ${FONTELLO_HOST}/`cat .fontello`
fontsave:
@if test ! `which unzip` ; then \
echo 'Install unzip first.' >&2 ; \
exit 128 ; \
fi
@if test ! -e .fontello ; then \
echo 'Run `make fontopen` first.' >&2 ; \
exit 128 ; \
fi
rm -rf .fontello.src .fontello.zip
curl --silent --show-error --fail --output .fontello.zip \
${FONTELLO_HOST}/`cat .fontello`/get
unzip .fontello.zip -d .fontello.src
rm -rf ${FONT_DIR}
mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONT_DIR}
rm -rf .fontello.src .fontello.zip
@sntran
Copy link

sntran commented Feb 17, 2020

For Mac, with fontsave target, you can pipe curl into bsdtar to save a few immediate steps:

fontsave:
	@if test ! `which unzip` ; then \
		echo 'Install unzip first.' >&2 ; \
		exit 128 ; \
		fi
	@if test ! -e .fontello ; then \
		echo 'Run `make fontopen` first.' >&2 ; \
		exit 128 ; \
		fi
	curl --silent --show-error --fail \
		${FONTELLO_HOST}/`cat .fontello`/get \
		| bsdtar --strip-components=1 -xf- -C $@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment