Skip to content

Instantly share code, notes, and snippets.

@chrissimpkins
Created September 20, 2019 18:34
Show Gist options
  • Save chrissimpkins/c6e23e0586ef5320c4909c2039310167 to your computer and use it in GitHub Desktop.
Save chrissimpkins/c6e23e0586ef5320c4909c2039310167 to your computer and use it in GitHub Desktop.
Example Makefile for font projects
# define project name
PROJECT=replaceme-with-project-name
# define path to the font build directory for tests
FONT_DIR="/path/to/font/file/directory"
venv:
python3 -m venv ~/venv/$(PROJECT)
# can't activate and deactivate from Makefile
# because it runs new subshells for each
# command...
# venv-activate:
# . ~/venv/$(PROJECT)/bin/activate
# venv-deactivate:
# deactivate
install-dep:
# requirements.txt should define all project dependencies for
# builds and testing
pip3 install -r requirements.txt
build:
# add all build commands to this block
# NOTE: important to use TAB for spacing from
# left margin in Makefiles (not spaces)
# Static instance builds
fontmake -g [SOURCE PATH 1] --interpolate -o ttf
# Variable font builds
fontmake -g [SOURCE PATH 1] -o variable
# TODO: could include move source to place the
# builds in the proper directory to follow the
# fontmake steps above
test-fontbakery:
fontbakery check-googlefonts $(FONT_DIR)/*.ttf
.PHONY: venv install-dep build test-fontbakery
@chrissimpkins
Copy link
Author

Create a venv

$ make venv

Activate / deactivate the venv

Must be done manually instead of from the Makefile

Add project dependencies to your activated venv

add the dependencies to a requirements.txt file in the root of the repository, then run:

$ make install-dep

Build font files

$ make build

Test with fontbakery

$ make test-fontbakery

Can add new make targets in the file with the same format and associated command line strings that you use for execution and then run it with make followed by the target name. Make sure to use TAB to space the commands from the left margin, not spaces.

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