Setup a new cvs commit notification script that does log accumulation
[wmaker-crm.git] / util / wsetfont
blob96f9e6ebb301062a4ed134e82c1c3fa3b5274e94
1 #!/bin/sh
3 # language/font setting script for Window Maker
5 # by MANOME Tomonori <manome@itlb.te.noda.sut.ac.jp>
6 # (rewriten slightly by judas@hell on Jan 27 2001
7 # -argument --nodef tries to change only font coding (limited!)
8 # -much easier to add new font codings
9 # -much harder to read code...
10 # -argument --auto gets locale by itself, but does not override if some
11 # coding is also given
12 # -argument --locale=?? takes locale code (ja, sk, ...)
13 # )
15 # [Special Thanks To]
16 # Korean fontset info from:
17 # Byeong-Chan, Kim <redhands@linux.sarang.net>
18 # Chae-yong Chong <cychong@metro.telecom.samsung.co.kr>
19 # Latin2 fontset info from:
20 # Piotr Dembinski <pdemb@aurora.put.poznan.pl>
21 # Toni Bilic <root@toni.hr.tel.hr>
22 # Greek fontset info from:
23 # Nikolaos Papagrigoriou <papanikos@usa.net>
24 # Quote bug fix info from:
25 # Luke Kendall <luke@research.canon.com.au>
26 # Bug fix info for Korean font section from:
27 # CHOI Junho <junker@jazz.snu.ac.kr>
29 VERSION="Version 0.5 1998/12/07"
31 WDWRITE="wdwrite"
32 WDREAD="wdread"
33 PROGRAM=`basename $0`
35 help_msg() {
36 echo -e "\n"\
37 "$PROGRAM - font/language setting utility for Window Maker\n"\
38 "\n"\
39 "Usage: $VERSION\n"\
40 " $PROGRAM [--nodef] [--auto] <font_family>" >/dev/stderr
41 cat >/dev/stderr <<EOF
42 -----------------------------------------------------------------------
43 [font_fam] [Fontset] [Font Information]
44 default helvetica
45 latin1 helvetica(iso8859-1)
46 latin2 helvetica(iso8859-2) See *Note1.
47 greek helvetica(iso8859-7) See *Note1.
48 japanese helvetica/-*-fixed(jisx02XX) Included in X11R6/XFree86("fnon" pkg)
49 korean helvetica/-*-kodig(ksc5601) See *Note1.
50 korean2 helvetica/daewoo(ksc5601) Included in X11R6/XFree86("fnon" pkg)
51 russian helvetica(koi8-r) Included in X11R6/XFree86("fcyr" pkg)
52 turkish unknown See *Note2.
53 -----------------------------------------------------------------------
54 Latin1 Languages: Danish/Dutch/English/Finnish/French/Galician/German/
55 Italian/Norwegian/Portuguese/Spanish/Swedish/...
56 Latin2 Languages: Croatian/Czech/Polish/Romanian/Slovenian/...
58 *Note1: Not included in X11R6/XFree86. You can download them from ...
59 Latin2 X fonts packages: http://sizif.mf.uni-lj.si/linux/cee/iso8859-2.html
60 Greek X fonts packages: ftp://argeas.argos.hol.gr/pub/unix/linux/GREEK/fonts/
61 ftp://ftp.ntua.gr/pub/fonts/X11/
62 Korean X fonts packages: ftp://linux.sarang.net (Linux RPM)
63 ftp://ftp.kaist.ac.kr/pub/hangul/fonts
64 *Note2: please let me know appropriate font setting for WMGLOBAL/WindowMaker,
65 and the fonts' URL to download. mail-to: manome@itlb.te.noda.sut.ac.jp
66 EOF
67 exit
70 nodef=""
71 auto=""
72 family=""
73 for i in $*; do
74 case $i in
75 "--nodef")
76 nodef="YES";;
77 "--auto")
78 auto="YES";;
80 if echo $i |grep "^--locale=" &>/dev/null; then
81 new_locale=$(echo $i |sed -e "s|--locale=||" -)
82 elif [ -z $family ]; then
83 family=$i
84 else
85 help_msg
86 fi;;
87 esac
88 done
89 if [ -z "$family" ] && [ -z "$new_locale" ] && [ -z "$auto" ]; then
90 help_msg
93 ################################################################################
94 # You should make changes only in this area
95 # (or it is not what I wanted it to be...)
99 # For --auto and --locale= switch...
101 all_codings="latin1 latin2 greek japanese korean2 russian"
102 latin1="ca da de gl nl fi fr de is it no pt es sv se"
103 latin2="hr cz cs hu pl ro sk sl"
104 greek="el"
105 japanese="ja"
106 korean2="ko"
107 russian="ru bg"
110 # These are lists of all domains and keys we're gonna change...
112 DomainNames="WMGLOBAL WindowMaker"
113 DomainWMGLOBAL="SystemFont BoldSystemFont MultiByteText"
114 DomainWindowMaker="WindowTitleFont MenuTitleFont MenuTextFont IconTitleFont ClipTitleFont DisplayFont"
116 for i in $DomainNames; do
117 tmp="Domain$i"
118 AllKeys="$AllKeys ${!tmp}"
119 done
122 # Items that don't need to have coding string appended ( = not fonts).
124 NotFont="MultiByteText"
127 # Elements of $NodefUnable will always have fonts set to defaults, while those
128 # of $NonedefAble will have changed only coding part of font name (if --nodef
129 # command line argument is used).
131 NodefAble="default latin1 latin2 greek russian"
132 NodefUnable="japanese korean korean2"
133 Supported="$NodefAble $NodefUnable"
135 defaultCoding="*-*"
136 latin1Coding="iso8859-1"
137 latin2Coding="iso8859-2"
138 greekCoding="iso8859-7"
139 russianCoding="koi8-r"
141 defaultMultiByteText="AUTO"
142 latin1MultiByteText="NO"
143 latin2MultiByteText="YES"
144 greekMultiByteText="YES"
145 russianMultiByteText="YES"
148 # Default WindowMaker fonts for NodefAble font families (part telling us
149 # the font coding will be added automaticly from *Coding).
151 DefaultSystemFont="-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-"
152 DefaultBoldSystemFont="-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-"
153 DefaultWindowTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-"
154 DefaultMenuTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-"
155 DefaultMenuTextFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-"
156 DefaultIconTitleFont="-*-helvetica-medium-r-normal-*-8-*-*-*-*-*-"
157 DefaultClipTitleFont="-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-"
158 DefaultDisplayFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-"
159 DefaultMultiByteText="AUTO"
162 # NodefUnable have to give full font descriptions...
164 japaneseSystemFont=\"-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-%d-*,-*-*-medium-r-normal-*-*-*\"
165 japaneseBoldSystemFont=\"-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-%d-*,-*-*-medium-r-normal-*-*-*\"
166 japaneseWindowTitleFont=\"-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*\"
167 japaneseMenuTitleFont=\"-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*\"
168 japaneseMenuTextFont=\"-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*\"
169 japaneseIconTitleFont=\"-*-helvetica-medium-r-normal-*-8-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-*-*\"
170 japaneseClipTitleFont=\"-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-*-*\"
171 japaneseDisplayFont=\"-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*\"
172 japaneseMultiByteText="YES"
174 koreanSystemFont=\"-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--%d-*-*-*-*-*-*-*,*-*-medium-r-normal-*-%d-*-*-*-*-*-*-*,*-*-*-*-*--%d-*-*-*-*-*-*-*,*\"
175 koreanBoldSystemFont=\"-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-kodig-bold-r-normal--%d-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--%d-*-*-*-*-*-*-*,*-*-bold-r-normal-*-%d-*-*-*-*-*-*-*,*-*-*-*-*--%d-*-*-*-*-*-*-*,*\"
176 koreanWindowTitleFont=\"-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--12-*-*-*-*-*-*-*,-*-*-medium-r-normal--12-*-*-*-*-*-*-*,-*-*-medium-r-normal--*-*-*-*-*-*-*-*,-*-*-*-r-normal--*-*-*-*-*-*-*-*,-*-*-*-*-*--*-*-*-*-*-*-*-*,*\"
177 koreanMenuTitleFont=\"-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--14-*-*-*-*-*-*-*,-*-*-medium-r-normal--12-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*\"
178 koreanMenuTextFont=\"-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--14-*-*-*-*-*-*-*,*-*-medium-r-normal--12-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*\"
179 koreanIconTitleFont=\"-*-helvetica-medium-r-normal-*-8-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--10-*-*-*-*-*-*-*,*-*-medium-r-normal--10-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*\"
180 koreanClipTitleFont=\"-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--10-*-*-*-*-*-*-*,*-*-medium-r-normal--10-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*\"
181 koreanDisplayFont=\"-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--12-*-*-*-*-*-*-*,*-*-medium-r-normal--12-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*\"
182 koreanMultiByteText="YES"
184 korean2SystemFont=\"-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-medium-r-normal-*-%d-*,-*-medium-r-normal-*\"
185 korean2BoldSystemFont=\"-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-medium-r-normal-*-%d-*,-*-medium-r-normal-*\"
186 korean2WindowTitleFont=\"7x14,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*\"
187 korean2MenuTitleFont=\"7x14,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*\"
188 korean2MenuTextFont=\"7x14,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*\"
189 korean2IconTitleFont=\"-*-helvetica-medium-r-normal-*-10-*-*-*-*-*-*-*,-*-gothic-medium-r-normal-*-12-*-*-*-*-*-ksc5601.1987-*\"
190 korean2ClipTitleFont=\"-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*,-*-gothic-medium-r-normal-*-12-*-*-*-*-*-ksc5601.1987-*\"
191 korean2DisplayFont=\"-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*\"
192 korean2MultiByteText="YES"
195 # End of area meant to hold everything you could need to modify...
196 ################################################################################
199 # Get current locale automaticaly (--auto).
201 if [ -z "$family" ]; then
202 if [ -n "$new_locale" ]; then
203 locale="$new_locale"
204 else
205 locale=$LANG
206 if [ -z "$locale" ]; then
207 locale=$LC_ALL
211 if [ -z "$locale" ]; then
212 family="default"
213 else
214 for i in $all_codings; do
215 for j in ${!i}; do
216 if [ "$j" == "${locale%_*}" ]; then
217 family="$i"
218 break 2
220 done
221 done
226 # Do we recognize passed coding?
228 is_supported=""
229 for i in $Supported; do
230 if test "$family" == "$i"; then
231 is_supported="YES"
232 break
234 done
235 if test -z "$is_supported"; then # unknown coding
236 echo -e "\n"\
237 "Sorry, font coding $family or locale $locale not recognized.\n"\
238 "Type $PROGRAM with no arguments for list of supported font codings...\n"\
239 "" >/dev/stderr
240 exit 1
244 # Nodef is supported only for elements of $NodefAble.
246 is_nodef_unable=""
247 for i in $NodefUnable; do
248 if test "$family" == "$i"; then
249 if test -n "$nodef"; then # --nodef with one from $NodefUnable
250 echo -e "\n"\
251 "Sorry, --nodef argument is not allowed for these font codings:\n"\
252 " $NodefUnable\n"\
253 "Run $PROGRAM without --nodef argument to set default fonts for your\n"\
254 "font coding.\n"\
255 "" >/dev/stderr
256 exit 1
257 else
258 is_nodef_unable="YES"
259 break
262 done
265 # The real work...
267 if test -z "$nodef"; then
268 for i in $AllKeys; do
269 if test -n "$is_nodef_unable"; then # japanese,... defaults
270 tmp="$family$i"
271 eval $i=${!tmp}
272 else # rest, load defaults
273 not_font=""
274 for j in $NotFont; do
275 if test "$i" == "$j"; then
276 not_font="YES"
277 break
279 done
280 if test -n "$not_font"; then # don't append coding (not default!)
281 tmp="${family}$i"
282 eval $i="${!tmp}"
283 else # append coding
284 tmp="Default$i"
285 tmp1="${family}Coding"
286 eval $i="${!tmp}${!tmp1}"
289 done
290 else
291 echo -e "\n"\
292 "You used --nodef command line argument. You should note, that this\n"\
293 "works with these font codings only:\n"\
294 " $NodefAble\n"\
295 "You should not use it to change fonts from other font codings than\n"\
296 "those listed above. If your WindowMaker does not appear to find fonts,\n"\
297 "you should run $PROGRAM once again without --nodef argument." >/dev/stderr
301 # Ok, in the following, `i' will be the domain file name,
302 # `j' is the actual key in that file we try to change...
304 for i in $DomainNames; do
305 echo
306 echo "Setting up $i domain file..."
307 tmp="Domain$i"
308 for j in ${!tmp}; do
309 if test -n "$nodef"; then # --nodef, change coding only
310 not_font=""
311 for k in $NotFont; do
312 if test "$k" == "$j"; then
313 not_font="YES"
314 break;
316 done
317 if test -n "$not_font"; then # don't append coding
318 tmp1="${family}$j"
319 eval $j=${!tmp1}
320 else # append coding
321 #TODO:make this funny sed script a lot smarter to let us make changes in font
322 # lists, etc... (then we can enable --nodef for NodefUnable codings)
323 #TODO:better (or at least any) check, whether wmaker is installed...
324 tmp1="${family}Coding"
325 eval $j=$($WDREAD $i $j | sed -e "s/\(^-.*-\).*-.*$/\1${!tmp1}/g")
326 if test -z "${!j}"; then # failed, load default
327 tmp2="Default$j"
328 eval $j=${!tmp2}
332 tmp1="$j=\"${!j}\"" # cosmetic length workaround
333 if (( ${#tmp1} > 80 )); then
334 tmp1=$(echo "${tmp1:0:76}...\"")
336 echo "$tmp1"
337 $WDWRITE $i $j \"${!j}\"
338 done
339 done
340 echo