diff options
author | Rasmus Andersson <rasmus@notion.se> | 2020-04-06 00:18:45 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2020-04-06 00:18:45 +0300 |
commit | 2065cd3073fc0c4ff7696d665cbb82d6cdce5b39 (patch) | |
tree | edc1f786addceda50b16e298e1a9a31ed3f9c1cd | |
parent | c2a946c8c8bde00fc5145eedd1a52941b7da6cfd (diff) | |
download | inter-2065cd3073fc0c4ff7696d665cbb82d6cdce5b39.tar.xz |
make: updated makefile + init script with githook for running the init script
-rw-r--r-- | Makefile | 134 | ||||
-rwxr-xr-x | init.sh | 98 | ||||
-rw-r--r-- | misc/git-hooks/post-checkout.sh | 2 | ||||
-rwxr-xr-x | misc/makezip.sh | 145 |
4 files changed, 275 insertions, 104 deletions
@@ -1,25 +1,12 @@ -# Targets: +# High-level make 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 -# -# designspace Build build/ufo/Inter.designspace from src/Inter.glyphs +# all_text Build all Inter (non-dislay) fonts +# all_display Build all Inter Display fonts +# web Build all web fonts +# var Build all variable fonts +# zip Build a complete ZIP archive of all fonts. +# test Build and test everyything +# install Build and install all OTF files (macOS only) # # Style-specific targets: # STYLE_otf Build OTF file for STYLE into FONTDIR/const @@ -36,24 +23,29 @@ # const # const-hinted # var -# var-hinted (disabled) # FONTDIR = build/fonts -all: all_const all_const_hinted all_var -web: all_web -.PHONY: all web +all: all_text all_display web -all_const: all_otf all_ttf all_web -all_const_hinted: all_ttf_hinted all_web_hinted -var: var_text var_display -var_text: \ - $(FONTDIR)/var/Inter.var.woff2 \ - $(FONTDIR)/var/Inter.var.otf -var_display: \ - $(FONTDIR)/var/InterDisplay.var.woff2 \ - $(FONTDIR)/var/InterDisplay.var.otf -all_var: \ +# all fonts of a certain type +all_otf: all_otf_text all_otf_display +all_ttf: all_ttf_text all_ttf_display all_ttf_text_hinted all_ttf_display_hinted + +# all fonts of given variant +all_text: all_otf_text all_ttf_text all_ttf_text_hinted all_var_text web_text +all_display: all_otf_display all_ttf_display all_ttf_display_hinted all_var_display web_display + +# web fonts +web: web_text web_display +web_text: all_web_text all_web_hinted_text +web_display: all_web_display all_web_hinted_display + +# variable fonts +var: all_var_text all_var_display +var_text: $(FONTDIR)/var/Inter.var.woff2 $(FONTDIR)/var/Inter.var.otf +var_display: $(FONTDIR)/var/InterDisplay.var.woff2 $(FONTDIR)/var/InterDisplay.var.otf +all_var_text: \ $(FONTDIR)/var/Inter.var.otf \ $(FONTDIR)/var/Inter.var.woff2 \ $(FONTDIR)/var/Inter-V.var.otf \ @@ -61,7 +53,8 @@ all_var: \ $(FONTDIR)/var/Inter-roman.var.otf \ $(FONTDIR)/var/Inter-roman.var.woff2 \ $(FONTDIR)/var/Inter-italic.var.otf \ - $(FONTDIR)/var/Inter-italic.var.woff2 \ + $(FONTDIR)/var/Inter-italic.var.woff2 +all_var_display: \ $(FONTDIR)/var/InterDisplay.var.otf \ $(FONTDIR)/var/InterDisplay.var.woff2 \ $(FONTDIR)/var/InterDisplay-V.var.otf \ @@ -71,11 +64,12 @@ all_var: \ $(FONTDIR)/var/InterDisplay-italic.var.otf \ $(FONTDIR)/var/InterDisplay-italic.var.woff2 +.PHONY: all all_otf all_ttf all_text all_display +.PHONY: web web_text web_display +.PHONY: var var_text var_display all_var_text all_var_display + # Hinted variable font disabled. See https://github.com/rsms/inter/issues/75 # all_var_hinted: $(FONTDIR)/var-hinted/Inter.var.otf $(FONTDIR)/var-hinted/Inter.var.woff2 -# .PHONY: all_var_hinted - -.PHONY: all_const all_const_hinted var var_text var_display all_var export PATH := $(PWD)/build/venv/bin:$(PATH) @@ -189,29 +183,38 @@ $(FONTDIR)/const-hinted/%.ttf: $(FONTDIR)/const/%.ttf - -# check var -test_var: all_var - misc/fontbuild checkfont $(FONTDIR)/var/*.otf $(FONTDIR)/var/*.woff2 - # 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 +test: check_all_text check_all_display + misc/fontbuild checkfont $(FONTDIR)/var/*.otf $(FONTDIR)/var/*.woff2 @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: +check_text: + misc/fontbuild checkfont \ + $(FONTDIR)/const/Inter-*.ttf \ + $(FONTDIR)/const/Inter-*.otf \ + $(FONTDIR)/const/Inter-*.woff2 \ + $(FONTDIR)/var/Inter.var.otf \ + $(FONTDIR)/var/Inter.var.woff2 \ + $(FONTDIR)/var/Inter-*.var.otf \ + $(FONTDIR)/var/Inter-*.var.woff2 + @echo "check_text: all ok" + +check_display: misc/fontbuild checkfont \ - $(FONTDIR)/const/*.ttf \ - $(FONTDIR)/const/*.otf \ - $(FONTDIR)/const/*.woff2 \ - $(FONTDIR)/var/*.otf \ - $(FONTDIR)/var/*.woff2 - @echo "check: all ok" + $(FONTDIR)/const/InterDisplay-*.ttf \ + $(FONTDIR)/const/InterDisplay-*.otf \ + $(FONTDIR)/const/InterDisplay-*.woff2 \ + $(FONTDIR)/var/InterDisplay.var.otf \ + $(FONTDIR)/var/InterDisplay.var.woff2 \ + $(FONTDIR)/var/InterDisplay-*.var.otf \ + $(FONTDIR)/var/InterDisplay-*.var.woff2 + @echo "check_display: all ok" -.PHONY: test check +.PHONY: test check check_text check_display @@ -297,15 +300,26 @@ build/release/Inter-%.zip: build/tmp/a.zip @sh -c "if [ -f /usr/bin/open ]; then /usr/bin/open --reveal '$@'; fi" zip: all - $(MAKE) check - $(MAKE) build/release/Inter-${VERSION}-$(shell git rev-parse --short=10 HEAD).zip + $(MAKE) check_text check_display + bash misc/makezip.sh -all \ + "build/release/Inter-${VERSION}-$(shell git rev-parse --short=10 HEAD).zip" + +zip_text: all + $(MAKE) check_text + bash misc/makezip.sh -text \ + "build/release/Inter-${VERSION}-text-$(shell git rev-parse --short=10 HEAD).zip" + +zip_display: all + $(MAKE) check_display + bash misc/makezip.sh -display \ + "build/release/Inter-${VERSION}-display-$(shell git rev-parse --short=10 HEAD).zip" zip_dist: pre_dist - $(MAKE) check - $(MAKE) ${ZIP_FILE_DIST} + $(MAKE) check_text + bash misc/makezip.sh -text "build/release/Inter-${VERSION}.zip" # distribution -pre_dist: all +pre_dist: all_text @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; \ @@ -381,13 +395,13 @@ install_ttf_hinted: all_ttf_hinted mkdir -p ~/'Library/Fonts/Inter' cp -a $(FONTDIR)/const-hinted/*.ttf ~/'Library/Fonts/Inter' -install_text_otf: all_text_otf +install_text_otf: all_otf_text @echo "Installing OTF files locally at ~/Library/Fonts/Inter" rm -rf ~/'Library/Fonts/Inter' mkdir -p ~/'Library/Fonts/Inter' cp -a $(FONTDIR)/const/Inter-*.otf ~/'Library/Fonts/Inter' -install_display_otf: all_display_otf +install_display_otf: all_otf_display @echo "Installing OTF files locally at ~/Library/Fonts/InterDisplay" rm -rf ~/'Library/Fonts/InterDisplay' mkdir -p ~/'Library/Fonts/InterDisplay' @@ -52,6 +52,21 @@ else # —————————————————————————————————————————————————————————————————— + # git hooks + if [ -d .git ] && [ -d misc/git-hooks ]; then + mkdir -p .git/hooks + pushd .git/hooks >/dev/null + for f in ../../misc/git-hooks/*.sh; do + HOOKFILE=$(basename "$f" .sh) + if ! [ -f "$HOOKFILE" ]; then + ln -vfs "$f" "$HOOKFILE" + fi + done + popd >/dev/null + fi + + + # —————————————————————————————————————————————————————————————————— # virtualenv mkdir -p "$VENV_DIR" @@ -539,64 +554,74 @@ else echo "" >> "$GEN_MAKE_FILE" done - # all_otf target - echo -n "all_otf:" >> "$GEN_MAKE_FILE" + # all_otf_* target + echo -n "all_otf_text:" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do echo -n " ${style}_otf" >> "$GEN_MAKE_FILE" - echo -n " display_${style}_otf" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" - - # all_text_otf target - echo -n "all_text_otf:" >> "$GEN_MAKE_FILE" + echo -n "all_otf_display:" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do - echo -n " ${style}_otf" >> "$GEN_MAKE_FILE" + echo -n " display_${style}_otf" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" - # all_display_otf target - echo -n "all_display_otf:" >> "$GEN_MAKE_FILE" + # all_ttf_* target + echo -n "all_ttf_text:" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do - echo -n " display_${style}_otf" >> "$GEN_MAKE_FILE" + echo -n " ${style}_ttf" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" - - # all_ttf target - echo -n "all_ttf:" >> "$GEN_MAKE_FILE" + echo -n "all_ttf_display:" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do - echo -n " ${style}_ttf" >> "$GEN_MAKE_FILE" echo -n " display_${style}_ttf" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" - # all_ttf_hinted target - echo -n "all_ttf_hinted:" >> "$GEN_MAKE_FILE" + # all_ttf_*_hinted target + echo -n "all_ttf_text_hinted:" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do echo -n " ${style}_ttf_hinted" >> "$GEN_MAKE_FILE" + done + echo "" >> "$GEN_MAKE_FILE" + echo -n "all_ttf_display_hinted:" >> "$GEN_MAKE_FILE" + for style in "${all_styles[@]}"; do echo -n " display_${style}_ttf_hinted" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" - # all_web target - echo -n "all_web:" >> "$GEN_MAKE_FILE" + # all_web_* target + echo -n "all_web_text:" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do echo -n " ${style}_web" >> "$GEN_MAKE_FILE" + done + echo "" >> "$GEN_MAKE_FILE" + echo -n "all_web_display:" >> "$GEN_MAKE_FILE" + for style in "${all_styles[@]}"; do echo -n " display_${style}_web" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" - # all_web_hinted target - echo -n "all_web_hinted:" >> "$GEN_MAKE_FILE" + # all_web_*_hinted target + echo -n "all_web_hinted_text:" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do echo -n " ${style}_web_hinted" >> "$GEN_MAKE_FILE" + done + echo "" >> "$GEN_MAKE_FILE" + echo -n "all_web_hinted_display:" >> "$GEN_MAKE_FILE" + for style in "${all_styles[@]}"; do echo -n " display_${style}_web_hinted" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" - # all_check_const target - echo -n "all_check_const:" >> "$GEN_MAKE_FILE" + # check_all_* target + echo -n "check_all_text:" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do echo -n " ${style}_check" >> "$GEN_MAKE_FILE" + done + echo "" >> "$GEN_MAKE_FILE" + echo -n "check_all_display:" >> "$GEN_MAKE_FILE" + for style in "${all_styles[@]}"; do echo -n " display_${style}_check" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" @@ -617,31 +642,16 @@ else done echo "" >> "$GEN_MAKE_FILE" - # all_const_fonts target - # echo -n "all_const_fonts:" >> "$GEN_MAKE_FILE" - # for style in "${all_styles[@]}"; do - # echo -n " ${style}" >> "$GEN_MAKE_FILE" - # done - # echo "" >> "$GEN_MAKE_FILE" - - # googlefonts_all target - echo -n "googlefonts_all:" >> "$GEN_MAKE_FILE" - echo -n " build/googlefonts/var/Inter.var.otf" >> "$GEN_MAKE_FILE" - echo -n " build/googlefonts/var/Inter.var.woff2" >> "$GEN_MAKE_FILE" - echo -n " build/googlefonts/var/Inter-roman.var.otf" >> "$GEN_MAKE_FILE" - echo -n " build/googlefonts/var/Inter-roman.var.woff2" >> "$GEN_MAKE_FILE" - echo -n " build/googlefonts/var/Inter-italic.var.otf" >> "$GEN_MAKE_FILE" - echo -n " build/googlefonts/var/Inter-italic.var.woff2" >> "$GEN_MAKE_FILE" - for style in "${all_styles[@]}"; do - echo -n " build/googlefonts/const/Inter-${style}.otf" >> "$GEN_MAKE_FILE" - echo -n " build/googlefonts/const/Inter-${style}.woff2" >> "$GEN_MAKE_FILE" - done - echo "" >> "$GEN_MAKE_FILE" - - echo -n ".PHONY: all_otf all_ttf_hinted all_ttf all_web all_web_hinted all_ufo all_check_const" >> "$GEN_MAKE_FILE" + echo -n ".PHONY:" >> "$GEN_MAKE_FILE" + echo -n " all_otf_text all_otf_display" >> "$GEN_MAKE_FILE" + echo -n " all_ttf_text all_ttf_display all_ttf_hinted_text all_ttf_hinted_display" >> "$GEN_MAKE_FILE" + echo -n " all_web_text all_web_display all_web_hinted_text all_web_hinted_display" >> "$GEN_MAKE_FILE" + echo -n " check_all_text check_all_display" >> "$GEN_MAKE_FILE" + echo -n " all_samples_pdf all_samples_png" >> "$GEN_MAKE_FILE" for style in "${all_styles[@]}"; do echo -n " ${style} ${style}_ttf ${style}_ttf_hinted ${style}_otf ${style}_check" >> "$GEN_MAKE_FILE" + echo -n " display_${style} display_${style}_ttf display_${style}_ttf_hinted display_${style}_otf display_${style}_check" >> "$GEN_MAKE_FILE" done echo "" >> "$GEN_MAKE_FILE" fi diff --git a/misc/git-hooks/post-checkout.sh b/misc/git-hooks/post-checkout.sh new file mode 100644 index 000000000..c32d46c55 --- /dev/null +++ b/misc/git-hooks/post-checkout.sh @@ -0,0 +1,2 @@ +#!/bin/bash -e +bash init.sh diff --git a/misc/makezip.sh b/misc/makezip.sh new file mode 100755 index 000000000..96bedef66 --- /dev/null +++ b/misc/makezip.sh @@ -0,0 +1,145 @@ +#!/bin/bash -e +cd "$(dirname "$0")/.." + +OPT_HELP=false +OPT_TEXT=false +OPT_DISPLAY=false +OUTFILE= + +# parse args +while [[ $# -gt 0 ]]; do + case "$1" in + -h*|--h*) + OPT_HELP=true + shift + ;; + -text|--text) + OPT_TEXT=true + shift + ;; + -display|--display) + OPT_DISPLAY=true + shift + ;; + -a*|--a*) + OPT_TEXT=true + OPT_DISPLAY=true + shift + ;; + -*) + echo "$0: Unknown option $1" >&2 + OPT_HELP=true + shift + ;; + *) + if [[ "$OUTFILE" != "" ]] && ! $OPT_HELP; then + echo "$0: Extra unexpected argument(s) after <outfile>" >&2 + OPT_HELP=true + fi + OUTFILE=$1 + shift + ;; + esac +done +if (! $OPT_TEXT && ! $OPT_DISPLAY); then + OPT_HELP=true + echo "$0: Need at least one of: -all, -display, -text" >&2 +fi +if $OPT_HELP; then + echo "Usage: $0 [options] <outfile>" + echo "Options:" + echo " -h, -help Show help." + echo " -text Include Inter Text" + echo " -display Include Inter Display" + echo " -a, -all Include all fonts" + exit 1 +fi + +# tmp dir +ZIPDIR=build/tmp/zip +FONTDIR=build/fonts + +# convert relative path to absolute if needed +OUTFILE_ABS=$OUTFILE +if [[ "$OUTFILE_ABS" != /* ]]; then + OUTFILE_ABS=$PWD/$OUTFILE_ABS +fi + +# cleanup any previous build +rm -rf "$ZIPDIR" +rm -f build/tmp/a.zip + +# create directories +mkdir -p \ + "$ZIPDIR/Inter Desktop" \ + "$ZIPDIR/Inter Hinted for Windows/Desktop" \ + "$ZIPDIR/Inter Hinted for Windows/Web" \ + "$ZIPDIR/Inter Variable" \ + "$ZIPDIR/Inter Variable/Single axis" \ + "$ZIPDIR/Inter Web" + +# copy font files +# ---------------------------------------------------------------------------- +if $OPT_TEXT; then + # Inter Desktop + cp $FONTDIR/const/Inter-*.otf "$ZIPDIR/Inter Desktop/" & + cp $FONTDIR/var/Inter-V.var.otf "$ZIPDIR/Inter Desktop/Inter-V.otf" & + + # Inter Hinted for Windows + cp "misc/dist/about hinted fonts.txt" "$ZIPDIR/Inter Hinted for Windows/" & + cp $FONTDIR/const-hinted/Inter-*.ttf "$ZIPDIR/Inter Hinted for Windows/Desktop/" & + cp $FONTDIR/const-hinted/Inter-*.woff* "$ZIPDIR/Inter Hinted for Windows/Web/" & + cp misc/dist/inter.css "$ZIPDIR/Inter Hinted for Windows/Web/" & + + # Inter Variable + cp $FONTDIR/var/Inter.var.otf "$ZIPDIR/Inter Variable/Inter.otf" & + cp $FONTDIR/var/Inter-roman.var.otf "$ZIPDIR/Inter Variable/Single axis/Inter-roman.otf" & + cp $FONTDIR/var/Inter-italic.var.otf "$ZIPDIR/Inter Variable/Single axis/Inter-italic.otf" & + + # Inter Web + cp $FONTDIR/const/Inter-*.woff* "$ZIPDIR/Inter Web/" & + cp $FONTDIR/var/Inter.var.woff2 "$ZIPDIR/Inter Web/" & + cp $FONTDIR/var/Inter-roman.var.woff2 "$ZIPDIR/Inter Web/" & + cp $FONTDIR/var/Inter-italic.var.woff2 "$ZIPDIR/Inter Web/" & + cp misc/dist/inter.css "$ZIPDIR/Inter Web/" & +fi +# ---------------------------------------------------------------------------- +if $OPT_DISPLAY; then + # Inter Desktop + cp $FONTDIR/const/InterDisplay-*.otf "$ZIPDIR/Inter Desktop/" & + cp $FONTDIR/var/InterDisplay-V.var.otf "$ZIPDIR/Inter Desktop/InterDisplay-V.otf" & + + # Inter Hinted for Windows + cp "misc/dist/about hinted fonts.txt" "$ZIPDIR/Inter Hinted for Windows/" & + cp $FONTDIR/const-hinted/InterDisplay-*.ttf "$ZIPDIR/Inter Hinted for Windows/Desktop/" & + cp $FONTDIR/const-hinted/InterDisplay-*.woff* "$ZIPDIR/Inter Hinted for Windows/Web/" & + cp misc/dist/inter-display.css "$ZIPDIR/Inter Hinted for Windows/Web/" & + + # Inter Variable + cp $FONTDIR/var/InterDisplay.var.otf "$ZIPDIR/Inter Variable/InterDisplay.otf" & + cp $FONTDIR/var/InterDisplay-roman.var.otf "$ZIPDIR/Inter Variable/Single axis/InterDisplay-roman.otf" & + cp $FONTDIR/var/InterDisplay-italic.var.otf "$ZIPDIR/Inter Variable/Single axis/InterDisplay-italic.otf" & + + # Inter Web + cp $FONTDIR/const/InterDisplay-*.woff* "$ZIPDIR/Inter Web/" & + cp $FONTDIR/var/InterDisplay.var.woff2 "$ZIPDIR/Inter Web/" & + cp $FONTDIR/var/InterDisplay-roman.var.woff2 "$ZIPDIR/Inter Web/" & + cp $FONTDIR/var/InterDisplay-italic.var.woff2 "$ZIPDIR/Inter Web/" & + cp misc/dist/inter-display.css "$ZIPDIR/Inter Web/" & +fi +# ---------------------------------------------------------------------------- + +# copy misc stuff +cp misc/dist/install*.txt "$ZIPDIR/" +cp LICENSE.txt "$ZIPDIR/" + +# wait for processes to finish +wait + +# zip +pushd "$ZIPDIR" >/dev/null +zip -q -X -r "$OUTFILE_ABS" * +popd >/dev/null +rm -rf "$ZIPDIR" + +echo "Created $OUTFILE" |