1#!/bin/sh
2
3# The GD_FONTS environment variable can be set to specify the gzipped
4# tar-ball containing the fonts in bdf format and the bdf file names.
5#
6# For example:
7# GD_FONTS="/usr/ports/distfiles/x-koi8u.tgz koi6x10.bdf koi8x13.bdf \
8#	koi9x15.bdf koi12x24.bdf koi10x20.bdf"
9#
10# This can be usefull for slave ports, like ukrainian/gd, which may
11# now provide alternative fonts easily.
12
13#	TODO: . handle multiple archiving formats: tgz, tar.bz2, zip
14#	      . allow for passing already extracted font-files
15
16if [ -z "$GD_FONTS" ]
17then
18	echo "GD_FONTS can be set to specify an alternative list of .bdf files"
19	echo "See $0 for details..."
20	exit 0
21fi
22
23set $GD_FONTS
24#
25# The  tarball is  the  first argument,  the  tiny, small,  medium-bold,
26# large, and giant fonts follow.
27#
28
29tarball=$1
30shift
31tar -xvzpf $tarball -C $WRKSRC $@
32
33rm -f $WRKSRC/Makefile.fonts
34
35for font in Tiny Small MediumBold Large Giant
36do
37	f=`echo $font | tr -d [[:lower:]] | tr [[:upper:]] [[:lower:]]`
38	rm -f $WRKSRC/gdfont$f.[ch]
39	printf 'gdfont%s.c gdfont%s.h: %s\
40		perl ${.CURDIR}/bdftogd gdFont%s font%s < %s\n' \
41		$f $f $1 $font $f $1 >> $WRKSRC/Makefile.fonts
42	shift
43done
44