| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 | #!/bin/sh# /////////////////////////////////////////////////////////////////## build-ttf.sh#  A shell script that builds the Hack ttf fonts from UFO source#  Copyright 2017 Christopher Simpkins#  MIT License##  Usage: ./build-ttf.sh (--install-dependencies)#     Arguments:#     --install-dependencies (optional) - installs all#       build dependencies prior to the build script execution## /////////////////////////////////////////////////////////////////# ttfautohint local install path from Werner Lemberg's ttfautohint-build.sh install script#   - This is revised to ttfautohint on the user's PATH if this local install is not identified#     then the identified ttfautohint is used to execute hinting.  Versions of ttfautohint < 1.6 exit with status#     code 1 due to use of -R option#   - The intent is to support use of ttfautohint installed on a user's PATH (e.g. they've previously installed it)TTFAH="$HOME/ttfautohint-build/local/bin/ttfautohint"# test for number of argumentsif [ $# -gt 1 ]	then	    echo "Inappropriate arguments included in your command." 1>&2	    echo "Usage: ./build-ttf.sh (--install-dependencies)" 1>&2	    exit 1fi# Optional build dependency install request with syntax `./build.sh --install-dependencies`if [ "$1" = "--install-dependencies" ]	then		# fontmake		pip install --upgrade fontmake		# fontTools (installed with fontmake at this time. leave this as dependency check as python scripts for fixes require it should fontTools eliminate dep)		pip install --upgrade fonttools		# ttfautohint v1.6 (must be pinned to v1.6 and above for Hack instruction sets)        tools/scripts/install/ttfautohint-build.shfi# confirm executable installs and library imports for build dependenciesINSTALLFLAG=0echo "Confirming that build dependencies are installed..."echo " "# fontmake installedif ! which fontmake	then	    echo "Unable to install fontmake with 'pip install fontmake'.  Please attempt a manual install of this build dependency and then repeat your build attempt." 1>&2	    INSTALLFLAG=1fi# fontTools python library can be importedif ! python -c "import fontTools"	then	    echo "Unable to install fontTools with 'pip install fonttools'.  Please attempt a manual install of this build dependency and then repeat your build attempt." 1>&2	    INSTALLFLAG=1else	echo "fontTools Python library identified"fi# ttfautohint installed#   - tests for install to local path from ttfautohint-build.sh script#   - if not found on this path, tests for install on system PATH - if found, revises TTFAH to the string "ttfautohint" for execution of instruction setsif ! [ -f "$TTFAH" ]	then	    if ! which ttfautohint	    	then	            echo "Unable to install ttfautohint from source.  Please attempt a manual install of this build dependency and then repeat your build attempt." 1>&2	            INSTALLFLAG=1	    else	    	TTFAH="ttfautohint"  # revise TTFAH variable to ttfautohint installed on the user's PATH for excecution of hints below	    fifi# if any of the dependency installs failed, exit and do not attempt build, notify userif [ $INSTALLFLAG -eq 1 ]	then	    echo "Build canceled." 1>&2	    exit 1fi# Desktop ttf font buildecho "Starting build..."echo " "# remove any existing release files from the build directoryif [ -f "build/ttf/Hack-Regular.ttf" ]; then	rm build/ttf/Hack-Regular.ttffiif [ -f "build/ttf/Hack-Italic.ttf" ]; then	rm build/ttf/Hack-Italic.ttffiif [ -f "build/ttf/Hack-Bold.ttf" ]; then	rm build/ttf/Hack-Bold.ttffiif [ -f "build/ttf/Hack-BoldItalic.ttf" ]; then	rm build/ttf/Hack-BoldItalic.ttffi# remove master_ttf directory if a previous build failed + exited early and it was not cleaned upif [ -d "master_ttf" ]; then	rm -rf master_ttffi# build regular setif ! fontmake -u "source/Hack-Regular.ufo" -o ttf	then	    echo "Unable to build the Hack-Regular variant set.  Build canceled." 1>&2	    exit 1fi# build bold setif ! fontmake -u "source/Hack-Bold.ufo" -o ttf	then	    echo "Unable to build the Hack-Bold variant set.  Build canceled." 1>&2	    exit 1fi# build italic setif ! fontmake -u "source/Hack-Italic.ufo" -o ttf	then	    echo "Unable to build the Hack-Italic variant set.  Build canceled." 1>&2	    exit 1fi# build bold italic setif ! fontmake -u "source/Hack-BoldItalic.ufo" -o ttf	then	    echo "Unable to build the Hack-BoldItalic variant set.  Build canceled." 1>&2	    exit 1fi# Desktop ttf font post build fixes# DSIG table fix with adapted fontbakery Python scriptecho " "echo "Attempting DSIG table fixes with fontbakery..."echo " "if ! python postbuild_processing/fixes/fix-dsig.py master_ttf/*.ttf	then	    echo "Unable to complete DSIG table fixes on the release files"	    exit 1fi# fstype value fix with adapted fontbakery Python scriptecho " "echo "Attempting fstype fixes with fontbakery..."echo " "if ! python postbuild_processing/fixes/fix-fstype.py master_ttf/*.ttf	then	    echo "Unable to complete fstype fixes on the release files"	    exit 1fi# Desktop ttf font hintingecho " "echo "Attempting ttfautohint hinting..."echo " "# make a temporary directory for the hinted filesmkdir master_ttf/hinted# Hack-Regular.ttfif ! "$TTFAH" -l 6 -r 50 -x 10 -H 181 -D latn -f latn -w G -W -t -X "" -I -R "master_ttf/Hack-Regular.ttf" -m "postbuild_processing/tt-hinting/Hack-Regular-TA.txt" "master_ttf/Hack-Regular.ttf" "master_ttf/hinted/Hack-Regular.ttf"	then	    echo "Unable to execute ttfautohint on the Hack-Regular variant set.  Build canceled." 1>&2	    exit 1fiecho "master_ttf/Hack-Regular.ttf - successful hinting with ttfautohint"# Hack-Bold.ttfif ! "$TTFAH" -l 6 -r 50 -x 10 -H 260 -D latn -f latn -w G -W -t -X "" -I -R "master_ttf/Hack-Regular.ttf" -m "postbuild_processing/tt-hinting/Hack-Bold-TA.txt" "master_ttf/Hack-Bold.ttf" "master_ttf/hinted/Hack-Bold.ttf"	then	    echo "Unable to execute ttfautohint on the Hack-Bold variant set.  Build canceled." 1>&2	    exit 1fiecho "master_ttf/Hack-Bold.ttf - successful hinting with ttfautohint"# Hack-Italic.ttfif ! "$TTFAH" -l 6 -r 50 -x 10 -H 145 -D latn -f latn -w G -W -t -X "" -I -R "master_ttf/Hack-Regular.ttf" -m "postbuild_processing/tt-hinting/Hack-Italic-TA.txt" "master_ttf/Hack-Italic.ttf" "master_ttf/hinted/Hack-Italic.ttf"	then	    echo "Unable to execute ttfautohint on the Hack-Italic variant set.  Build canceled." 1>&2	    exit 1fiecho "master_ttf/Hack-Italic.ttf - successful hinting with ttfautohint"# Hack-BoldItalic.ttfif ! "$TTFAH" -l 6 -r 50 -x 10 -H 265 -D latn -f latn -w G -W -t -X "" -I -R "master_ttf/Hack-Regular.ttf" -m "postbuild_processing/tt-hinting/Hack-BoldItalic-TA.txt" "master_ttf/Hack-BoldItalic.ttf" "master_ttf/hinted/Hack-BoldItalic.ttf"	then	    echo "Unable to execute ttfautohint on the Hack-BoldItalic variant set.  Build canceled." 1>&2	    exit 1fiecho "master_ttf/Hack-BoldItalic.ttf - successful hinting with ttfautohint"echo " "# Move release files to build directoryecho " "# create directory if it does not exist# (occurs with git + empty directories)if ! [ -d build/ttf ]; then	mkdir build/ttffimv master_ttf/hinted/Hack-Regular.ttf build/ttf/Hack-Regular.ttfecho "Regular ttf build path: build/ttf/Hack-Regular.ttf"mv master_ttf/hinted/Hack-Italic.ttf build/ttf/Hack-Italic.ttfecho "Italic ttf build path: build/ttf/Hack-Italic.ttf"mv master_ttf/hinted/Hack-Bold.ttf build/ttf/Hack-Bold.ttfecho "Bold ttf build path: build/ttf/Hack-Bold.ttf"mv master_ttf/hinted/Hack-BoldItalic.ttf build/ttf/Hack-BoldItalic.ttfecho "Bold Italic ttf build path: build/ttf/Hack-BoldItalic.ttf"# Remove master_ttf directoryrm -rf master_ttf
 |