echo"Inappropriate arguments included in your command." 1>&2
echo"Usage: ./build-subsets.sh" 1>&2
echo"Usage: ./build-subsets.sh (--system)" 1>&2
exit1
fi
# ////////////////////////////////////////
# //////////////////////////////////////////////
#
#
# Confirm that dependencies are installed
# Re-define build dependencies to PATH
# installed versions if --system flag is used
#
#
# ////////////////////////////////////////
INSTALLFLAG=0
echo"Confirming that build dependencies are installed..."
echo" "
# fontmake installed
if ! which fontmake
then
echo"fontmake was not found. Please install all build dependencies with 'make build-with-dependencies', then attempt your build again." 1>&2
INSTALLFLAG=1
fi
# fontTools python library can be imported
if ! python -c "import fontTools"
then
echo"The fontTools library was not found. Please install all build dependencies with 'make build-with-dependencies', then attempt your build again." 1>&2
INSTALLFLAG=1
else
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 sets
if ! [ -f "$TTFAH"]
then
if ! which ttfautohint
then
echo"ttfautohint was not found. Please install all build dependencies with 'make build-with-dependencies', then attempt your build again." 1>&2
INSTALLFLAG=1
else
TTFAH="ttfautohint"# revise TTFAH variable to ttfautohint installed on the user's PATH for excecution of hints below
echo"ttfautohint executable identified"
fi
else
echo"ttfautohint executable identified"
fi
# sfntwoff-zopfli installed
if ! [ -f "$SFNTWOFF_BIN"]
then
echo"sfnt2woff-zopfli was not found on the path $SFNTWOFF_BIN. Please install all build dependencies with 'make build-with-dependencies', then attempt your build again." 1>&2
INSTALLFLAG=1
else
echo"sfnt2woff-zopfli executable identified"
fi
# //////////////////////////////////////////////
# woff2 installed
if ! [ -f "$WOFF2_BIN"]
then
echo"woff2_compress was not found on the path $WOFF2_BIN. Please install all build dependencies with 'make build-with-dependencies', then attempt your build again." 1>&2
INSTALLFLAG=1
else
echo"woff2_compress executable identified"
if["$1"="--system"];then
TTFAH="ttfautohint"
FONTMAKE="fontmake"
PYTHON="python3"
SFNTWOFF_BIN="sfnt2woff-zopfli"
WOFF2_BIN="woff2_compress"
fi
# if any of the dependency installs failed, exit and do not attempt build, notify user
# 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.sh
fi
# confirm executable installs and library imports for build dependencies
INSTALLFLAG=0
echo"Confirming that build dependencies are installed..."
echo" "
# fontmake installed
if ! 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=1
fi
# fontTools python library can be imported
if ! 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=1
else
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 sets
if ! [ -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
fi
fi
# if any of the dependency installs failed, exit and do not attempt build, notify user
if[$INSTALLFLAG -eq 1]
then
# Optional build with system-installed build dependencies instead of pinned build process defined versions
if["$1"="--system"]
then
# re-define the default executables to executables that exist on PATH
TTFAH="ttfautohint"
FONTMAKE="fontmake"
PYTHON="python3"
echo"================================="
echo" BUILD ENVIRONMENT"
echo"================================="
# test re-defined system-installed build dependency paths
if ! which "$TTFAH";then
echo"Unable to identify a system installed version of ttfautohint. Please install and try again." 1>&2
INSTALLFLAG=1
else
ttfautohint --version
fi
if ! which "$FONTMAKE";then
echo"Unable to identify a system installed version of fontmake. Please install and try again." 1>&2
INSTALLFLAG=1
else
"$FONTMAKE" --version
fi
if ! which "$PYTHON";then
echo"Unable to identify a Python 3 installation. Please install and try again." 1>&2
INSTALLFLAG=1
else
"$PYTHON" --version
fi
echo"================================="
echo" "
echo"================================="
echo" "
fi
# ttfautohint path test for default builds
# test for local ttfautohint install using repository provided install script and defined ttfautohint version (and its dependencies)
# no tests for Python build dependencies here because they are always installed by default & tested in the pipenv virtualenv before these steps
if[$# -eq 0];then
if ! [ -f "$TTFAH"];then
echo"Unable to identify the expected local install path for ttfautohint. Please install and try again." 1>&2
INSTALLFLAG=1
fi
fi
# If any of the dependency checks failed, exit the build and notify user
if[$INSTALLFLAG -eq 1];then
echo"Build canceled." 1>&2
exit1
fi
@ -110,21 +109,21 @@ fi
# build regular set
if ! fontmake -u "source/Hack-Regular.ufo" -o ttf
if ! $FONTMAKE -u "source/Hack-Regular.ufo" -o ttf
then
echo"Unable to build the Hack-Regular variant set. Build canceled." 1>&2
exit1
fi
# build bold set
if ! fontmake -u "source/Hack-Bold.ufo" -o ttf
if ! $FONTMAKE -u "source/Hack-Bold.ufo" -o ttf
then
echo"Unable to build the Hack-Bold variant set. Build canceled." 1>&2
exit1
fi
# build italic set
if ! fontmake -u "source/Hack-Italic.ufo" -o ttf
if ! $FONTMAKE -u "source/Hack-Italic.ufo" -o ttf
then
echo"Unable to build the Hack-Italic variant set. Build canceled." 1>&2
exit1
@ -132,7 +131,7 @@ fi
# build bold italic set
if ! fontmake -u "source/Hack-BoldItalic.ufo" -o ttf
if ! $FONTMAKE -u "source/Hack-BoldItalic.ufo" -o ttf
then
echo"Unable to build the Hack-BoldItalic variant set. Build canceled." 1>&2
exit1
@ -144,7 +143,7 @@ fi
echo" "
echo"Attempting DSIG table fixes with fontbakery..."
echo" "
if ! python postbuild_processing/fixes/fix-dsig.py master_ttf/*.ttf
if ! $PYTHON postbuild_processing/fixes/fix-dsig.py master_ttf/*.ttf
then
echo"Unable to complete DSIG table fixes on the release files"
exit1
@ -154,7 +153,7 @@ fi
echo" "
echo"Attempting fstype fixes with fontbakery..."
echo" "
if ! python postbuild_processing/fixes/fix-fstype.py master_ttf/*.ttf
if ! $PYTHON postbuild_processing/fixes/fix-fstype.py master_ttf/*.ttf
then
echo"Unable to complete fstype fixes on the release files"
# make Hack repository the current directory again following the build
cd"$CUR_DIR"||exit1
# determine if system installed executable on PATH is requested for build
# then test for presence of the sfnt2woff-zopfli build dependency based upon where it should be located
if["$1"="--system"];then
SFNTWOFF_BIN="sfnt2woff-zopfli"
if ! which $SFNTWOFF_BIN;then
echo"Unable to identify sfnt2woff-zopfli executable on system PATH. Please install and try again." 1>&2
exit1
else
# display version of installed sfnt2woff-zopfli
echo"Beginning web font build with $SFNTWOFF_BIN"
fi
fi
if[ -f "$SFNTWOFF_BIN"];then
echo"Beginning web font build with $SFNTWOFF"
else
echo"Unable to locate sfnt2woff-zopfli on the path $SFNTWOFF_BIN. Please attempt a manual install of this build dependency and then repeat your build attempt." 1>&2
exit1
# test for sfnt2woff-zopfli with default build approach
if[$# -eq 0];then
if[ -f "$SFNTWOFF_BIN"];then
echo"Beginning web font build with $SFNTWOFF_BIN"
else
echo"Unable to locate sfnt2woff-zopfli on the path $SFNTWOFF_BIN. Please install this build dependency and then repeat your build attempt." 1>&2
# make Hack repository the current directory again following the build
cd"$CUR_DIR"||exit1
# determine if system installed executable on PATH is requested for build
# then test for presence of the woff2_compress build dependency based upon where it should be located
if["$1"="--system"];then
WOFF2_BIN="woff2_compress"
if ! which $WOFF2_BIN;then
echo"Unable to identify woff2_compress executable on system PATH. Please install and try again." 1>&2
exit1
else
# display version of installed woff2_compress
echo"Beginning web font build with $WOFF2_BIN"
fi
fi
if[ -f "$WOFF2_BIN"];then
echo"Beginning web font build with $WOFF2_BIN"
else
echo"Unable to locate woff2_compress on path $WOFF2_BIN. Please attempt a manual install of this build dependency and then repeat your build attempt." 1>&2
exit1
# test for woff2_compress executable with default build approach
if[$# -eq 0];then
if[ -f "$WOFF2_BIN"];then
echo"Beginning web font build with $WOFF2_BIN"
else
echo"Unable to locate woff2_compress on path $WOFF2_BIN. Please attempt a manual install of this build dependency and then repeat your build attempt." 1>&2
Hack is compiled from UFO v2 spec source files to ttf, woff, and woff2 fonts with free, open source build tools. The default build approach requires a *nix platform (macOS, Linux, a Unix-like development platform for Windows such as MinGW) and uses pinned build dependency versions to support font files that render reproducibly (relative to upstream repository builds) in a given rendering environment. See the bottom of this document for an alternative approach that uses system-installed versions of all build dependencies and supports build dependency versions that differ from those used in the upstream repository.
## Quickstart
The following commands will do the following:
1. Clone the Hack source repository
2. Install the `pipenv` dependency
3. Compile and install a local version `ttfautohint` (i.e., *off of the system PATH*)
The build process takes minutes to complete on the average system. You will see a great deal of text stream by in your terminal during the build. This text stream is normal and expected during the build.
You will find the compiled fonts in the build directory (located in the top level of the source repository) after you complete these steps.
Detailed instructions follow if you have difficulties with any of the above steps. If you encounter an error that is not addressed in this build documentation, please report it as a new issue report on the repository. *Please review the entire build document below to confirm that we have not explained how to address your problem before you submit a new issue report*!
Hack is compiled from UFO v2 spec source files to ttf, woff, and woff2 fonts with free, open source build tools. You can either install the tools manually or use the automated build dependency installation approach documented below.
### Python interpreter dependency
### Desktop font (ttf) build dependencies
The Hack fonts are built with a Python version 3 interpreter. The Python interpreter version is fixed at each git commit. You may view the Python interpreter in use at any commit in the Pipfile and Pipfile.lock files that are located in the root directory of the repository. [Click here](https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/source-foundry/Hack%24%40master+python_version) to search for these values in the current HEAD commit of the master branch.
If this version of the Python interpreter is not available on your development system, you may install [`pyenv`](https://github.com/pyenv/pyenv-installer) before you attempt your build. If `pyenv` is installed before the build, `pipenv` will automatically install the interpreter defined in the Hack build in the virtual environment used for the build, even if it is not installed on your system.
The pyenv project defines the following command as a supported approach to install `pyenv`:
- [ttfautohint](https://www.freetype.org/ttfautohint/) executable (includes Harfbuzz and FreeType dependencies)
### Web font (woff + woff2) build dependencies
`fontmake` and `fontTools` are automatically installed during the compile process.
`pipenv` must be installed manually with the following command before you attempt a build:
**Install pipenv**
```
$ pip3 install pipenv
```
`ttfautohint` (including its Harfbuzz and FreeType dependencies) can be installed locally on the path defined for use in Hack builds with the following command:
To build the Hack web fonts from source you will need all of the build dependencies listed above for desktop font builds. In addition you will need the following dependencies for the web font build steps:
**Compile and install a local copy of ttfautohint**
```
$ make compile-local-dep
```
This path is defined as the following subdirectory on your $HOME path:
- ttfautohint: `$HOME/ttfautohint-build`
### Web font (woff + woff2) dependencies
To build the Hack web fonts from source you will need all of the build dependencies listed above for desktop font builds and the following additional dependencies:
- [sfnt2woff-zopfli](https://github.com/bramstein/sfnt2woff-zopfli) C++ executable
- [woff2_compress](https://github.com/source-foundry/woff2) C++ executable
The sfnt2woff-zopfli executable and woff2_compress executable are compiled and installed on a local build path (i.e., off of system PATH) with the following command:
### Automated build dependency installation
Install all build dependencies for desktop and web fonts with the following make command:
**Compile and install local copies of sfnt2woff-zopfli and woff2_compress**
```
$ make build-with-dependencies
$ make compile-local-dep
```
This will install all necessary build dependencies and complete a build of all desktop and web fonts.
These paths are defined as the following subdirectories on your $HOME path:
After the build dependencies are installed, use make targets from the root of the Hack repository to build font sets.
After the build dependencies are installed, use make targets from the root of the Hack repository to build font sets. The following commands build the regular, bold, italic, and bold italic variants of the respective build types:
#### Build all desktop and web fonts (including web font subsets)
@ -40,7 +117,7 @@ After the build dependencies are installed, use make targets from the root of th
$ make
```
#### Build ttf desktop fonts
#### Build ttf desktop fonts only
```
$ make ttf
@ -80,37 +157,62 @@ Desktop fonts are available on the path `build/ttf` from the root of the reposit
### Web fonts (woff + woff2)
Web fonts are available on the path `build/web/fonts` from the root of the repository upon completion of your build.
Web fonts are available on the path `build/web/fonts` from the root of the repository upon completion of your build. CSS files that may be used with your web font builds are available on the path `build/web`.
## Uninstall build dependencies
Python packages that are used during the build process are installed in a virtual environment with `pipenv`. The virtual environment and all Python packages installed in that environment can be eliminated with the execution of the following command in the root of the repository:
## Uninstall
```
$ pipenv -rm
```
All build dependencies installed with the automated approaches can be uninstalled with the following commands:
All compiled project build dependencies installed as part of this build process can be uninstalled with the following commands:
```
$ pip uninstall fontmake
$ pip uninstall fonttools
$ rm -rf ~/ttfautohint-build
$ rm -rf ~/sfnt2woff-zopfli-build
$ rm -rf ~/woff2
```
Here are all of the above commands in a single line that can be copied/pasted into your terminal to accomplish the entire uninstall process:
In cases where a compile did not proceed to completion (e.g., you intentionally exited early, or an exception was raised that led to an early termination of the build), a temporary directory may still exist in the root of the repository on the path `master_ttf`. This directory can be removed with:
```
$ rm -rf master_ttf
```
## Compile with system PATH installed build dependencies
The following make targets are available for those who would like to build with system PATH installed versions of all build dependencies. This approach allows you build with dependency versions that differ from those used in the upstream project. Please see the note at the bottom of this section for caveats to this approach.
#### System PATH build dependency compiles of all fonts
In cases where a compile did not proceed to completion (e.g. you intentionally exited early or an exception was raised) a temporary directory may still exist in the root of the repository on the path `master_ttf`. This can be removed with:
#### System PATH build dependency compiles of desktop fonts
```
$ rm -rf master_ttf
$ make ttf-system
```
#### System PATH build dependency compiles of all web fonts
```
$ make webfonts-system
```
### Uninstall Details
#### System PATH build dependency compiles of woff web fonts
fontmake and fonttools are Python packages and are uninstalled with pip.
```
$ make woff-system
```
The FreeType library (including its build dependency Harfbuzz), ttfautohint, sfnt2woff-zopfli, and woff2 are built in directories on your $HOME path. They are not installed on your $PATH (unless of course you have defined $HOME on $PATH) so they **will not** work from the command line with the name of the executable file only (e.g. `$ ttfautohint [file path]`). This is intentional.
#### System PATH build dependency compiles of woff web fonts
```
$ make woff2-system
```
Repeat execution of the build process cleans up the temporary directory `master_ttf` if found so this step is not mandatory to repeat a build and should not lead to errors with the build.
You must install all build dependencies before use of these make targets. Please refer to the documentation for the respective build dependency projects for details about installations. While we release these system PATH installed compile make targets to simplify the approach to builds for users who prefer not to (or cannot) create a development environment that matches the one used for our upstream builds, this approach is not otherwise supported or tested in this repository. Please understand this caveat if you intend to release fonts built with this approach in a production environment as differences in the build dependency versions can alter font renders.