Adds WIP scripts and logic for post processing patched fonts (WIP for fixing #70)

This commit is contained in:
Ryan L McIntyre 2016-12-03 14:57:11 -05:00
parent b90f400e10
commit e9d84b6c02
9 changed files with 137 additions and 0 deletions

View file

@ -0,0 +1,7 @@
# [ U+0069 ] adjust point above lowercase i
i touch 0,1, 4,5, 6,7, 10,11 y 1 @ 6, 7, 15, 16, 21, 22
# [ U+006A] adjust point above lowercase j
j touch 0,1, 4,5, 6,7, 10,11 y 1 @ 6, 7, 15, 16, 21, 22

View file

@ -0,0 +1,5 @@
# [ U+002B ] adjust the space in the vertical stroke of bar glyph
bar touch 2,3 y 0.25 @ 6
bar touch 2,3 y 1 @ 10,11,12,13
bar touch 4,5 y -0.25 @ 6
bar touch 4,5 y -1 @ 10

View file

@ -0,0 +1,8 @@
# [ U+002B ] adjust the space in the vertical stroke of bar glyph
bar touch 4,7 y 0.5 @ 6
bar touch 4,7 y 0.25 @ 7
bar touch 4,7 y 1 @ 10,11,12,13,14
bar touch 0,3 y -0.25 @ 6
bar touch 0,3 y -0.5 @ 7
bar touch 0,3 y -1 @ 10,14

View file

@ -0,0 +1,5 @@
# [ U+0030 ] Adjust fill in the zero glyph
zero left 40
zero touch 39,40,71 y -0.5 @ 7
zero touch 39,40,71 y -1 @ 8,12-18
zero touch 55,56,57 y -1 @ 19-25

60
bin/scripts/Hack/autohint.sh Executable file
View file

@ -0,0 +1,60 @@
#!/bin/bash
# ------------------------------------------------------------------
#
# autohint.sh
# Copyright 2016 Christopher Simpkins
# MIT license
# Modified by Ryan L McIntyre
# for Nerd Fonts (https://github.com/ryanoasis/nerd-fonts)
#
# ------------------------------------------------------------------
# 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;
}
# ttfautohint - Input and output file names must not be identical
cp "$fontfile" "${fontfile}.tmp"
#exit 0
if [[ "$fontfile" == *"Regular"* ]]
then
echo "regular"
ttfautohint -l 4 -r 80 -G 350 -x 0 -H 181 -D latn -f latn -w G -W -t -X "" -I -m "bin/scripts/Hack/Hack-Regular-TA.txt" "${fontfile}.tmp" "$fontfile"
else
echo "not regular"
fi
# clean-up
#rm "${fontfile}.tmp"
echo "[Nerd Fonts] Completed Autohinting Hack '$fontfile'"
exit 0
# Hack-Regular.ttf
ttfautohint -l 4 -r 80 -G 350 -x 0 -H 181 -D latn -f latn -w G -W -t -X "" -I -m "Hack-Regular-TA.txt" "$fontfile" "$fontfile"
#ttfautohint -l 4 -r 80 -G 350 -x 0 -H 181 -D latn -f latn -w G -W -t -X "" -I -m "Hack-Regular-TA.txt" "../prehinted_builds/Hack-Regular-TT.ttf" "../posthinted_builds/Hack-Regular.ttf"
#echo "Hack-Regular-TT.ttf hinted and moved to ../posthinted_builds/Hack-Regular.ttf"
exit 0
# Hack-Bold.ttf
ttfautohint -l 4 -r 80 -G 350 -x 0 -H 260 -D latn -f latn -w G -W -t -X "" -I -m "Hack-Bold-TA.txt" "../prehinted_builds/Hack-Bold-TT.ttf" "../posthinted_builds/Hack-Bold.ttf"
echo "Hack-Bold-TT.ttf hinted and moved to ../posthinted_builds/Hack-Bold.ttf"
# Hack-Italic.ttf
ttfautohint -l 4 -r 80 -G 350 -x 0 -H 145 -D latn -f latn -w G -W -t -X "" -I -m "Hack-Italic-TA.txt" "../prehinted_builds/Hack-Italic-TT.ttf" "../posthinted_builds/Hack-Italic.ttf"
echo "Hack-Italic-TT.ttf hinted and moved to ../posthinted_builds/Hack-Italic.ttf"
# Hack-BoldItalic.ttf
ttfautohint -l 4 -r 80 -G 350 -x 0 -H 265 -D latn -f latn -w G -W -t -X "" -I -m "Hack-BoldItalic-TA.txt" "../prehinted_builds/Hack-BoldItalic-TT.ttf" "../posthinted_builds/Hack-BoldItalic.ttf"
echo "Hack-BoldItalic-TT.ttf hinted and moved to ../posthinted_builds/Hack-BoldItalic.ttf"

14
bin/scripts/Hack/postprocess.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
# version: 0.9.0
fontfile=$1
dir=$(dirname "$0")
echo "dir $dir"
"${dir}/autohint.sh" "$fontfile"
#"${dir}/../fpfix.py" "$fontfile"
printf "\n"
printf "[Nerd Fonts] Post Processed Hack '%s'\n" "$fontfile"

29
bin/scripts/fpfix.py Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
### DEPENDENCY:
# fontTools Python library
# ==> https://github.com/fonttools/fonttools
# ==> Install: pip install fonttools
### USAGE:
# python fpfix.py [filepath to font]
import sys
from fontTools import ttLib
if len(sys.argv) < 2:
sys.stderr.write("[fpfix.py] ERROR: Please enter a path to the font file")
sys.exit(1)
try:
tt = ttLib.TTFont(sys.argv[1])
post = tt["post"].__dict__
post["isFixedPitch"] = 1
tt.save(sys.argv[1])
print("[fpfix.py]: '" + sys.argv[1] + "' fixed pitch setting was changed to 1 in the post table")
except Exception as e:
sys.stderr.write("[fpfix.py] ERROR: Unable to update the font isFixedPitch setting. " + str(e))
sys.exit(1)

View file

@ -21,6 +21,7 @@ import argparse
from argparse import RawTextHelpFormatter
import errno
import time
import subprocess
try:
#Load the module
@ -48,6 +49,7 @@ parser.add_argument('--pomicons', dest='pomicons', action='store_true', help='Ad
parser.add_argument('--powerline', dest='powerline', action='store_true', help='Add Powerline Glyphs', default=False)
parser.add_argument('--powerlineextra', dest='powerlineextra', action='store_true', help='Add Powerline Glyphs (https://github.com/ryanoasis/powerline-extra-symbols)', default=False)
parser.add_argument('--custom', type=str, nargs='?', dest='custom', help='Specify a custom symbol font. All new glyphs will be copied, with no scaling applied.', default=False)
parser.add_argument('--postprocess', type=str, nargs='?', dest='postprocess', help='Specify a Script for Post Processing', default=False)
# http://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
progressbars_group_parser = parser.add_mutually_exclusive_group(required=False)
@ -684,3 +686,8 @@ print "\nDone with Path Sets, generating font..."
sourceFont.generate(args.outputdir + "/" + sourceFont.fullname + extension, flags=('opentype', 'PfEd-comments'))
print "\nGenerated: " + sourceFont.fullname
if args.postprocess:
subprocess.call([args.postprocess, args.outputdir + "/" + sourceFont.fullname + extension])
print "\nPost Processed: " + sourceFont.fullname

View file

@ -1 +1,3 @@
config_has_powerline=1
[font-patcher]
post_process=bin/scripts/Hack/postprocess.sh