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
|
#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# Author: Martin Schlemmer <azarah@gentoo.org>
# $Header: /var/cvsroot/gentoo-x86/x11-base/xfree/files/4.2.1-r1/xfs.start,v 1.2 2003/02/14 23:30:00 vapier Exp $
#NB: Config is in /etc/conf.d/xfs
depend() {
use logger
}
check_config() {
if [ -z "${XFS_PORT}" ]
then
eerror "Please set \$XFS_PORT in /etc/conf.d/xfs!"
return 1
fi
return 0
}
# Return 0 on change, or 1 on no change, or if dir do not exist
check_changed() {
local x=""
local fontlist=""
# If the dir do not exist, e
if [ ! -d $1 ]
then
return 1
fi
# Create a list of all non known config files in the font dir
fontlist="$(find $1/ -type f -maxdepth 1)"
fontlist="$(echo "${fontlist}" | egrep -v 'fonts\..*')"
fontlist="$(echo "${fontlist}" | egrep -v '*.\.dir')"
fontlist="$(echo "${fontlist}" | egrep -v 'XftCache')"
if [ ! -f $1/fonts.list ]
then
if [ -n "${fontlist}" ]
then
# No list file exist, so create it and return 0 to add
# this font dir as a candidate for updating...
echo "${fontlist}" > $1/fonts.list
return 0
fi
else
local retval=1
# All the fonts was removed, so cleanup
if [ -z "${fontlist}" ]
then
for x in $1/fonts.* $1/encodings.dir $1/XftCache
do
if [ -f ${x} ]
then
rm -f ${x}
fi
done
return 1
fi
# Check that no files was added or removed....
if [ "$(cat $1/fonts.list | md5sum)" != "$(echo "${fontlist}" | md5sum)" ]
then
retval=0
fi
# Check that no files was updated....
if [ "${retval}" -ne 0 ]
then
local changed_list=""
changed_list="$(find $1 -type f -cnewer $1/fonts.dir)"
changed_list="$(echo "${changed_list}" | egrep -v 'fonts\..*')"
changed_list="$(echo "${changed_list}" | egrep -v '*.\.dir')"
changed_list="$(echo "${changed_list}" | egrep -v 'XftCache')"
if [ -n "${changed_list}" ]
then
retval=0
fi
fi
# OK, something changed, so recreate fonts.list and add as candidate
# for updating...
if [ "${retval}" -eq 0 ]
then
echo "${fontlist}" > $1/fonts.list
return 0
fi
fi
return 1
}
# This is a brain dead function to extract font dirs from
# the xfs config file (/etc/X11/fs/config).
get_fontdir_list() {
local dowrite=1
set -f
(awk '!/^#|^\t+#/ { print $0 }' /etc/X11/fs/config) | while read line
do
if [ "${line/catalogue}" != "${line}" ]
then
dowrite=0;
fi
if [ "${dowrite}" -eq 0 ]
then
# Do not print the 'catalogue = ' bit, or any ','
echo "${line/catalogue*=}" | sed -e 's:,::g'
if [ "$(echo ${line} | sed -e 's:,::g')" = "${line}" ]
then
dowrite=1
fi
fi
done
set +f
}
# This is the main beast for setting up the font dirs
setup_font_dirs() {
local x=""
local pending_fontdirs=""
umask 022
# While we at it, update fontconfig's cache as well
if [ -x /usr/bin/fc-cache ]
then
ebegin "Updating FC cache"
/usr/bin/fc-cache
eend 0
fi
if [ ! -x /usr/X11R6/bin/mkfontdir -o ! -x /usr/X11R6/bin/ttmkfdir ]
then
ewarn "Could not find mkfontdir or ttmkfdir binary!"
return 0
fi
/usr/X11R6/bin/mkfontdir -n \
-e /usr/X11R6/lib/X11/fonts/encodings \
-e /usr/X11R6/lib/X11/fonts/encodings/large \
-- /usr/X11R6/lib/X11/fonts/encodings
ebegin "Scanning font dirs"
for x in $(get_fontdir_list)
do
if test -d ${x} && check_changed ${x}
then
if [ -z "${pending_fontdirs}" ]
then
pending_fontdirs="${x}"
else
pending_fontdirs="${pending_fontdirs} ${x}"
fi
fi
done
eend 0
if [ -n "${pending_fontdirs}" ]
then
ebegin "Indexing font dirs"
for x in ${pending_fontdirs}
do
ebegin " ${x}"
# Only generate .scale files if there are
# truetype fonts present ...
if [ "${x/encodings}" = "${x}" -a \
-n "$(find ${x} -iname '*.tt[cf]' -print)" ]
then
/usr/X11R6/bin/ttmkfdir \
-e /usr/X11R6/lib/X11/fonts/encodings/encodings.dir \
-o ${x}/fonts.scale -d ${x} &> /dev/null
fi
if [ "${x/encodings}" = "${x}" ]
then
/usr/X11R6/bin/mkfontdir \
-e /usr/X11R6/lib/X11/fonts/encodings \
-e /usr/X11R6/lib/X11/fonts/encodings/large \
-- ${x} &> /dev/null
fi
if [ "${x/encodings}" = "${x}" -a -x /usr/X11R6/bin/xftcache ] && \
[ -n "$(find ${x} -iname '*.tt[cf]' -print)" -o \
-n "$(find ${x} -iname '*.pf[ab]' -print)" ]
then
/usr/X11R6/bin/xftcache ${x}
fi
eend 0
done
fi
}
start() {
check_config || return 1
if [ "${SETUP_FONTDIRS}" = "yes" ]
then
setup_font_dirs
fi
ebegin "Starting X Font Server"
if [ "`grep -e "^xfs:" /etc/passwd`" ] ; then
start-stop-daemon --start --quiet --exec /usr/X11R6/bin/xfs \
-- -daemon -config /etc/X11/fs/config \
-droppriv -user xfs -port ${XFS_PORT} 1>&2
else
start-stop-daemon --start --quiet --exec /usr/X11R6/bin/xfs \
-- -daemon -config /etc/X11/fs/config \
-port ${XFS_PORT} 1>&2
fi
eend $?
}
stop() {
ebegin "Stopping X Font Server"
start-stop-daemon --stop --quiet --exec /usr/X11R6/bin/xfs 1>&2
rm -rf /tmp/.font-unix
eend $?
}
# vim:ts=4
|