2018-07-09 16:20:40 +02:00
|
|
|
#!/usr/bin/env bash
|
2016-12-03 21:57:11 +02:00
|
|
|
# ------------------------------------------------------------------
|
|
|
|
#
|
2018-03-17 17:50:02 +02:00
|
|
|
# autohint.sh
|
|
|
|
# Copyright 2016 Christopher Simpkins
|
|
|
|
# MIT license
|
|
|
|
# Modified by Ryan L McIntyre
|
|
|
|
# for Nerd Fonts (https://github.com/ryanoasis/nerd-fonts)
|
2023-01-23 16:41:11 +02:00
|
|
|
# Nerd Fonts Version: 2.3.2
|
2018-03-18 02:33:15 +02:00
|
|
|
# Script Version: 1.1.1
|
2016-12-03 21:57:11 +02:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------
|
|
|
|
|
|
|
|
# DESCRIPTION
|
|
|
|
# Applies hints to the Hack ttf font builds with ttfautohint
|
|
|
|
# Executable: ttfautohint (http://www.freetype.org/ttfautohint/doc/ttfautohint.html)
|
|
|
|
|
|
|
|
fontfile=$1
|
|
|
|
|
|
|
|
echo "[Nerd Fonts] Autohinting Hack '$fontfile'"
|
|
|
|
|
|
|
|
command -v ttfautohint >/dev/null 2>&1 || {
|
|
|
|
echo "[Nerd Fonts] 'ttfautohint' is required (not installed). Aborting." >&2; exit 1;
|
|
|
|
}
|
|
|
|
|
2018-03-18 02:33:15 +02:00
|
|
|
nerdfonts_hack_scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
2016-12-03 21:57:11 +02:00
|
|
|
# ttfautohint - Input and output file names must not be identical
|
|
|
|
cp "$fontfile" "${fontfile}.tmp"
|
|
|
|
|
2018-03-18 02:33:15 +02:00
|
|
|
if [[ "$fontfile" == *"Regular"* ]]
|
2016-12-03 21:57:11 +02:00
|
|
|
then
|
2018-03-17 17:50:02 +02:00
|
|
|
echo "[Nerd Fonts] Hinting Hack Regular"
|
2018-03-18 02:33:15 +02:00
|
|
|
ttfautohint -l 6 -r 50 -x 10 -H 181 -D latn -f latn -w G -W -t -X "" -I -m "${nerdfonts_hack_scripts_dir}/Hack-Regular-TA.txt" "${fontfile}.tmp" "$fontfile"
|
|
|
|
elif [[ "$fontfile" == *"Bold"* ]]
|
2016-12-15 04:50:36 +02:00
|
|
|
then
|
2018-03-17 17:50:02 +02:00
|
|
|
echo "[Nerd Fonts] Hinting Hack Bold"
|
2018-03-18 02:33:15 +02:00
|
|
|
ttfautohint -l 6 -r 50 -x 10 -H 260 -D latn -f latn -w G -W -t -X "" -I -m "${nerdfonts_hack_scripts_dir}/Hack-Bold-TA.txt" "${fontfile}.tmp" "$fontfile"
|
|
|
|
elif [[ "$fontfile" == *"Italic"* ]]
|
2016-12-15 04:50:36 +02:00
|
|
|
then
|
2018-03-17 17:50:02 +02:00
|
|
|
echo "[Nerd Fonts] Hinting Hack Italic"
|
2018-03-18 02:33:15 +02:00
|
|
|
ttfautohint -l 6 -r 50 -x 10 -H 145 -D latn -f latn -w G -W -t -X "" -I -m "${nerdfonts_hack_scripts_dir}/Hack-Italic-TA.txt" "${fontfile}.tmp" "$fontfile"
|
|
|
|
elif [[ "$fontfile" == *"BoldItalic"* ]]
|
2016-12-15 04:50:36 +02:00
|
|
|
then
|
2018-03-17 17:50:02 +02:00
|
|
|
echo "[Nerd Fonts] Hinting Hack Bold Italic"
|
2018-03-18 02:33:15 +02:00
|
|
|
ttfautohint -l 6 -r 50 -x 10 -H 265 -D latn -f latn -w G -W -t -X "" -I -m "${nerdfonts_hack_scripts_dir}/Hack-BoldItalic-TA.txt" "${fontfile}.tmp" "$fontfile"
|
2016-12-15 04:50:36 +02:00
|
|
|
else
|
2018-03-17 17:50:02 +02:00
|
|
|
echo "[Nerd Fonts] Could not find any Hack fonts to hint..."
|
2016-12-03 21:57:11 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# clean-up
|
2016-12-15 03:10:42 +02:00
|
|
|
rm "${fontfile}.tmp"
|
2016-12-03 21:57:11 +02:00
|
|
|
|
|
|
|
echo "[Nerd Fonts] Completed Autohinting Hack '$fontfile'"
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
|