Skip to content

Commit

Permalink
Merge pull request #107 from uswds/add-build-script
Browse files Browse the repository at this point in the history
Update to 1.006
  • Loading branch information
thisisdano committed Jul 18, 2019
2 parents 4c9f0fa + 0577b6b commit 83f0d41
Show file tree
Hide file tree
Showing 4,258 changed files with 134,402 additions and 130,295 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ _site
site/assets/uswds
site/assets/fonts
site/assets/css
env
report.json
82 changes: 82 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/sh

# -------------------------------------------------------------------
# UPDATE THIS VARIABLE ----------------------------------------------

thisFont="Public-Sans" # must match the name in the font file, e.g. FiraCode-VF.ttf needs the variable "FiraCode"

# -------------------------------------------------------------------
# Update the following as needed ------------------------------------

source env/bin/activate
set -e

cd source

echo "Generating TTF binaries"
mkdir -p ../fonts/webfonts
fontmake -g $thisFont.glyphs -i -o ttf --output-dir ../fonts/webfonts/
fontmake -g $thisFont-italics.glyphs -i -o ttf --output-dir ../fonts/webfonts/

echo "Generating Variable Fonts"
mkdir -p ../fonts/variable
fontmake -g $thisFont.glyphs -o variable --output-path ../fonts/variable/$thisFont-Roman-VF.ttf
fontmake -g $thisFont-italics.glyphs -o variable --output-path ../fonts/variable/$thisFont-Italic-VF.ttf

rm -rf master_ufo/ instance_ufo/

echo "Post processing"

ttfs=$(ls ../fonts/webfonts/*.ttf)
echo $ttfs
for ttf in $ttfs
do
gftools fix-dsig --autofix $ttf;
gftools fix-nonhinting $ttf $ttf;
done
rm ../fonts/webfonts/*backup*.ttf

vfs=$(ls ../fonts/variable/*.ttf)
for vf in $vfs
do
gftools fix-dsig --autofix $vf;
gftools fix-nonhinting $vf $vf
done
rm ../fonts/variable/*backup*.ttf

gftools fix-vf-meta $vfs;
for vf in $vfs
do
mv "$vf.fix" $vf;
done

cd ..

# ============================================================================
# Autohinting ================================================================

statics=$(ls fonts/webfonts/*.ttf)
echo hello
for file in $statics; do
echo "fix DSIG in " ${file}
gftools fix-dsig --autofix ${file}

echo "TTFautohint " ${file}
# autohint with detailed info
hintedFile=${file/".ttf"/"-hinted.ttf"}
ttfautohint -I ${file} ${hintedFile}
cp ${hintedFile} ${file}
rm -rf ${hintedFile}
done


# ============================================================================
# Build woff and woff2 fonts ==========================================================

# requires https://github.com/bramstein/homebrew-webfonttools

ttfs=$(ls fonts/webfonts/*.ttf)
for ttf in $ttfs; do
woff2_compress $ttf
sfnt2woff-zopfli $ttf
done

0 comments on commit 83f0d41

Please sign in to comment.