updated single click patch
[wmaker-crm.git] / util / wsetfont
blob014094e9b1f719d7577d0d141e57993c50a7b3f3
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 # improved by Mike FABIAN <mfabian@suse.de> on April 23th 20003
16 # - use 'locale charmap' to find out the encoding of the locale
17 # simulate 'locale charmap' on systems which lack it.
18 # - add a few fontsets, especially a generic one which hopefully works almost always
20 # [Special Thanks To]
21 # Korean fontset info from:
22 # Byeong-Chan, Kim <redhands@linux.sarang.net>
23 # Chae-yong Chong <cychong@metro.telecom.samsung.co.kr>
24 # Latin2 fontset info from:
25 # Piotr Dembinski <pdemb@aurora.put.poznan.pl>
26 # Toni Bilic <root@toni.hr.tel.hr>
27 # Greek fontset info from:
28 # Nikolaos Papagrigoriou <papanikos@usa.net>
29 # Quote bug fix info from:
30 # Luke Kendall <luke@research.canon.com.au>
31 # Bug fix info for Korean font section from:
32 # CHOI Junho <junker@jazz.snu.ac.kr>
33 # Ukrainian fontset info from:
34 # Bohdan Vlasyuk <bohdan@vstu.edu.ua>
35 # CP1251 and isocyr fontset info from:
36 # Anton Zinoviev <zinoviev@debian.org>
38 VERSION="Version 0.6 2002/01/12"
40 WDWRITE="wdwrite"
41 WDREAD="wdread"
42 PROGRAM=`basename $0`
44 help_msg() {
45 cat >/dev/stderr <<EOF
46 $PROGRAM - font/language setting utility for Window Maker
48 Usage: $VERSION
49 $PROGRAM [--nodef] [--auto] <font_family>
50 -----------------------------------------------------------------------
51 [font_fam] [Fontset] [Font Information]
52 default helvetica See *Note1.
53 generic helvetica/efont/gnu-unifont/* See *Note2.
54 efontuni efont(iso10646-1) See *Note1.
55 gnuuni gnu-unicode(iso10646-1) See *Note1.
56 unicode helvetica(iso10646-1) Included in XFree86
57 latin1 helvetica(iso8859-1) Included in XFree86
58 latin2 helvetica(iso8859-2) Included in XFree86
59 latin9 helvetica(iso8859-15) Included in XFree86
60 greek helvetica(iso8859-7) See *Note1.
61 japanese helvetica/-*-fixed(jisx02XX) Included in X11R6/XFree86("fnon" pkg)
62 korean helvetica/-*-kodig(ksc5601) See *Note1.
63 korean2 helvetica/daewoo(ksc5601) Included in X11R6/XFree86("fnon" pkg)
64 russian helvetica(koi8-r) Included in X11R6/XFree86("fcyr" pkg)
65 ukrainian helvetica(koi8-u) See *Note1.
66 cp1251 helvetica(microsoft-cp1251)
67 isocyr helvetica(iso8859-5)
68 turkish helvetica(iso8859-9) Included in XFree86
69 sans generic alias for use with Xft
70 serif generic alias for use with Xft
71 monospace generic alias for use with Xft
72 -----------------------------------------------------------------------
73 Latin1 Languages: Danish/Dutch/English/Finnish/French/Galician/German/
74 Italian/Norwegian/Portuguese/Spanish/Swedish/...
75 Latin2 Languages: Croatian/Czech/Polish/Romanian/Slovenian/...
76 Latin9 Languages: same languages as Latin1 but with Euro symbol.
77 CP1251 Languages: Belarusian/Bulgarian
79 *Note1: Not included in X11R6/XFree86. You can download them from ...
80 efontuni: http://openlab.ring.gr.jp/efont/
81 gnuuni: http://czyborra.com/unifont/
82 Greek X fonts packages: ftp://argeas.argos.hol.gr/pub/unix/linux/GREEK/fonts/
83 ftp://ftp.ntua.gr/pub/fonts/X11/
84 Korean X fonts packages: ftp://linux.sarang.net (Linux RPM)
85 ftp://ftp.kaist.ac.kr/pub/hangul/fonts
86 Ukrainian X fonts packages: http://www.inp.nsk.su/~bolkhov/files/fonts/cyr-rfx/
87 *Note2: generic fontset which hopefully works with most locales
88 in most circumstances
89 EOF
90 exit
93 nodef=""
94 auto=""
95 family=""
96 for i in $*; do
97 case $i in
98 "--nodef")
99 nodef="YES";;
100 "--auto")
101 auto="YES";;
102 --locale=*)
103 new_locale=`echo $i |sed -e "s|--locale=||" -`;;
105 if [ -z $family ]; then
106 family=$i
107 else
108 help_msg
109 fi;;
110 esac
111 done
112 if [ -z "$family" ] && [ -z "$new_locale" ] && [ -z "$auto" ]; then
113 help_msg
116 ################################################################################
117 # You should make changes only in this area
118 # (or it is not what I wanted it to be...)
122 # These are lists of all domains and keys we're gonna change...
124 DomainNames="WMGLOBAL WindowMaker"
125 DomainWMGLOBAL="SystemFont BoldSystemFont MultiByteText"
126 DomainWindowMaker="WindowTitleFont MenuTitleFont MenuTextFont IconTitleFont ClipTitleFont DisplayFont LargeDisplayFont"
128 for i in $DomainNames; do
129 tmp="Domain$i"
130 eval AllKeys="\"$AllKeys \$${tmp}\""
131 done
134 # Items that don't need to have coding string appended ( = not fonts).
136 NotFont="MultiByteText"
139 # Elements of $NodefUnable will always have fonts set to defaults, while those
140 # of $NodefAble will have changed only coding part of font name (if --nodef
141 # command line argument is used).
143 NodefAble="default unicode latin1 latin2 latin5 latin9 greek russian ukrainian cp1251 isocyr"
144 NodefUnable="generic efontuni gnuuni japanese korean korean2 sans serif monospace"
145 Supported="$NodefAble $NodefUnable"
147 defaultCoding="*-*"
148 unicodeCoding="iso10646-1"
149 latin1Coding="iso8859-1"
150 latin2Coding="iso8859-2"
151 latin5Coding="iso8859-9"
152 latin9Coding="iso8859-15"
153 greekCoding="iso8859-7"
154 russianCoding="koi8-r"
155 ukrainianCoding="koi8-u"
156 cp1251Coding="microsoft-cp1251"
157 isocyrCoding="iso8859-5"
159 defaultMultiByteText="AUTO"
160 unicodeMultiByteText="YES"
161 latin1MultiByteText="NO"
162 latin2MultiByteText="YES"
163 latin5MultiByteText="YES"
164 latin9MultiByteText="YES"
165 greekMultiByteText="YES"
166 russianMultiByteText="YES"
167 ukrainianMultiByteText="YES"
168 cp1251MultiByteText="YES"
169 isocyrMultiByteText="YES"
172 # Default WindowMaker fonts for NodefAble font families (part telling us
173 # the font coding will be added automaticly from *Coding).
175 DefaultSystemFont="-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-"
176 DefaultBoldSystemFont="-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-"
177 DefaultWindowTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-"
178 DefaultMenuTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-"
179 DefaultMenuTextFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-"
180 DefaultIconTitleFont="-*-helvetica-medium-r-normal-*-8-*-*-*-*-*-"
181 DefaultClipTitleFont="-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-"
182 DefaultDisplayFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-"
183 DefaultLargeDisplayFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-"
184 DefaultMultiByteText="AUTO"
187 # NodefUnable have to give full font descriptions...
190 genericSystemFont="-*-helvetica-medium-r-normal-*-%d-*-*-*-iso8859-*,-efont-biwidth-medium-r-normal-*-%d-*-*-*-*-*-*-*,-efont-biwidth-medium-r-normal-*-*-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-medium-r-normal-*-%d-*-*-*-*-*-ksc5601.1987-*,-shinonome-gothic-medium-r-normal-*-%d-*,-*-*-medium-r-normal-*-%d-*,-*-*-medium-r-normal-*-*-*"
191 genericBoldSystemFont="-*-helvetica-bold-r-normal-*-%d-*-*-*-iso8859-*,-efont-biwidth-bold-r-normal-*-%d-*-*-*-*-*-*-*,-efont-biwidth-bold-r-normal-*-*-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-bold-r-normal-*-%d-*-*-*-*-*-ksc5601.1987-*,-shinonome-gothic-bold-r-normal-*-%d-*,-*-*-bold-r-normal-*-%d-*,-*-*-bold-r-normal-*-*-*"
192 genericWindowTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-iso8859-*,-efont-biwidth-bold-r-normal-*-12-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-medium-r-normal-*-12-*-*-*-*-*-ksc5601.1987-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
193 genericMenuTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-iso8859-*,-efont-biwidth-bold-r-normal-*-12-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-bold-r-normal-*-12-*-*-*-*-*-ksc5601.1987-*,-shinonome-gothic-bold-r-normal-*-12-*,-*-*-bold-r-normal-*-12-*,-*-*-bold-r-normal-*-14-*,-*-*-bold-r-normal-*-*-*"
194 genericMenuTextFont="-*-helvetica-medium-r-normal-*-12-*-*-*-iso8859-*,-efont-biwidth-medium-r-normal-*-12-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-medium-r-normal-*-12-*-*-*-*-*-ksc5601.1987-*,-shinonome-gothic-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
195 genericIconTitleFont="-*-helvetica-medium-r-normal-*-8-*-*-*-iso8859-*,-efont-biwidth-medium-r-normal-*-8-*-*-*-*-*-*-*,-efont-biwidth-medium-r-normal-*-10-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-medium-r-normal-*-8-*-*-*-*-*-ksc5601.1987-*,-baekmuk-gulim-medium-r-normal-*-10-*-*-*-*-*-ksc5601.1987-*,-shinonome-gothic-medium-r-normal-*-8-*,-shinonome-gothic-medium-r-normal-*-10-*,-shinonome-gothic-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-8-*,-*-*-medium-r-normal-*-10-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
196 genericClipTitleFont="-*-helvetica-bold-r-normal-*-10-*-*-*-iso8859-*,-efont-biwidth-bold-r-normal-*-10-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-medium-r-normal-*-10-*-*-*-*-*-ksc5601.1987-*,-shinonome-gothic-medium-r-normal-*-10-*,-shinonome-gothic-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-10-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
197 genericDisplayFont="-*-helvetica-medium-r-normal-*-12-*-*-*-iso8859-*,-efont-biwidth-medium-r-normal-*-12-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-medium-r-normal-*-12-*-*-*-*-*-ksc5601.1987-*,-shinonome-gothic-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
198 genericLargeDisplayFont="-*-helvetica-medium-r-normal-*-24-*-*-*-iso8859-*,-efont-biwidth-medium-r-normal-*-24-*-*-*-*-*-*-*,-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*,-baekmuk-gulim-medium-r-normal-*-24-*-*-*-*-*-ksc5601.1987-*,-shinonome-gothic-medium-r-normal-*-24-*,-*-*-medium-r-normal-*-24-*,-*-*-medium-r-normal-*-*-*"
199 genericMultiByteText="YES"
201 efontuniSystemFont="-efont-biwidth-medium-r-normal-*-%d-*-*-*-*-*-*-*,-efont-biwidth-medium-r-normal-*-*-*-*-*-*-*-*-*"
202 efontuniBoldSystemFont="-efont-biwidth-bold-r-normal-*-%d-*-*-*-*-*-*-*,-efont-biwidth-bold-r-normal-*-*-*-*-*-*-*-*-*"
203 efontuniWindowTitleFont="-efont-biwidth-bold-r-normal-*-12-*-*-*-*-*-*-*"
204 efontuniMenuTitleFont="-efont-biwidth-bold-r-normal-*-12-*-*-*-*-*-*-*"
205 efontuniMenuTextFont="-efont-biwidth-medium-r-normal-*-12-*-*-*-*-*-*-*"
206 efontuniIconTitleFont="-efont-biwidth-medium-r-normal-*-8-*-*-*-*-*-*-*,-efont-biwidth-medium-r-normal-*-10-*-*-*-*-*-*-*"
207 efontuniClipTitleFont="-efont-biwidth-bold-r-normal-*-10-*-*-*-*-*-*-*"
208 efontuniDisplayFont="-efont-biwidth-medium-r-normal-*-12-*-*-*-*-*-*-*"
209 efontuniLargeDisplayFont="-efont-biwidth-medium-r-normal-*-24-*-*-*-*-*-*-*"
210 efontuniMultiByteText="YES"
212 # Unless scaling of bitmap fonts is allowed (usually disabled nowadays),
213 # the GNU-Unifont is only available in 16 pixel height.
214 gnuuniSystemFont="-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*"
215 gnuuniBoldSystemFont="-gnu-unifont-bold-r-normal-*-16-*-*-*-*-*-*-*"
216 gnuuniWindowTitleFont="-gnu-unifont-bold-r-normal-*-16-*-*-*-*-*-*-*"
217 gnuuniMenuTitleFont="-gnu-unifont-bold-r-normal-*-16-*-*-*-*-*-*-*"
218 gnuuniMenuTextFont="-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*"
219 gnuuniIconTitleFont="-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*"
220 gnuuniClipTitleFont="-gnu-unifont-bold-r-normal-*-16-*-*-*-*-*-*-*"
221 gnuuniDisplayFont="-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*"
222 gnuuniLargeDisplayFont="-gnu-unifont-medium-r-normal-*-16-*-*-*-*-*-*-*"
223 gnuuniMultiByteText="YES"
225 japaneseSystemFont="-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-%d-*,-*-*-medium-r-normal-*-*-*"
226 japaneseBoldSystemFont="-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-%d-*,-*-*-medium-r-normal-*-*-*"
227 japaneseWindowTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
228 japaneseMenuTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
229 japaneseMenuTextFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
230 japaneseIconTitleFont="-*-helvetica-medium-r-normal-*-8-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-*-*"
231 japaneseClipTitleFont="-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-12-*,-*-*-medium-r-normal-*-*-*"
232 japaneseDisplayFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-14-*,-*-*-medium-r-normal-*-*-*"
233 japaneseLargeDisplayFont="-*-helvetica-medium-r-normal-*-24-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-24-*,-*-*-medium-r-normal-*-16-*,-*-*-medium-r-normal-*-*-*"
234 japaneseMultiByteText="YES"
236 koreanSystemFont="-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--%d-*-*-*-*-*-*-*,*-*-medium-r-normal-*-%d-*-*-*-*-*-*-*,*-*-*-*-*--%d-*-*-*-*-*-*-*,*"
237 koreanBoldSystemFont="-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-kodig-bold-r-normal--%d-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--%d-*-*-*-*-*-*-*,*-*-bold-r-normal-*-%d-*-*-*-*-*-*-*,*-*-*-*-*--%d-*-*-*-*-*-*-*,*"
238 koreanWindowTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--12-*-*-*-*-*-*-*,-*-*-medium-r-normal--12-*-*-*-*-*-*-*,-*-*-medium-r-normal--*-*-*-*-*-*-*-*,-*-*-*-r-normal--*-*-*-*-*-*-*-*,-*-*-*-*-*--*-*-*-*-*-*-*-*,*"
239 koreanMenuTitleFont="-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--14-*-*-*-*-*-*-*,-*-*-medium-r-normal--12-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*"
240 koreanMenuTextFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--14-*-*-*-*-*-*-*,*-*-medium-r-normal--12-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*"
241 koreanIconTitleFont="-*-helvetica-medium-r-normal-*-8-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--10-*-*-*-*-*-*-*,*-*-medium-r-normal--10-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*"
242 koreanClipTitleFont="-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--10-*-*-*-*-*-*-*,*-*-medium-r-normal--10-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*"
243 koreanDisplayFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--12-*-*-*-*-*-*-*,*-*-medium-r-normal--12-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*"
244 koreanLargeDisplayFont="-*-helvetica-medium-r-normal-*-24-*-*-*-*-*-*-*,-*-kodig-medium-r-normal--24-*-*-*-*-*-*-*,*-*-medium-r-normal--24-*-*-*-*-*-*-*,*-*-medium-r-normal--*-*-*-*-*-*-*-*,*-*-*-r-normal--*-*-*-*-*-*-*-*,*"
245 koreanMultiByteText="YES"
247 korean2SystemFont="-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-medium-r-normal-*-%d-*,-*-medium-r-normal-*"
248 korean2BoldSystemFont="-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-medium-r-normal-*-%d-*,-*-medium-r-normal-*"
249 korean2WindowTitleFont="7x14,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*"
250 korean2MenuTitleFont="7x14,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*"
251 korean2MenuTextFont="7x14,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*"
252 korean2IconTitleFont="-*-helvetica-medium-r-normal-*-10-*-*-*-*-*-*-*,-*-gothic-medium-r-normal-*-12-*-*-*-*-*-ksc5601.1987-*,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*"
253 korean2ClipTitleFont="-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*,-*-gothic-medium-r-normal-*-12-*-*-*-*-*-ksc5601.1987-*,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*"
254 korean2DisplayFont="-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*,-*-gothic-medium-r-normal-*-16-*-*-*-*-*-ksc5601.1987-*"
255 korean2LargeDisplayFont="-*-helvetica-medium-r-normal-*-24-*-*-*-*-*-*-*,-*-gothic-medium-r-normal-*-24-*-*-*-*-*-ksc5601.1987-*,-*-*-medium-r-normal-*-24-*-*-*-*-*-ksc5601.1987-*"
256 korean2MultiByteText="YES"
258 # Entries for use with Xft2:
260 # WindowMaker uses the XftFontOpenXlfd() function to open fonts via Xft2.
262 # 1. If the XLFD doesn't have all its fields present will fail and
263 # return NULL (I added a fallback to load "sans" in that case to wfont.c).
265 # 2. If all fields are present, but hold invalid values then it will:
266 # a. If family is invalid, will load the default "sans-serif" font.
267 # b. If the font size is invalid (non-numerical) it will fail and
268 # return NULL.
269 # c. If other fields are invalid, will load the font specified by
270 # the valid family name, ignoring any invalid fields. It will
271 # use a default medium weight and a default roman slant if they
272 # are invalid.
274 # I believe the three generic aliases "sans", "serif", and "monospace"
275 # are especially good default values for the family name because these
276 # 3 font aliases are guaranteed to work in Xft. A font named "sans"
277 # doesn't really exist but the "sans" alias automatically resolves to
278 # the "best" installed sans serif font which supports the language
279 # from the current locale according to the rules in /etc/fonts/fonts.conf.
280 # For exammple, if you are running in en_US locale, the first font from the
281 # list of the "prefer" aliases for "sans-serif" in /etc/fonts/fonts.conf
282 # which is installed and contains all necessary glyphs for English
283 # will be used. If you are running in a ja_JP locale (ja_JP.eucJP, ja_JP.SJIS,
284 # or ja_JP.UTF-8), the first installed font from this list which has
285 # all glyphs for Japanese is used. I.e. if /etc/fonts/fonts.conf contains
287 # ...
288 # <alias>
289 # <family>sans-serif</family>
290 # <prefer>
291 # ...
292 # <family>Luxi Sans</family>
293 # ...
294 # <family>Kochi Gothic</family>
295 # ...
296 # </prefer>
297 # </alias>
298 # ...
300 # "Luxi Sans" will be used for English and "Kochi Gothic" for
301 # Japanese (if no other fonts supporting Japanese or English fonts
302 # are higher in the list).
304 # Therefore, using the generic aliases "sans", "serif", or "monospace"
305 # is an easy way to support many languages automatically.
307 # These aliases also make it especially easy for the user to
308 # get a consistent look throughout his system because he
309 # can easily choose his preferred "sans-serif", "serif" and
310 # "monospace" fonts by writing something like the following
311 # in his personal ~/.fonts.conf:
313 # --- snip ---
314 # <?xml version="1.0"?>
315 # <!DOCTYPE fontconfig SYSTEM "/etc/fonts/fonts.dtd">
316 # <fontconfig>
317 # <alias>
318 # <family>serif</family>
319 # <prefer>
320 # <family>Luxi Serif</family>
321 # <family>Kochi Mincho</family>
322 # </prefer>
323 # </alias>
324 # <alias>
325 # <family>sans-serif</family>
326 # <prefer>
327 # <family>Luxi Sans</family>
328 # <family>Kochi Gothic</family>
329 # </prefer>
330 # </alias>
331 # <alias>
332 # <family>monospace</family>
333 # <prefer>
334 # <family>Luxi Mono</family>
335 # <family>Kochi Gothic</family>
336 # </prefer>
337 # </alias>
338 # </fontconfig>
339 # --- snip ---
341 # By changing ~/.fonts.conf the user can thus easily change
342 # the look of all applications which just specify these generic aliases
343 # instead of specific font names at once.
345 # As Xft doesn't care for the foundry, the following font settings
346 # just have "xftdummy" in the foundry.
348 sansSystemFont="-xftdummy-sans-medium-r-normal-*-%d-*-*-*-*-*-*-*"
349 sansBoldSystemFont="-xftdummy-sans-bold-r-normal-*-%d-*-*-*-*-*-*-*"
350 sansWindowTitleFont="-xftdummy-sans-bold-r-normal-*-12-*-*-*-*-*-*-*"
351 sansMenuTitleFont="-xftdummy-sans-bold-r-normal-*-12-*-*-*-*-*-*-*"
352 sansMenuTextFont="-xftdummy-sans-medium-r-normal-*-12-*-*-*-*-*-*-*"
353 sansIconTitleFont="-xftdummy-sans-medium-r-normal-*-8-*-*-*-*-*-*-*"
354 sansClipTitleFont="-xftdummy-sans-bold-r-normal-*-10-*-*-*-*-*-*-*"
355 sansDisplayFont="-xftdummy-sans-medium-r-normal-*-12-*-*-*-*-*-*-*"
356 sansLargeDisplayFont="-xftdummy-sans-medium-r-normal-*-12-*-*-*-*-*-*-*"
357 sansMultiByteText="YES"
359 serifSystemFont="-xftdummy-serif-medium-r-normal-*-%d-*-*-*-*-*-*-*"
360 serifBoldSystemFont="-xftdummy-serif-bold-r-normal-*-%d-*-*-*-*-*-*-*"
361 serifWindowTitleFont="-xftdummy-serif-bold-r-normal-*-12-*-*-*-*-*-*-*"
362 serifMenuTitleFont="-xftdummy-serif-bold-r-normal-*-12-*-*-*-*-*-*-*"
363 serifMenuTextFont="-xftdummy-serif-medium-r-normal-*-12-*-*-*-*-*-*-*"
364 serifIconTitleFont="-xftdummy-serif-medium-r-normal-*-8-*-*-*-*-*-*-*"
365 serifClipTitleFont="-xftdummy-serif-bold-r-normal-*-10-*-*-*-*-*-*-*"
366 serifDisplayFont="-xftdummy-serif-medium-r-normal-*-12-*-*-*-*-*-*-*"
367 serifLargeDisplayFont="-xftdummy-serif-medium-r-normal-*-12-*-*-*-*-*-*-*"
368 serifMultiByteText="YES"
370 monospaceSystemFont="-xftdummy-monospace-medium-r-normal-*-%d-*-*-*-*-*-*-*"
371 monospaceBoldSystemFont="-xftdummy-monospace-bold-r-normal-*-%d-*-*-*-*-*-*-*"
372 monospaceWindowTitleFont="-xftdummy-monospace-bold-r-normal-*-12-*-*-*-*-*-*-*"
373 monospaceMenuTitleFont="-xftdummy-monospace-bold-r-normal-*-12-*-*-*-*-*-*-*"
374 monospaceMenuTextFont="-xftdummy-monospace-medium-r-normal-*-12-*-*-*-*-*-*-*"
375 monospaceIconTitleFont="-xftdummy-monospace-medium-r-normal-*-8-*-*-*-*-*-*-*"
376 monospaceClipTitleFont="-xftdummy-monospace-bold-r-normal-*-10-*-*-*-*-*-*-*"
377 monospaceDisplayFont="-xftdummy-monospace-medium-r-normal-*-12-*-*-*-*-*-*-*"
378 monospaceLargeDisplayFont="-xftdummy-monospace-medium-r-normal-*-12-*-*-*-*-*-*-*"
379 monospaceMultiByteText="YES"
382 # End of area meant to hold everything you could need to modify...
383 ################################################################################
386 # Get current locale automaticaly (--auto).
389 # helper function to determine the encoding used by the current locale
390 # as portable as possible:
392 locale_charmap () {
393 if type -p locale > /dev/null 2>&1
394 then
395 # if the 'locale' command is available, the easiest way to
396 # determine the encoding used in the current locale is
397 # to call 'locale charmap'. It is available at least on
398 # Linux
399 # Solaris 8
400 # AIX
401 # HP-UX
402 LOCALE_CHARMAP=`locale charmap 2>/dev/null`
403 else
404 # emulate 'locale charmap' on systems which don't have it (*BSD)
405 # see also
406 # http://www.cl.cam.ac.uk/~mgk25/ucs/langinfo.c
408 # First determine the LC_CTYPE locale category setting
409 ctype="C"
410 if test x$LC_ALL != x ; then
411 ctype=$LC_ALL
412 elif test x$LC_CTYPE != x ; then
413 ctype=$LC_CTYPE
414 elif test x$LANG != x ; then
415 ctype=$LANG
418 # the value of LC_CTYPE should have the following syntax:
419 # [language[_territory][.codeset][@modifier]]
420 # (see also http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html)
421 case $ctype in
422 C|POSIX)
423 LOCALE_CHARMAP=US-ASCII
425 *[Uu][Tt][Ff]*)
426 LOCALE_CHARMAP=UTF-8
428 *@euro)
429 # all @euro locales use ISO-8859-15 encoding
430 # (apart from .UTF-8@euro locales of course, which exist
431 # on Solaris 8).
432 LOCALE_CHARMAP=ISO-8859-15
434 *[Kk][Oo][Ii]8-[Rr]*)
435 LOCALE_CHARMAP=KOI8-R
437 *[Kk][Oo][Ii]8-[Uu]*)
438 LOCALE_CHARMAP=KOI8-U
440 *620*)
441 LOCALE_CHARMAP=TIS-620
443 *2312*)
444 LOCALE_CHARMAP=GB2312
446 *[Hh][Kk][Ss][Cc][Ss]*)
447 LOCALE_CHARMAP=Big5HKSCS
449 *[Bb][Ii][Gg]*)
450 LOCALE_CHARMAP=Big5
452 *[Gg][Bb][Kk]*)
453 LOCALE_CHARMAP=GBK
455 *18030*)
456 LOCALE_CHARMAP=GB18030
458 *Shift_JIS*|*[Ss][Jj][Ii][Ss]*)
459 LOCALE_CHARMAP=SHIFT_JIS
461 # make sure to run 'sed' and 'cut' in POSIX locale, otherwise
462 # one might get unexpected results, for example in vi_VN.tcvn
463 # locale the following 'sed' and 'cut' commands fail.
464 *.*@*)
465 # if it contains a '.' and an '@' the encoding can be found between
466 # the '.' and the '@'.
467 LOCALE_CHARMAP=`echo $ctype | LC_ALL=C sed -e 's/.*\.\([^.@]\+\)@.*/\1/g' `
469 *.*)
470 # if it contains only a '.' and no '@', everything behind the '.'
471 # is the encoding:
472 LOCALE_CHARMAP=`echo $ctype | LC_ALL=C cut -d '.' -f 2 `
474 # no encoding could be found in LC_CTYPE, try the language
475 # and/or country codes as a fallback.
476 zh_TW*)
477 LOCALE_CHARMAP=Big5
479 zh_HK*)
480 LOCALE_CHARMAP=Big5HKSCS
482 zh*)
483 LOCALE_CHARMAP=GB2312
485 ja*)
486 LOCALE_CHARMAP=EUC-JP
488 ko*)
489 LOCALE_CHARMAP=EUC-KR
491 ru*)
492 LOCALE_CHARMAP=KOI8-R
494 uk*)
495 LOCALE_CHARMAP=KOI8-U
497 pl*|hr*|hu*|cs*|sk*|sl*)
498 LOCALE_CHARMAP=ISO-8859-2
500 eo*|mt*)
501 LOCALE_CHARMAP=ISO-8859-3
503 el*)
504 LOCALE_CHARMAP=ISO-8859-7
506 he*)
507 LOCALE_CHARMAP=ISO-8859-8
509 tr*)
510 LOCALE_CHARMAP=ISO-8859-9
512 th*)
513 LOCALE_CHARMAP=TIS-620 # or ISO-8859-11
515 lt*)
516 LOCALE_CHARMAP=ISO-8859-13
518 cy*)
519 LOCALE_CHARMAP=ISO-8859-14
521 ro*)
522 LOCALE_CHARMAP=ISO-8859-14 # or ISO-8859-16
524 am*|vi*)
525 LOCALE_CHARMAP=UTF-8
528 LOCALE_CHARMAP=ISO-8859-1
530 esac
532 # The exact spelling of the value of LOCALE_CHARMAP may differ a little
533 # bit on different systems.
534 # Converting it to lowercase and removing '-' and '_' characters hopefully
535 # gives the same results on most systems though and should make matching
536 # encodings easier.
537 # Attention!: make sure that tr is running in POSIX locale when doing the
538 # conversion to lowercase, otherwise one might run into locale dependent
539 # problems. For example in tr_TR locale, the lowercase version of 'I'
540 # is U+0131 (LATIN SMALL LETTER DOTLESS I), i.e. it doesn't have a dot
541 # like the lowercase version of 'I' in most other locales.
542 LOCALE_CHARMAP=`echo $LOCALE_CHARMAP | LC_ALL=C tr '[:upper:]' '[:lower:]' | tr -d '_-'`
545 if [ -z "$family" ]; then
546 if [ -n "$new_locale" ]; then
547 export LC_ALL="$new_locale"
550 locale_charmap;
551 case "$LOCALE_CHARMAP" in
552 utf8)
553 family="generic"
555 eucjp)
556 family="japanese"
558 euckr)
559 family="korean2"
561 iso88591)
562 family="latin1"
564 iso88592)
565 family="latin2"
567 iso88599)
568 family="latin5"
570 iso885915)
571 family="latin9"
573 iso88597)
574 family="greek"
576 koi8u)
577 family="ukrainian"
579 koi8r)
580 family="russian"
582 cp1251)
583 family="cp1251"
585 iso88595)
586 family="isocyr"
589 family="default"
591 esac
592 echo "using family=$family ..."
596 # Do we recognize passed coding?
598 is_supported=""
599 for i in $Supported; do
600 if test "$family" = "$i"; then
601 is_supported="YES"
602 break
604 done
605 if test -z "$is_supported"; then # unknown coding
606 cat >/dev/stderr <<EOT
607 Sorry, font coding $family or locale $locale not recognized.
608 Type $PROGRAM with no arguments for list of supported font codings...
610 exit 1
614 # Nodef is supported only for elements of $NodefAble.
616 is_nodef_unable=""
617 for i in $NodefUnable; do
618 if test "$family" = "$i"; then
619 if test -n "$nodef"; then # --nodef with one from $NodefUnable
620 cat >/dev/stderr <<-EOT
621 Sorry, --nodef argument is not allowed for these font codings:
622 $NodefUnable
623 Run $PROGRAM without --nodef argument to set default fonts for your
624 font coding.
626 exit 1
627 else
628 is_nodef_unable="YES"
629 break
632 done
635 # The real work...
637 if test -z "$nodef"; then
638 for i in $AllKeys; do
639 if test -n "$is_nodef_unable"; then # japanese,... defaults
640 tmp="$family$i"
641 eval $i="\$${tmp}"
642 else # rest, load defaults
643 not_font=""
644 for j in $NotFont; do
645 if test "$i" = "$j"; then
646 not_font="YES"
647 break
649 done
650 if test -n "$not_font"; then # don't append coding (not default!)
651 tmp="${family}$i"
652 eval $i="\$${tmp}"
653 else # append coding
654 tmp="Default$i"
655 tmp1="${family}Coding"
656 eval $i="\$${tmp}\$${tmp1}"
659 done
660 else
661 cat >/dev/stderr <<EOT
662 You used --nodef command line argument. You should note, that this
663 works with these font codings only:
664 $NodefAble
665 You should not use it to change fonts from other font codings than
666 those listed above. If your WindowMaker does not appear to find fonts,
667 you should run $PROGRAM once again without --nodef argument.
672 # Ok, in the following, `i' will be the domain file name,
673 # `j' is the actual key in that file we try to change...
675 for i in $DomainNames; do
676 echo
677 echo "Setting up $i domain file..."
678 tmp="Domain$i"
679 eval _tmp="\$${tmp}"
680 for j in ${_tmp}; do
681 if test -n "$nodef"; then # --nodef, change coding only
682 not_font=""
683 for k in $NotFont; do
684 if test "$k" = "$j"; then
685 not_font="YES"
686 break;
688 done
689 if test -n "$not_font"; then # don't append coding
690 tmp1="${family}$j"
691 eval $j="\$${tmp1}"
692 else # append coding
693 #TODO:make this funny sed script a lot smarter to let us make changes in font
694 # lists, etc... (then we can enable --nodef for NodefUnable codings)
695 #TODO:better (or at least any) check, whether wmaker is installed...
696 tmp1="${family}Coding"
697 eval _tmp1="\$${tmp1}"
698 eval $j=`$WDREAD $i $j | sed -e "s/\(^-.*-\).*-.*$/\1${_tmp1}/g"`
699 eval _j="\$$j"
700 if test -z "${_j}"; then # failed, load default
701 tmp2="Default$j"
702 eval $j="\$${tmp2}"
706 tmp1="$j=\"`eval echo '${'$j'}'`\"" # cosmetic length workaround
707 echo '<<<<'
708 if [ ${#tmp1} -lt 80 ]; then
709 tmp1=`echo $tmp1 | sed -e 's/^\(.\{1,76\}\).*/\1/'`
711 eval _j="\$$j"
712 echo $j="${_j}"
713 $WDWRITE $i $j \"${_j}\"
714 done
715 done
716 echo