-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·108 lines (87 loc) · 2.33 KB
/
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
#
# build.sh
set -e
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
# directory where the fonts are located
FONTS_DIR=fonts
POSITIONAL_ARGS=()
while [ $# -gt 0 ]; do
case $1 in
--generate)
GENERATE=1
shift
;;
--all)
ALL=1
shift
;;
--package)
PACKAGE=1
shift
;;
-h|--help)
HELP=1
shift
;;
-*)
echo "Unknown option $1"
exit 1
;;
*)
# save positional arg
POSITIONAL_ARGS+=("$1")
shift
;;
esac
done
# find all projects automatically
if [[ -n "$ALL" ]]; then
# clear previous ones as they are useless
POSITIONAL_ARGS=()
for i in "$FONTS_DIR"/*/; do
# filter only python packages
if [[ -f "$i/__init__.py" ]]; then
POSITIONAL_ARGS+=("$(basename "$i")")
fi
done
fi
# restore positional parameters
set -- "${POSITIONAL_ARGS[@]}"
# print help if no args, or if no command is supplied
if [ -n "$HELP" ] || [ -z "$1" ]; then
cat <<EOF
Usage: $0 [<arguments...>] <fonts...>
Optional arguments:
--all Builds all fonts, any positional argument is ignored
--generate Generates the assets used in the font, not needed
unless generator script is modified
--package Package the fonts
--help Shows this message
EOF
exit
fi
# make sure dir exists
mkdir -p ./build
# remove all the old fonts
rm -f ./build/*
# show fontforge version in log
echo -n "INFO: "
fontforge -quiet -version | head -n 1
for font in "$@"; do
if [ -n "$GENERATE" ]; then
echo "INFO: Generating assets for $font"
# this cannot be run with the fontforge python
python3 "$FONTS_DIR/$font/generator.py"
fi
# the module is responsible for building itself
fontforge -quiet -script -m "$FONTS_DIR.$font"
if [ -n "$PACKAGE" ]; then
echo "INFO: Packaging the fonts"
for i in "$@"; do
7za a "Compacity${i^}.zip" ./build/Compacity"${i^}"* >/dev/null
done
# a complete package with all fonts for the CI
7za a CompacityFonts.zip ./build/* >/dev/null
fi
done