This repository has been archived by the owner on Aug 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
makefont
executable file
·120 lines (103 loc) · 2.86 KB
/
makefont
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
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
#
# makefont - Font Builder
# Written in 2015-2019 by Saber Rasetikerdar <[email protected]>
# Works only on linux.
#
# Requirements:
# build.py
# ttfautohint
# sfnt2woff
# ttf2eot
# woff2_compress
# zip
#
if [ ! -f "build.conf" ]; then
echo "build.conf not found!"
exit 1
fi
source build.conf
SCRIPTDIR=`dirname "$0"`
TEMPDIR="${PWD}/font-output-temp"
SOURCEDIR="source"
LATINDIR="latin"
DISTDIR="dist"
BUILDCMD="${SCRIPTDIR}"/build.py
LATINCOPYRIGHT="${LATINCOPYRIGHT}"
if [ ! -f "${BUILDCMD}" ]; then
echo "BUILDCMD not found!"
exit 1
fi
if [ ! -d "${SOURCEDIR}" ]; then
echo "SOURCEDIR not found!"
exit 1
fi
rm -rf "${TEMPDIR}"
mkdir -p "${TEMPDIR}"
mkdir "${TEMPDIR}"/build
if [ ! -d "${TEMPDIR}"/build ]; then
echo "TEMPDIR/build not found!"
exit 1
fi
# Make all the possible versions
for ((i=0;i<${#SOURCEFILES[@]};++i));
do
sf="$SOURCEDIR"/"${SOURCEFILES[i]}"
lf="${LATINDIR}"/"${LATINFILES[i]}"
bn=$(basename ${sf})
filename="${bn%.*}"
if [ -f ${sf} ]; then
"${BUILDCMD}" --input="${sf}" --output="${TEMPDIR}"/build/$filename-WOL.ttf
"${BUILDCMD}" --input="${sf}" --output="${TEMPDIR}"/build/$filename-FD-WOL.ttf --farsi-digits
if [ -f ${lf} ]; then
"${BUILDCMD}" --input="${sf}" --latin="${lf}" --latin-copyright="${LATINCOPYRIGHT}" --output="${TEMPDIR}"/build/$filename.ttf
"${BUILDCMD}" --input="${sf}" --latin="${lf}" --latin-copyright="${LATINCOPYRIGHT}" --output="${TEMPDIR}"/build/$filename-FD.ttf --farsi-digits
fi
fi
done
# Make all file types
for f in "${TEMPDIR}"/build/*.ttf
do
if [ -f "${f}" ]; then
fn=$(basename "${f}")
ttfautohint -n -w D -W -D arab -f latn -G 11 -l 8 -r 11 "${f}" "${TEMPDIR}/${fn}"
sfnt2woff "${TEMPDIR}/${fn}"
ttf2eot "${TEMPDIR}/${fn}" > "${TEMPDIR}/${fn%%.*}".eot
woff2_compress "${TEMPDIR}/${fn}"
fi
done
rm -rf "${TEMPDIR}"/build
# Move files to where they belong to
mkdir "${TEMPDIR}"/Farsi-Digits-Without-Latin
mv "${TEMPDIR}"/*FD-WOL* "${TEMPDIR}"/Farsi-Digits-Without-Latin
mkdir "${TEMPDIR}"/Farsi-Digits
mv "${TEMPDIR}"/*FD* "${TEMPDIR}"/Farsi-Digits
mkdir "${TEMPDIR}"/Without-Latin
mv "${TEMPDIR}"/*WOL* "${TEMPDIR}"/Without-Latin
# Add other(license, readme, ...) files defined in build.conf
for ((i=0;i<${#ADDFILES[@]};++i));
do
cp "${ADDFILES[i]}" "${TEMPDIR}"
done
# Make variable
if [ -d "variable" ]; then
cd variable/
./makevariable.sh "${TEMPDIR}"
cd ..
fi
# Make the release package(zip)
rm -f "$RELEASEFILEPATH"
CURDIR=`pwd`
cd "${TEMPDIR}"
zip -r release.zip .
cd "$CURDIR"
mv "${TEMPDIR}"/release.zip "$RELEASEFILEPATH"
# Make folder "dist"
mkdir -p "${DISTDIR}"
cp -rf "${TEMPDIR}"/**/ "${DISTDIR}"
cp -rf "${TEMPDIR}"/*.woff "${DISTDIR}"
cp -rf "${TEMPDIR}"/*.woff2 "${DISTDIR}"
cp -rf "${TEMPDIR}"/*.ttf "${DISTDIR}"
cp -rf "${TEMPDIR}"/*.eot "${DISTDIR}"
# Clean up
rm -rf "${TEMPDIR}"