1
1
mirror of https://github.com/rsms/inter.git synced 2024-11-24 05:30:41 +03:00
inter/Makefile

338 lines
11 KiB
Makefile
Raw Normal View History

2017-08-22 10:05:20 +03:00
# Targets:
# all Build everything
# test Build and test everyything (implies all_check)
# install Build and install all OTF files. (currently Mac-only)
# zip Build a complete release-grade ZIP archive of all fonts.
# dist Create a new release distribution. Does everything.
#
# all_const Build all non-variable files
# all_const_hinted Build all non-variable files with hints
# all_var Build all variable files
# all_var_hinted Build all variable files with hints (disabled)
#
# all_otf Build all OTF files into FONTDIR/const
# all_ttf Build all TTF files into FONTDIR/const
# all_ttf_hinted Build all TTF files with hints into FONTDIR/const-hinted
# all_web, web Build all WOFF files into FONTDIR/const
# all_web_hinted Build all WOFF files with hints into FONTDIR/const-hinted
# all_var Build all variable font files into FONTDIR/var
# all_var_hinted Build all variable font files with hints into
# FONTDIR/var-hinted
#
2019-02-03 01:29:56 +03:00
# designspace Build src/Inter.designspace from src/Inter.glyphs
#
# Style-specific targets:
# STYLE_otf Build OTF file for STYLE into FONTDIR/const
# STYLE_ttf Build TTF file for STYLE into FONTDIR/const
# STYLE_ttf_hinted Build TTF file for STYLE with hints into
# FONTDIR/const-hinted
# STYLE_web Build WOFF files for STYLE into FONTDIR/const
# STYLE_web_hinted Build WOFF files for STYLE with hints into
# FONTDIR/const-hinted
# STYLE_check Build & check OTF and TTF files for STYLE
2017-08-22 10:05:20 +03:00
#
# "build" directory output structure:
# fonts
# const
# const-hinted
# var
# var-hinted (disabled)
#
FONTDIR = build/fonts
all: all_const all_const_hinted all_var
web: all_web
all_const: all_otf all_ttf all_web
all_const_hinted: all_ttf_hinted all_web_hinted
var: \
2019-02-03 01:29:56 +03:00
$(FONTDIR)/var/Inter.var.woff2 \
$(FONTDIR)/var/Inter.var.ttf
all_var: \
2019-02-03 01:29:56 +03:00
$(FONTDIR)/var/Inter.var.woff2 \
$(FONTDIR)/var/Inter.var.ttf \
$(FONTDIR)/var/Inter-upright.var.woff2 \
2019-03-27 21:21:26 +03:00
$(FONTDIR)/var/Inter-italic.var.woff2 \
$(FONTDIR)/var/Inter-upright.var.ttf \
$(FONTDIR)/var/Inter-italic.var.ttf
all_ufo_masters = $(Thin_ufo_d) \
$(ThinItalic_ufo_d) \
$(Regular_ufo_d) \
$(Italic_ufo_d) \
$(Black_ufo_d) \
$(BlackItalic_ufo_d)
# Hinted variable font disabled. See https://github.com/rsms/inter/issues/75
2019-02-03 01:29:56 +03:00
# all_var_hinted: $(FONTDIR)/var-hinted/Inter.var.ttf $(FONTDIR)/var-hinted/Inter.var.woff2
# .PHONY: all_var_hinted
.PHONY: all_const all_const_hinted var all_var
2018-09-10 20:21:35 +03:00
export PATH := $(PWD)/build/venv/bin:$(PATH)
2017-08-22 22:46:29 +03:00
2017-08-22 10:05:20 +03:00
# generated.make is automatically generated by init.sh and defines depenencies for
# all styles and alias targets
include build/etc/generated.make
# TTF -> WOFF2
build/%.woff2: build/%.ttf
woff2_compress "$<"
# TTF -> WOFF
build/%.woff: build/%.ttf
ttf2woff -O -t woff "$<" "$@"
# make sure intermediate TTFs are not gc'd by make
.PRECIOUS: build/%.ttf
2018-09-14 20:55:23 +03:00
# Master UFOs -> variable TTF
$(FONTDIR)/var/Inter.var.ttf: src/Inter.designspace $(all_ufo_masters) version.txt
misc/fontbuild compile-var -o $@ $(FONTBUILD_FLAGS) $<
$(FONTDIR)/var/Inter-%.var.ttf: src/Inter-%.designspace $(all_ufo_masters) version.txt
misc/fontbuild compile-var -o $@ $(FONTBUILD_FLAGS) $<
misc/tools/fix-vf-meta.py $@
# Instance UFO -> OTF, TTF (note: masters' rules in generated.make)
$(FONTDIR)/const/Inter-%.otf: build/ufo/Inter-%.ufo version.txt
misc/fontbuild compile -o $@ $(FONTBUILD_FLAGS) $<
2017-08-22 10:05:20 +03:00
$(FONTDIR)/const/Inter-%.ttf: build/ufo/Inter-%.ufo version.txt
misc/fontbuild compile -o $@ $(FONTBUILD_FLAGS) $<
2017-08-22 10:05:20 +03:00
# designspace <- glyphs file
src/Inter-upright.designspace: src/Inter.designspace
src/Inter-italic.designspace: src/Inter.designspace
2019-02-03 01:29:56 +03:00
src/Inter.designspace: src/Inter.glyphs
misc/fontbuild glyphsync $<
2017-08-22 10:05:20 +03:00
2018-11-26 19:57:00 +03:00
# make sure intermediate files are not gc'd by make
2019-02-03 01:29:56 +03:00
.PRECIOUS: src/Inter-*.designspace
2018-11-26 19:57:00 +03:00
2019-02-03 01:29:56 +03:00
designspace: src/Inter.designspace
.PHONY: designspace
2018-09-10 20:21:35 +03:00
# short-circuit Make for performance
2019-02-03 01:29:56 +03:00
src/Inter.glyphs:
@true
# instance UFOs <- master UFOs
build/ufo/Inter-%.ufo: build/ufo/features src/Inter.designspace $(all_ufo_masters)
2019-02-03 01:29:56 +03:00
misc/fontbuild instancegen src/Inter.designspace $*
build/ufo/features:
ln -s ../../src/features build/ufo/features
# make sure intermediate UFOs are not gc'd by make
2019-02-03 01:29:56 +03:00
.PRECIOUS: build/ufo/Inter-%.ufo
# Note: The seemingly convoluted dependency graph above is required to
# make sure that glyphsync and instancegen are not run in parallel.
# hinted TTF files via autohint
$(FONTDIR)/const-hinted/%.ttf: $(FONTDIR)/const/%.ttf
mkdir -p "$(dir $@)"
ttfautohint --fallback-stem-width=256 --no-info "$<" "$@"
# python -m ttfautohint --fallback-stem-width=256 --no-info "$<" "$@"
# $(FONTDIR)/var-hinted/%.ttf: $(FONTDIR)/var/%.ttf
# mkdir -p "$(dir $@)"
# ttfautohint --fallback-stem-width=256 --no-info "$<" "$@"
# make sure intermediate TTFs are not gc'd by make
.PRECIOUS: $(FONTDIR)/const/%.ttf $(FONTDIR)/const-hinted/%.ttf $(FONTDIR)/var/%.var.ttf
# check var
test_var: all_var
misc/fontbuild checkfont $(FONTDIR)/var/*.ttf $(FONTDIR)/var/*.woff2
2017-08-22 10:05:20 +03:00
# test runs all tests
# Note: all_check_const is generated by init.sh and runs "fontbuild checkfont"
# on all otf and ttf files.
test: all_check_const test_var
@echo "test: all ok"
# check does the same thing as test, but without any dependency checks, meaning
# it will check whatever font files are already built.
check:
misc/fontbuild checkfont \
$(FONTDIR)/const/*.ttf \
$(FONTDIR)/const/*.otf \
$(FONTDIR)/const/*.woff2 \
$(FONTDIR)/var/*.ttf \
$(FONTDIR)/var/*.woff2
@echo "check: all ok"
.PHONY: test check
# samples renders PDF and PNG samples
samples: $(FONTDIR)/samples all_samples_pdf all_samples_png
$(FONTDIR)/samples/%.pdf: $(FONTDIR)/const/%.otf
misc/tools/fontsample/fontsample -o "$@" "$<"
$(FONTDIR)/samples/%.png: $(FONTDIR)/const/%.otf
misc/tools/fontsample/fontsample -o "$@" "$<"
$(FONTDIR)/samples:
mkdir -p $@
ZD = build/tmp/zip
# intermediate zip target that creates a zip file at build/tmp/a.zip
build/tmp/a.zip:
@rm -rf "$(ZD)"
@rm -f build/tmp/a.zip
2017-08-22 10:05:20 +03:00
@mkdir -p \
2019-02-03 01:29:56 +03:00
"$(ZD)/Inter (web)" \
"$(ZD)/Inter (web hinted)" \
"$(ZD)/Inter (TTF)" \
"$(ZD)/Inter (TTF hinted)" \
"$(ZD)/Inter (TTF variable)" \
"$(ZD)/Inter (OTF)"
@#
@# copy font files
cp -a $(FONTDIR)/const/*.woff \
$(FONTDIR)/const/*.woff2 \
2019-02-03 01:29:56 +03:00
$(FONTDIR)/var/*.woff2 "$(ZD)/Inter (web)/"
cp -a $(FONTDIR)/const-hinted/*.woff \
$(FONTDIR)/const-hinted/*.woff2 \
"$(ZD)/Inter (web hinted)/"
2019-02-03 01:29:56 +03:00
cp -a $(FONTDIR)/const/*.ttf "$(ZD)/Inter (TTF)/"
cp -a $(FONTDIR)/const-hinted/*.ttf "$(ZD)/Inter (TTF hinted)/"
cp -a $(FONTDIR)/var/*.ttf "$(ZD)/Inter (TTF variable)/"
cp -a $(FONTDIR)/const/*.otf "$(ZD)/Inter (OTF)/"
@#
@# copy misc stuff
cp -a misc/dist/inter.css "$(ZD)/Inter (web)/"
cp -a misc/dist/inter.css "$(ZD)/Inter (web hinted)/"
cp -a misc/dist/*.txt "$(ZD)/"
cp -a LICENSE.txt "$(ZD)/"
@#
@# Add "beta" to Light and Thin filenames.
@# Requires "rename" tool in PATH (`brew install rename` on macOS)
2019-02-03 01:29:56 +03:00
rename 's/(Light.*|Thin.*)\./$$1-BETA./' "$(ZD)/Inter"*/*.*
@#
@# zip
cd "$(ZD)" && zip -q -X -r "../../../$@" * && cd ../..
@rm -rf "$(ZD)"
2017-08-22 10:05:20 +03:00
# load version, used by zip and dist
VERSION := $(shell cat version.txt)
# distribution zip files
2019-02-03 01:29:56 +03:00
ZIP_FILE_DIST := build/release/Inter-${VERSION}.zip
2017-08-22 22:46:29 +03:00
# zip
2019-02-03 01:29:56 +03:00
build/release/Inter-%.zip: build/tmp/a.zip
2017-08-22 22:46:29 +03:00
@mkdir -p "$(shell dirname "$@")"
@mv -f "$<" "$@"
@echo write "$@"
@sh -c "if [ -f /usr/bin/open ]; then /usr/bin/open --reveal '$@'; fi"
2017-08-22 22:46:29 +03:00
zip: all
$(MAKE) check
2019-02-03 01:29:56 +03:00
$(MAKE) build/release/Inter-${VERSION}-$(shell git rev-parse --short=10 HEAD).zip
zip_dist: pre_dist
$(MAKE) check
$(MAKE) ${ZIP_FILE_DIST}
.PHONY: zip zip_dist
2017-08-22 22:46:29 +03:00
2018-09-04 05:01:04 +03:00
# distribution
pre_dist: all
2017-08-22 22:46:29 +03:00
@echo "Creating distribution for version ${VERSION}"
@if [ -f "${ZIP_FILE_DIST}" ]; \
then echo "${ZIP_FILE_DIST} already exists. Bump version or remove the zip file to continue." >&2; \
exit 1; \
fi
2017-09-25 20:38:15 +03:00
dist: zip_dist
$(MAKE) -j docs
misc/tools/versionize.py
2017-08-22 22:46:29 +03:00
@echo "——————————————————————————————————————————————————————————————————"
@echo ""
2017-09-12 08:42:54 +03:00
@echo "Next steps:"
@echo ""
@echo "1) Commit & push changes"
@echo ""
@echo "2) Create new release with ${ZIP_FILE_DIST} at"
@echo " https://github.com/rsms/inter/releases/new?tag=v${VERSION}"
2017-08-22 22:46:29 +03:00
@echo ""
2018-09-04 05:01:04 +03:00
@echo "3) Bump version in version.txt (to the next future version)"
2017-08-22 22:46:29 +03:00
@echo ""
@echo "——————————————————————————————————————————————————————————————————"
docs: docs_fonts
$(MAKE) -j docs_info
docs_info: docs/_data/fontinfo.json \
docs/lab/glyphinfo.json \
docs/glyphs/metrics.json
docs_fonts:
2017-09-12 08:42:54 +03:00
rm -rf docs/font-files
mkdir docs/font-files
cp -a $(FONTDIR)/const/*.woff \
$(FONTDIR)/const/*.woff2 \
$(FONTDIR)/const/*.otf \
$(FONTDIR)/var/*.* \
docs/font-files/
2017-09-12 08:42:54 +03:00
.PHONY: docs docs_info docs_fonts
2019-02-03 01:29:56 +03:00
docs/_data/fontinfo.json: docs/font-files/Inter-Regular.otf misc/tools/fontinfo.py
2018-09-04 03:00:19 +03:00
misc/tools/fontinfo.py -pretty $< > docs/_data/fontinfo.json
docs/lab/glyphinfo.json: build/UnicodeData.txt misc/tools/gen-glyphinfo.py $(Regular_ufo_d)
misc/tools/gen-glyphinfo.py -ucd $< src/Inter-Regular.ufo > $@
2018-09-04 03:00:19 +03:00
docs/glyphs/metrics.json: $(Regular_ufo_d) misc/tools/gen-metrics-and-svgs.py
2019-02-03 01:29:56 +03:00
misc/tools/gen-metrics-and-svgs.py src/Inter-Regular.ufo
# Download latest Unicode data
build/UnicodeData.txt:
@echo fetch http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
@curl '-#' -o "$@" http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
# install targets
install_ttf: all_ttf_const
2019-02-03 01:29:56 +03:00
@echo "Installing TTF files locally at ~/Library/Fonts/Inter"
rm -rf ~/'Library/Fonts/Inter'
mkdir -p ~/'Library/Fonts/Inter'
cp -va $(FONTDIR)/const/*.ttf ~/'Library/Fonts/Inter'
install_ttf_hinted: all_ttf_hinted
2019-02-03 01:29:56 +03:00
@echo "Installing autohinted TTF files locally at ~/Library/Fonts/Inter"
rm -rf ~/'Library/Fonts/Inter'
mkdir -p ~/'Library/Fonts/Inter'
cp -va $(FONTDIR)/const-hinted/*.ttf ~/'Library/Fonts/Inter'
2017-08-22 10:05:20 +03:00
install_otf: all_otf
2019-02-03 01:29:56 +03:00
@echo "Installing OTF files locally at ~/Library/Fonts/Inter"
rm -rf ~/'Library/Fonts/Inter'
mkdir -p ~/'Library/Fonts/Inter'
cp -va $(FONTDIR)/const/*.otf ~/'Library/Fonts/Inter'
2017-08-22 10:05:20 +03:00
install: install_otf
2017-08-22 10:05:20 +03:00
# clean removes generated and built fonts in the build directory
2017-08-22 10:05:20 +03:00
clean:
rm -rvf build/tmp build/fonts
2017-08-22 10:05:20 +03:00
.PHONY: all web clean install install_otf install_ttf deploy pre_dist dist geninfo glyphsync