-
Notifications
You must be signed in to change notification settings - Fork 0
/
vf-build.sh
executable file
·73 lines (53 loc) · 1.92 KB
/
vf-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Fail fast
set -e
# -----------------------------------------------------------------------
# configure paths
sourcesDir="A Font Sources"
buildDir="B Builds"
proofDir="D Proofs"
ttfDir="$buildDir/VF-TTFs"
woffDir="$buildDir/VF-WOFF2s"
# -----------------------------------------------------------------------
# build TTFs
echo " "
echo "Building VF-TTFs..."
# removing old files
rm -rf "$ttfDir"
# making the ttf directory
mkdir -p "$ttfDir"
# making the ttfs from the designspace file
find "$sourcesDir" -path '**/*.glyphs' -print0 | while read -d $'\0' glyphsFile
do
fileBaseName=${glyphsFile##*/}
fontmake --glyphs-path "$glyphsFile" --output variable --output-path "$ttfDir/${fileBaseName/.glyphs/-VF.ttf}" --master-dir "{tmp}" --instance-dir "{tmp}" --flatten-components
done
# -----------------------------------------------------------------------
# post-processing TTFS
# this loops through ttfs and...
find "$ttfDir" -path '*.ttf' -print0 | while read -d $'\0' ttfFile
do
python "C Project Files/py/removeMacNames.py" "$ttfFile"
done
# -----------------------------------------------------------------------
# make web fonts
echo " "
echo "Making WOFF2s..."
# removing old files
rm -rf "$woffDir"
# making the woff2 directory
mkdir -p "$woffDir"
# this loops through all the TTFs in the TTF directory and...
find "$ttfDir" -path '*.ttf' -print0 | while read -d $'\0' ttfFile
do
# Replaces .ttf with .woff2 in the file name
woff2name=$(basename "${ttfFile/.ttf/.woff2}")
# ... and compresses them into WOFF2s
fonttools ttLib.woff2 compress -o "$woffDir/$woff2name" "$ttfFile"
done
# -----------------------------------------------------------------------
# Tests
# The "1>/dev/null 2>&1 || true" stuff is to limit the output in the terminal
echo " "
echo "Running Tests..."
fontbakery check-universal -n --succinct --html "$proofDir/VF-TTFs.html" "$ttfDir/*.ttf" 1>/dev/null 2>&1 || true