x2gs
3.06 KB
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
#!/bin/sh
#
# Copyright (c) 1998-2000
# Sergey A. Babkin. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Sergey A. Babkin (sab123@hotmail.com, babkin@bellatlantic.net)
#
# Use : x2gs [cfgfile]
# path to the configuration file
if [ $# -eq 1 ]
then
CFGFILE=$1
else
CFGFILE=`pwd`/convert.cfg
fi
MYSELF=x2gs
# include the configuration
if [ -r $CFGFILE ]
then {
. $CFGFILE
} else {
echo "
Can't find the configuration file
$CFGFILE
Please look at the sample file convert.cfg.sample,
copy it to convert.cfg and modify for
you actual configuration." >&2
exit 1
} fi
LOG=$DSTDIR/convert.log
[ -n "$GSDIR" ] || {
echo "$MYSELF: The Ghostscript base directory is not specified." >&2
echo "$MYSELF: Installation of the Ghostscript fonts is deferred." >&2
exit 0
}
[ -n "$GSCONFDIR" -a -d "$GSCONFDIR" ] || {
echo "$MYSELF: The Ghostscript configuration directory does not exist." >&2
echo "$MYSELF: Installation of the Ghostscript fonts is aborted." >&2
exit 1
}
[ -r "$GSCONFDIR/Fontmap" ] || {
echo "$MYSELF: Can't find Fontmap in the GS configuration directory." >&2
echo "$MYSELF: Installation of the Ghostscript fonts is aborted." >&2
exit 1
}
[ -n "$GSFONTDIR" -a -d "$GSFONTDIR" ] || {
echo "$MYSELF: The Ghostscript font directory does not exist." >&2
echo "$MYSELF: Installation of the Ghostscript fonts is aborted." >&2
exit 1
}
# link the fonts to $GSFONTDIR
rm -f $GSCONFDIR/Fontmap.ttf
# historically x2gs supported multiple X11 directories
for d in $DSTDIR
do {
for i in $d/*.pfa $d/*.afm
do {
[ -f $i ] || break;
n=`basename $i`
rm -f $GSFONTDIR/$n
ln -s $i $GSFONTDIR/$n || {
echo "$MYSELF: Unable to link $n to GS font directory">&2
}
} done
cat $d/Fontmap.ttf >>$GSCONFDIR/Fontmap.ttf
} done
if [ YES = "$INSTALLFONTMAP" ]
then {
mv $GSCONFDIR/Fontmap $GSCONFDIR/Fontmap.old || {
echo "$MYSELF: can't save Fontmap.old" >&2
exit 1
}
sed "\\|^% begin fonts from $DSTDIR|,\\|^% end fonts from $DSTDIR|d" \
<$GSCONFDIR/Fontmap.old >$GSCONFDIR/Fontmap || {
echo "$MYSELF: Can't create the new Fontmap file" >&2
echo "$MYSELF: Trying to restore the old Fontmap file" >&2
cp $GSCONFDIR/Fontmap.old $GSCONFDIR/Fontmap
exit 1
}
echo "% begin fonts from $DSTDIR" >>$GSCONFDIR/Fontmap
echo "" >>$GSCONFDIR/Fontmap
cat $GSCONFDIR/Fontmap.ttf >>$GSCONFDIR/Fontmap
echo "" >>$GSCONFDIR/Fontmap
echo "% end fonts from $DSTDIR" >>$GSCONFDIR/Fontmap
} fi