-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathglyph_builder.sh
executable file
·395 lines (322 loc) · 7.92 KB
/
glyph_builder.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
#!/bin/bash
# desc: bash script for creating yaft's glyph.h
# settings
YAFT_DIR=`pwd`
WORK_DIR=/tmp/glyph_builder
ALIAS_FILE=alias
# infomation of each fonts
# mplus
MPLUS_VERSION=2.2.4
MPLUS_NAME=mplus_bitmap_fonts-${MPLUS_VERSION}
MPLUS_FILE=${MPLUS_NAME}.tar.gz
MPLUS_URL=http://iij.dl.osdn.jp/mplus-fonts/5030/${MPLUS_FILE}
# efont
EFONT_VERSION=0.4.2
EFONT_NAME=efont-unicode-bdf-${EFONT_VERSION}
EFONT_FILE=${EFONT_NAME}.tar.bz2
EFONT_URL=http://openlab.ring.gr.jp/efont/dist/unicode-bdf/${EFONT_FILE}
# milkjf
# already included in yaft
# unifont
UNIFONT_VERSION=11.0.02
UNIFONT_NAME=unifont-${UNIFONT_VERSION}
UNIFONT_FILE=${UNIFONT_NAME}.bdf.gz
UNIFONT_URL=http://unifoundry.com/pub/unifont/${UNIFONT_NAME}/font-builds/${UNIFONT_FILE}
# dina font (fetch from ProgrammingFonts repository)
DINA_VERSION=
DINA_NAME=
DINA_FILE=
DINA_DIR=ProgrammingFonts/Dina/BDF
DINA_URL=https://github.com/ProgrammingFonts/ProgrammingFonts.git
# terminus font
TERMINUS_VERSION=4.39
TERMINUS_NAME=terminus-font-${TERMINUS_VERSION}
TERMINUS_FILE=${TERMINUS_NAME}.tar.gz
TERMINUS_URL=http://sourceforge.net/projects/terminus-font/files/${TERMINUS_NAME}/${TERMINUS_FILE}
# profont (pcf format)
PROFONT_VERSION=
PROFONT_NAME=profont-x11
PROFONT_FILE=${PROFONT_NAME}.zip
PROFONT_URL=http://tobiasjung.name/downloadfile.php?file=${PROFONT_FILE}
# tamsyn font (pcf format)
TAMSYN_VERSION=1.11
TAMSYN_NAME=tamsyn-font-${TAMSYN_VERSION}
TAMSYN_FILE=${TAMSYN_NAME}.tar.gz
TAMSYN_URL=http://www.fial.com/~scott/tamsyn-font/download/${TAMSYN_FILE}
# wqy-bitmapfont (mkfont_bdf cannot handle this font...)
WQY_VERSION=1.0.0-RC1
WQY_NAME=wqy-bitmapsong-bdf-${WQY_VERSION}
WQY_FILE=${WQY_NAME}.tar.gz
WQY_URL=http://jaist.dl.sourceforge.net/project/wqy/wqy-bitmapfont/${WQY_VERSION}/${WQY_FILE}
# misc functions
usage()
{
echo -e "usage: ./glyph_builder.sh FONTS VARIATIONS"
echo -e "\tavalable fonts: mplus, efont, milkjf, unifont, dina, terminus, profont, tamsyn"
echo -e "depends on: wget, pcf2bdf"
}
generate()
{
echo "./mkfont_bdf ./table/${ALIAS_FILE} ${@} > ${YAFT_DIR}/glyph.h"
./mkfont_bdf ./table/${ALIAS_FILE} ${@} > ${YAFT_DIR}/glyph.h
}
# each font generate function
mplus_create_bdf()
{
# Install M+ BITMAP FONTS E
echo -e "\nInstall M+ BITMAP FONTS E (iso8859-1)..."
cd fonts_e
awk '/^SWIDTH/{$2 += 80} /^DWIDTH/{$2 += 1} {print}' mplus_h12r.bdf \
| sed 's/hlv/hlvw/'> mplus_h12rw.bdf
cd -
# Install M+ BITMAP FONTS EURO
echo -e "\nInstall M+ BITMAP FONTS EURO (iso8859-15)..."
cd fonts_e/euro
for f in mplus_*.diff
do
b=`basename $f .diff`
echo "$f $b"
cp ../$b.bdf ./
patch $b.bdf $b.diff
mv $b.bdf $b-euro.bdf
done
awk '/^SWIDTH/{$2 += 80} /^DWIDTH/{$2 += 1} {print}' \
mplus_h12r-euro.bdf | sed 's/hlv/hlvw/' > mplus_h12rw-euro.bdf
cd -
echo -e "\nInstall M+ BITMAP FONTS J..."
cd fonts_j
echo "create: mplus_j10b.bdf"
echo -n "wait a minute..."
../mkbold -r -R mplus_j10r.bdf | sed 's/medium/bold/' \
> mplus_j10b.bdf &&
echo " done"
echo "create: mplus_j12b.bdf"
echo -n "wait a minute..."
../mkbold -r -R mplus_j12r.bdf | sed 's/medium/bold/' \
> mplus_j12b.bdf &&
echo " done"
cp mplus_j10r-iso-W4 mplus_j10r-iso.bdf
echo "select: mplus_j10r-iso.bdf [W5]"
patch mplus_j10r-iso.bdf mplus_j10r-iso-W5.diff
#echo "select: mplus_j10r-iso.bdf [W4]"
for f in mplus_[!j]*-jisx0201.diff
do
b=`basename $f -jisx0201.diff`
echo "create: $b-jisx0201.bdf"
cp ../fonts_e/$b.bdf ./
patch $b.bdf $b-jisx0201.diff
mv $b.bdf $b-jisx0201.bdf
done
for f in mplus_j*-jisx0201.diff
do
b=`basename $f -jisx0201.diff`
echo "create: $b-jisx0201.bdf"
cp $b-iso.bdf $b-jisx0201.bdf
patch $b-jisx0201.bdf $b-jisx0201.diff
done
# some bug fix
sed -i 's|STARTCHAR 0x2455n|STARTCHAR 0x2455|' mplus_j12r.bdf
sed -i 's|STARTCHAR 0x2455n|STARTCHAR 0x2455|' mplus_j12b.bdf
cd -
touch created
}
mplus()
{
echo -ne "creating glyph.h from mplus fonts...\n"
wget -q -nc ${MPLUS_URL}
if test ! -d ${MPLUS_NAME}; then
bsdtar xf ${MPLUS_FILE}
fi
cd ${MPLUS_NAME}
ln -sf ${YAFT_DIR}/mkfont_bdf .
ln -sf ${YAFT_DIR}/table .
if test ! -f created; then
mplus_create_bdf > /dev/null 2>&1
fi
case "$1" in
j10*)
FILES=`find fonts_j -type f -name "*${1}*.bdf" | tr "\n" " "`;;
j12*)
PATTERN=`echo -n $1 | tail -c3`
FILES=`find . -type f -name "*[fj]${PATTERN}*.bdf" | tr "\n" " "`;;
f10*|f12*)
FILES=`find fonts_e -type f -name "*${1}*.bdf" | tr "\n" " "`;;
*)
echo -ne "avalable font variations: [fj](10|12)[rb]\n"
exit -1;;
esac
generate ${FILES}
}
efont()
{
echo -ne "creating glyph.h from efont unicode...\n"
wget -q -nc ${EFONT_URL}
if test ! -d ${EFONT_NAME}; then
bsdtar xf ${EFONT_FILE}
fi
cd ${EFONT_NAME}
ln -sf ${YAFT_DIR}/mkfont_bdf .
ln -sf ${YAFT_DIR}/table .
case "$1" in
1[0246]*|24*)
FILES=`find . -type f -name "*${1}.bdf" | tr "\n" " "`;;
*)
echo -ne "avalable font variations: (10|12|14|16|24)(_b)?\n"
exit -1;;
esac
generate ${FILES}
}
milkjf()
{
echo -ne "creating glyph.h from milkjf font...\n"
ln -sf $YAFT_DIR/mkfont_bdf .
ln -sf $YAFT_DIR/table .
ln -sf $YAFT_DIR/fonts .
FILES=`find -L fonts -type f -name "*.bdf" | tr "\n" " "`
generate ${FILES}
}
unifont()
{
echo -ne "creating glyph.h from unifont...\n"
wget -q -nc ${UNIFONT_URL}
if test ! -f ${UNIFONT_NAME}.bdf; then
gunzip ${UNIFONT_FILE}
fi
ln -sf $YAFT_DIR/mkfont_bdf .
ln -sf $YAFT_DIR/table .
FILES="${UNIFONT_NAME}.bdf"
generate ${FILES}
}
dina()
{
echo -ne "creating glyph.h from dina font...\n"
git clone ${DINA_URL}
ln -sf $YAFT_DIR/mkfont_bdf .
ln -sf $YAFT_DIR/table .
case "$1" in
r*)
FILES=`find ${DINA_DIR} -type f -name "*${1}.bdf" | tr "\n" " "`;;
*)
echo -ne "avalable font variations: r400-(6|8|9|10), r700-(8|9|10)\n"
exit -1;;
esac
generate ${FILES}
}
terminus()
{
echo -ne "creating glyph.h from terminus font...\n"
wget -q -nc ${TERMINUS_URL}
if test ! -d ${TERMINUS_NAME}; then
bsdtar xf ${TERMINUS_FILE}
fi
cd ${TERMINUS_NAME}
ln -sf $YAFT_DIR/mkfont_bdf .
ln -sf $YAFT_DIR/table .
case "$1" in
u*)
FILES=`find . -type f -name "*${1}.bdf" | tr "\n" " "`;;
*)
echo -ne "avalable font variations: u(14|16)v, u(12|14|16|18|20|22|24|28|32)[nb]\n"
exit -1;;
esac
generate ${FILES}
}
profont()
{
echo -ne "creating glyph.h from profont...\n"
wget -q -nc ${PROFONT_URL} -O ${PROFONT_FILE}
if test ! -d ${PROFONT_NAME}; then
bsdtar xf ${PROFONT_FILE}
fi
cd ${PROFONT_NAME}
ln -sf $YAFT_DIR/mkfont_bdf .
ln -sf $YAFT_DIR/table .
if test ! -f created; then
for i in *.pcf; do
pcf2bdf -o `basename $i .pcf`.bdf $i
done
touch created
fi
case "$1" in
1*|2*)
FILES=`find . -type f -name "*${1}.bdf" | tr "\n" " "`;;
*)
echo -ne "avalable font variations: (10|11|12|15|17|22|29)\n"
exit -1;;
esac
generate ${FILES}
}
tamsyn()
{
echo -ne "creating glyph.h from tamsyn font...\n"
wget -q -nc ${TAMSYN_URL}
if test ! -d ${TAMSYN_NAME}; then
bsdtar xf ${TAMSYN_FILE}
fi
cd ${TAMSYN_NAME}
ln -sf $YAFT_DIR/mkfont_bdf .
ln -sf $YAFT_DIR/table .
if test ! -f created; then
for i in *.pcf; do
pcf2bdf -o `basename $i .pcf`.bdf $i
done
touch created
fi
case "$1" in
*[rb])
FILES=`find . -type f -name "*${1}.bdf" | tr "\n" " "`;;
*)
echo -ne "avalable font variations: (5x9|6x12|7x13|7x14|8x15|8x16|10x20)[rb]\n"
exit -1;;
esac
generate ${FILES}
}
wqy()
{
echo -ne "creating glyph.h from tamsyn font...\n"
wget -q -nc ${WQY_URL}
if test ! -d ${WQY_NAME}; then
bsdtar xf ${WQY_FILE}
fi
cd wqy-bitmapsong
ln -sf $YAFT_DIR/mkfont_bdf .
ln -sf $YAFT_DIR/table .
case "$1" in
*pt|*px)
FILES=`find . -type f -name "*${1}.bdf" | tr "\n" " "`;;
*)
echo -ne "avalable font variations: (9|10|11|12)pt, 13px\n"
exit -1;;
esac
generate ${FILES}
}
# main
echo "LANG: $LANG"
mkdir -p $WORK_DIR
cd $WORK_DIR
case "$1" in
"mplus")
shift
mplus $1;;
"efont")
shift
efont $1;;
"milkjf")
milkjf;;
"unifont")
unifont;;
"dina")
shift
dina $1;;
"terminus")
shift
terminus $1;;
"profont")
shift
profont $1;;
"tamsyn")
shift
tamsyn $1;;
*)
usage;;
esac