forked from xero/figlet-fonts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·94 lines (71 loc) · 1.38 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
#!/bin/bash
# Variables
width=180
text="FIGlet"
filename="index.html"
verbose=0
# Parse options
for arg in "$@"
do
case "$1" in
"-w")
width="$2"
shift
;;
"-t")
text="$2"
shift
;;
"-f")
filename="$2"
shift
;;
"-v")
verbose=1
;;
"")
break
;;
*)
echo "Usage: $0 [-w <width>] [-t <text>] [-f <filename>]"
exit 1
;;
esac
shift
done
# Verbose
if [ $verbose -eq 1 ]
then
echo "width: $width"
echo "text: $text"
echo "filename: $filename"
fi
# Prepare HTML file
echo -e "\
<!DOCTYPE html>\n\
<html>\n\
<head>\n\
<meta charset=\"utf-8\">\n\
<title>FIGlet fonts preview by CS Zach</title>\n\
</head>\n\
<body>\n\
<h1>FIGlet fonts preview</h1>
<pre>" > $filename
# Generate HTML for fonts preview
cd fonts
COMMAND="echo \"Font file: <a href=\"./fonts/{}\">{}</a>\" && echo && figlet -f \"{}\" -w \"$width\" \"$text\" && echo"
ls -1 *.[ft]lf | xargs -i sh -c "$COMMAND" 2> /dev/null >> ../"$filename"
cd - &>/dev/null
# Finish HTML
echo -e "\
</pre>\n\
<footer>
<p style=\"text-align: center\">
Fonts collected by <a href=\"https://github.com/xero\">xero</a>.<br>
Preview generated by <a href=\"https://github.com/cszach\">CS Zach</a>.
</p>
</footer>
</body>\n\
</html>" >> $filename
echo 'Success'
exit 0