Commit | Line | Data |
---|---|---|
60370d40 | 1 | ;;; fontset.el --- commands for handling fontset |
4ed46869 | 2 | |
d4877ac1 | 3 | ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
e3fe4da0 | 4 | ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
7976eda0 | 5 | ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
e3fe4da0 | 6 | ;; 2005, 2006, 2007, 2008 |
2fd125a3 KH |
7 | ;; National Institute of Advanced Industrial Science and Technology (AIST) |
8 | ;; Registration Number H14PRO021 | |
6118a2b8 | 9 | ;; Copyright (C) 2003, 2006 |
8f924df7 KH |
10 | ;; National Institute of Advanced Industrial Science and Technology (AIST) |
11 | ;; Registration Number H13PRO009 | |
4ed46869 | 12 | |
8135c753 | 13 | ;; Keywords: mule, i18n, fontset |
4ed46869 KH |
14 | |
15 | ;; This file is part of GNU Emacs. | |
16 | ||
17 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
18 | ;; it under the terms of the GNU General Public License as published by | |
d7142f3e | 19 | ;; the Free Software Foundation; either version 3, or (at your option) |
4ed46869 KH |
20 | ;; any later version. |
21 | ||
22 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
23 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | ;; GNU General Public License for more details. | |
26 | ||
27 | ;; You should have received a copy of the GNU General Public License | |
369314dc | 28 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
3a35cf56 LK |
29 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
30 | ;; Boston, MA 02110-1301, USA. | |
4ed46869 | 31 | |
60370d40 PJ |
32 | ;;; Commentary: |
33 | ||
4ed46869 KH |
34 | ;;; Code: |
35 | ||
37a94e2f KH |
36 | ;; Setup font-encoding-alist for all known encodings. |
37 | ||
38 | (setq font-encoding-alist | |
39 | '(("iso8859-1$" . iso-8859-1) | |
40 | ("iso8859-2$" . iso-8859-2) | |
41 | ("iso8859-3$" . iso-8859-3) | |
42 | ("iso8859-4$" . iso-8859-4) | |
43 | ("iso8859-5$" . iso-8859-5) | |
44 | ("iso8859-6$" . iso-8859-6) | |
45 | ("iso8859-7$" . iso-8859-7) | |
46 | ("iso8859-8$" . iso-8859-8) | |
47 | ("iso8859-9$" . iso-8859-9) | |
48 | ("iso8859-10$" . iso-8859-10) | |
49 | ("iso8859-11$" . iso-8859-11) | |
50 | ("iso8859-13$" . iso-8859-13) | |
51 | ("iso8859-14$" . iso-8859-14) | |
52 | ("iso8859-15$" . iso-8859-15) | |
cd5315ac | 53 | ("iso8859-16$" . iso-8859-16) |
37a94e2f | 54 | ("gb2312.1980" . chinese-gb2312) |
28f2f887 | 55 | ("gbk" . chinese-gbk) |
26cdb3ee | 56 | ("gb18030" . (unicode . nil)) |
37a94e2f KH |
57 | ("jisx0208.1978" . japanese-jisx0208-1978) |
58 | ("jisx0208" . japanese-jisx0208) | |
59 | ("jisx0201" . jisx0201) | |
60 | ("jisx0212" . japanese-jisx0212) | |
61 | ("ksc5601.1987" . korean-ksc5601) | |
62 | ("cns11643.1992.*1" . chinese-cns11643-1) | |
63 | ("cns11643.1992.*2" . chinese-cns11643-2) | |
64 | ("cns11643.1992.*3" . chinese-cns11643-3) | |
65 | ("cns11643.1992.*4" . chinese-cns11643-4) | |
66 | ("cns11643.1992.*5" . chinese-cns11643-5) | |
67 | ("cns11643.1992.*6" . chinese-cns11643-6) | |
68 | ("cns11643.1992.*7" . chinese-cns11643-7) | |
eb62213c KH |
69 | ("cns11643.92p1-0" . chinese-cns11643-1) |
70 | ("cns11643.92p2-0" . chinese-cns11643-2) | |
71 | ("cns11643.92p3-0" . chinese-cns11643-3) | |
72 | ("cns11643.92p4-0" . chinese-cns11643-4) | |
73 | ("cns11643.92p5-0" . chinese-cns11643-5) | |
74 | ("cns11643.92p6-0" . chinese-cns11643-6) | |
75 | ("cns11643.92p7-0" . chinese-cns11643-7) | |
37a94e2f | 76 | ("big5" . big5) |
37a94e2f KH |
77 | ("viscii" . viscii) |
78 | ("tis620" . tis620-2533) | |
b32f2167 | 79 | ("microsoft-cp1251" . windows-1251) |
6118a2b8 | 80 | ("koi8-r" . koi8-r) |
ef1d428c KH |
81 | ("jisx0213.2000-1" . japanese-jisx0213-1) |
82 | ("jisx0213.2000-2" . japanese-jisx0213-2) | |
83 | ("jisx0213.2004-1" . japanese-jisx0213.2004-1) | |
84 | ("iso10646-1$" . (unicode-bmp . nil)) | |
85 | ("iso10646.indian-1" . (unicode-bmp . nil)) | |
86 | ("unicode-bmp" . (unicode-bmp . nil)) | |
87 | ("abobe-symbol" . symbol) | |
88 | ("sisheng_cwnn" . chinese-sisheng) | |
37a94e2f KH |
89 | ("mulearabic-0" . arabic-digit) |
90 | ("mulearabic-1" . arabic-1-column) | |
91 | ("mulearabic-2" . arabic-2-column) | |
92 | ("muleipa" . ipa) | |
362cd0bf | 93 | ("ethiopic-unicode" . (unicode-bmp . ethiopic)) |
37a94e2f | 94 | ("is13194-devanagari" . indian-is13194) |
8f924df7 KH |
95 | ("Devanagari-CDAC" . devanagari-cdac) |
96 | ("Sanskrit-CDAC" . sanskrit-cdac) | |
97 | ("Bengali-CDAC" . bengali-cdac) | |
98 | ("Assamese-CDAC" . assamese-cdac) | |
99 | ("Punjabi-CDAC" . punjabi-cdac) | |
100 | ("Gujarati-CDAC" . gujarati-cdac) | |
101 | ("Oriya-CDAC" . oriya-cdac) | |
102 | ("Tamil-CDAC" . tamil-cdac) | |
103 | ("Telugu-CDAC" . telugu-cdac) | |
104 | ("Kannada-CDAC" . kannada-cdac) | |
105 | ("Malayalam-CDAC" . malayalam-cdac) | |
106 | ("Devanagari-Akruti" . devanagari-akruti) | |
107 | ("Bengali-Akruti" . bengali-akruti) | |
108 | ("Punjabi-Akruti" . punjabi-akruti) | |
109 | ("Gujarati-Akruti" . gujarati-akruti) | |
110 | ("Oriya-Akruti" . oriya-akruti) | |
111 | ("Tamil-Akruti" . tamil-akruti) | |
112 | ("Telugu-Akruti" . telugu-akruti) | |
113 | ("Kannada-Akruti" . kannada-akruti) | |
114 | ("Malayalam-Akruti" . malayalam-akruti) | |
37a94e2f KH |
115 | ("muleindian-2" . indian-2-column) |
116 | ("muleindian-1" . indian-1-column) | |
117 | ("mulelao-1" . mule-lao) | |
118 | ("muletibetan-2" . tibetan) | |
ef1d428c | 119 | ("muletibetan-1" . tibetan-1-column))) |
37a94e2f | 120 | |
6ce70459 KH |
121 | (setq font-encoding-charset-alist |
122 | '((latin-iso8859-1 . iso-8859-1) | |
123 | (latin-iso8859-2 . iso-8859-2) | |
124 | (latin-iso8859-3 . iso-8859-3) | |
125 | (latin-iso8859-4 . iso-8859-4) | |
126 | (latin-iso8859-9 . iso-8859-9) | |
127 | (latin-iso8859-10 . iso-8859-10) | |
128 | (latin-iso8859-13 . iso-8859-13) | |
129 | (latin-iso8859-14 . iso-8859-14) | |
130 | (latin-iso8859-15 . iso-8859-15) | |
131 | (latin-iso8859-16 . iso-8859-16) | |
132 | (cyrillic-iso8859-5 . iso-8859-5) | |
133 | (greek-iso8859-7 . iso-8859-7) | |
134 | (arabic-iso8859-6 . iso-8859-6) | |
135 | (thai-tis620 . tis620-2533) | |
136 | (latin-jisx0201 . jisx0201) | |
137 | (katakana-jisx0201 . jisx0201) | |
138 | (chinese-big5-1 . big5) | |
139 | (chinese-big5-2 . big5) | |
140 | (vietnamese-viscii-lower . viscii) | |
141 | (vietnamese-viscii-upper . viscii) | |
142 | (tibetan . unicode-bmp))) | |
143 | ||
6118a2b8 | 144 | (setq script-representative-chars |
f3a9e177 KH |
145 | '((latin ?A ?Z ?a ?z) |
146 | (greek #x3A9) | |
6118a2b8 KH |
147 | (coptic #x3E2) |
148 | (cyrillic #x42F) | |
149 | (armenian #x531) | |
150 | (hebrew #x5D0) | |
151 | (arabic #x628) | |
152 | (syriac #x710) | |
153 | (thaana #x78C) | |
154 | (devanagari #x915) | |
155 | (bengali #x995) | |
156 | (gurmukhi #xA15) | |
157 | (gujarati #xA95) | |
158 | (oriya #xB15) | |
159 | (tamil #xB95) | |
160 | (telugu #xC15) | |
161 | (kannada #xC95) | |
162 | (malayalam #xD15) | |
163 | (sinhala #xD95) | |
164 | (thai #xE17) | |
165 | (lao #xEA5) | |
166 | (tibetan #xF40) | |
167 | (myanmar #x1000) | |
168 | (georgian #x10D3) | |
169 | (ethiopic #x1208) | |
170 | (cherokee #x13B6) | |
171 | (canadian-aboriginal #x14C0) | |
172 | (ogham #x168F) | |
173 | (runic #x16A0) | |
174 | (khmer #x1780) | |
175 | (mongolian #x1826) | |
176 | (braille #x2800) | |
177 | (ideographic-description #x2FF0) | |
178 | (cjk-misc #x300E) | |
179 | (kana #x304B) | |
180 | (bopomofo #x3105) | |
181 | (kanbun #x319D) | |
182 | (han #x5B57) | |
183 | (yi #xA288) | |
e585323a KH |
184 | (cham #xAA00) |
185 | (tai-viet #xAA80) | |
6118a2b8 | 186 | (hangul #xAC00))) |
37a94e2f | 187 | |
10853234 KH |
188 | (setq otf-script-alist |
189 | '((arab . arabic) | |
190 | (armn . armenian) | |
191 | (bali . balinese) | |
192 | (beng . bengali) | |
193 | (bopo . bopomofo) | |
194 | (brai . braille) | |
195 | (bugi . buginese) | |
196 | (buhd . buhid) | |
27950902 | 197 | (byzm . byzantine-musical-symbol) |
6ce70459 | 198 | (cans . canadian-aboriginal) |
10853234 KH |
199 | (cher . cherokee) |
200 | (copt . coptic) | |
201 | (xsux . cuneiform) | |
202 | (cyrl . cyrillic) | |
203 | (cprt . cypriot) | |
204 | (dsrt . deseret) | |
205 | (deva . devanagari) | |
206 | (ethi . ethiopic) | |
207 | (geor . georgian) | |
208 | (glag . glagolitic) | |
209 | (goth . gothic) | |
210 | (grek . greek) | |
211 | (gujr . gujarati) | |
212 | (guru . gurmukhi) | |
213 | (hani . han) | |
214 | (hang . hangul) | |
215 | (hano . hanunoo) | |
216 | (hebr . hebrew) | |
217 | (kana . kana) | |
218 | (knda . kannada) | |
219 | (khar . kharoshthi) | |
220 | (khmr . khmer) | |
d9080b86 | 221 | (lao\ . lao) |
10853234 KH |
222 | (latn . latin) |
223 | (limb . limbu) | |
224 | (linb . linear_b) | |
225 | (mlym . malayalam) | |
27950902 | 226 | (math . mathematical) |
10853234 | 227 | (mong . mongolian) |
27950902 | 228 | (musc . musical-symbol) |
10853234 | 229 | (mymr . myanmar) |
d9080b86 | 230 | (nko\ . nko) |
10853234 KH |
231 | (ogam . ogham) |
232 | (ital . old_italic) | |
233 | (xpeo . old_persian) | |
234 | (orya . oriya) | |
235 | (osma . osmanya) | |
236 | (phag . phags-pa) | |
237 | (phnx . phoenician) | |
238 | (runr . runic) | |
239 | (shaw . shavian) | |
240 | (sinh . sinhala) | |
241 | (sylo . syloti_nagri) | |
242 | (syrc . syriac) | |
243 | (tglg . tagalog) | |
244 | (tagb . tagbanwa) | |
245 | (taml . tamil) | |
246 | (tale . tai_le) | |
247 | (telu . telugu) | |
248 | (thaa . thaana) | |
249 | (thai . thai) | |
250 | (tibt . tibetan) | |
251 | (tfng . tifinagh) | |
252 | (ugar . ugaritic) | |
d9080b86 | 253 | (yi\ \ . yi))) |
10853234 | 254 | |
2ad00186 | 255 | ;; Set standard fontname specification of characters in the default |
37a94e2f KH |
256 | ;; fontset to find an appropriate font for each script/charset. The |
257 | ;; specification has the form ((SCRIPT FONT-SPEC ...) ...), where | |
258 | ;; FONT-SPEC is: | |
9841dbc9 KH |
259 | ;; a cons (FAMILY . REGISTRY), |
260 | ;; or a string FONT-NAME, | |
261 | ;; or an object created by `font-spec'. | |
8f924df7 | 262 | ;; |
9841dbc9 KH |
263 | ;; FAMILY may be nil, in which case, the the corresponding name of |
264 | ;; default face is used. If REGISTRY contains a character `-', the | |
265 | ;; string before that is embedded in `CHARSET_REGISTRY' field, and the | |
266 | ;; string after that is embedded in `CHARSET_ENCODING' field. If it | |
267 | ;; does not contain `-', the whole string is embedded in | |
268 | ;; `CHARSET_REGISTRY' field, and a wild card character `*' is embedded | |
269 | ;; in `CHARSET_ENCODING' field. | |
37a94e2f KH |
270 | ;; |
271 | ;; SCRIPT is a symbol that appears as an element of the char table | |
272 | ;; `char-script-table'. SCRIPT may be a charset specifying the range | |
273 | ;; of characters. | |
2ad00186 | 274 | |
c963bbc2 KH |
275 | (defun setup-default-fontset () |
276 | "Setup the default fontset." | |
8f924df7 KH |
277 | (new-fontset |
278 | "fontset-default" | |
d9080b86 | 279 | `(;; for each script |
8f924df7 KH |
280 | (latin (nil . "ISO8859-1") |
281 | (nil . "ISO8859-2") | |
282 | (nil . "ISO8859-3") | |
283 | (nil . "ISO8859-4") | |
284 | (nil . "ISO8859-9") | |
285 | (nil . "ISO8859-10") | |
286 | (nil . "ISO8859-13") | |
287 | (nil . "ISO8859-14") | |
288 | (nil . "ISO8859-15") | |
cd5315ac | 289 | (nil . "ISO8859-16") |
e585323a KH |
290 | (nil . "VISCII1.1-1") |
291 | (nil . "ISO10646-1")) | |
8f924df7 | 292 | |
6ce70459 KH |
293 | (thai ,(font-spec :registry "iso10646-1" :otf '(thai nil nil (mark))) |
294 | (nil . "TIS620*") | |
295 | (nil . "ISO8859-11")) | |
8f924df7 | 296 | |
d9080b86 KH |
297 | (devanagari ,(font-spec :registry "iso10646-1" :otf '(deva nil (rphf))) |
298 | (nil . "iso10646.indian-1")) | |
6ce70459 KH |
299 | (bengali ,(font-spec :registry "iso10646-1" :otf '(beng nil (rphf)))) |
300 | (gurmukhi ,(font-spec :registry "iso10646-1" :otf '(guru nil (blwf)))) | |
301 | (gujarati ,(font-spec :registry "iso10646-1" :otf '(gujr nil (rphf)))) | |
302 | (oriya ,(font-spec :registry "iso10646-1" :otf '(orya nil (rphf)))) | |
d9080b86 | 303 | (tamil ,(font-spec :registry "iso10646-1" :otf '(taml nil (akhn)))) |
6ce70459 KH |
304 | (telugu ,(font-spec :registry "iso10646-1" :otf '(telu nil (blwf)))) |
305 | (kannada ,(font-spec :registry "iso10646-1" :otf '(knda nil (rphf)))) | |
306 | (sinhala ,(font-spec :registry "iso10646-1" :otf '(sinh nil (akhn)))) | |
307 | (malayalam ,(font-spec :registry "iso10646-1" :otf '(mlym nil (akhn)))) | |
8f924df7 | 308 | |
01308609 | 309 | (lao ,(font-spec :registry "iso10646-1" :otf '(lao\ nil nil (mark))) |
a1fe5dfa | 310 | ,(font-spec :registry "iso10646-1" :script 'lao) |
6ce70459 | 311 | (nil . "MuleLao-1")) |
8f924df7 | 312 | |
f6724075 KH |
313 | (tai-viet ("TaiViet" . "iso10646-1")) |
314 | ||
8f924df7 | 315 | ;; both for script and charset. |
b6381d6c KH |
316 | (tibetan ,(font-spec :registry "iso10646-1" |
317 | :otf '(tibt nil (ccmp blws abvs))) | |
318 | ,(font-spec :family "mtib" :registry "iso10646-1") | |
319 | (nil . "muletibetan-2")) | |
8f924df7 KH |
320 | |
321 | ;; both for script and charset. | |
6ce70459 KH |
322 | (ethiopic ,(font-spec :registry "iso10646-1" :script 'ethiopic) |
323 | (nil . "ethiopic-unicode")) | |
8f924df7 | 324 | |
6ce70459 KH |
325 | (greek ,(font-spec :registry "iso10646-1" :script 'greek) |
326 | (nil . "ISO8859-7")) | |
8f924df7 | 327 | |
6ce70459 KH |
328 | (cyrillic ,(font-spec :registry "iso10646-1" :script 'cyrillic) |
329 | (nil . "ISO8859-5") | |
b32f2167 KH |
330 | (nil . "microsoft-cp1251") |
331 | (nil . "koi8-r")) | |
8f924df7 | 332 | |
6ce70459 | 333 | (arabic ,(font-spec :registry "iso10646-1" |
fe243f8e | 334 | :otf '(arab nil (init medi fini liga))) |
6ce70459 | 335 | (nil . "MuleArabic-0") |
8f924df7 KH |
336 | (nil . "MuleArabic-1") |
337 | (nil . "MuleArabic-2") | |
338 | (nil . "ISO8859-6")) | |
339 | ||
6ce70459 KH |
340 | (hebrew ,(font-spec :registry "iso10646-1" :script 'hebrew) |
341 | (nil . "ISO8859-8")) | |
342 | ||
343 | (syriac ,(font-spec :registry "iso10646-1" :script 'syriac)) | |
344 | ||
345 | (thaana ,(font-spec :registry "iso10646-1" :otf '(thaa nil nil))) | |
346 | ||
347 | (myanmar ,(font-spec :registry "iso10646-1" :script 'myanmar)) | |
348 | ||
349 | (georgian ,(font-spec :registry "iso10646-1" :script 'georgian)) | |
350 | ||
351 | (cherokee ,(font-spec :registry "iso10646-1" :script 'cherokee)) | |
8f924df7 | 352 | |
6ce70459 KH |
353 | (canadian-aboriginal ,(font-spec :registry "iso10646-1" |
354 | :script 'canadian-aboriginal)) | |
355 | ||
356 | (ogham ,(font-spec :registry "iso10646-1" :script 'ogham)) | |
357 | ||
358 | (runic ,(font-spec :registry "iso10646-1" :script 'runic)) | |
359 | ||
360 | (khmer ,(font-spec :registry "iso10646-1" :otf '(khmr nil (pres)))) | |
361 | ||
362 | (yi ,(font-spec :registry "iso10646-1" :script 'yi)) | |
363 | ||
364 | (kana ,(font-spec :registry "iso10646-1" :script 'kana) | |
365 | (nil . "JISX0208*") | |
8f924df7 KH |
366 | (nil . "GB2312.1980-0") |
367 | (nil . "KSC5601.1987*") | |
d1bd4b12 KH |
368 | (nil . "JISX0201*") |
369 | (nil . "JISX0213.2000-1") | |
370 | (nil . "JISX0213.2004-1")) | |
8f924df7 | 371 | |
66fb0117 JR |
372 | (bopomofo ,(font-spec :registry "iso10646-1" :script 'bopomofo) |
373 | (nil . "sisheng_cwnn-0")) | |
8f924df7 | 374 | |
6ce70459 KH |
375 | (han ,(font-spec :registry "iso10646-1" :language 'ja) |
376 | ,(font-spec :registry "iso10646-1" :language 'zh) | |
377 | (nil . "GB2312.1980-0") | |
8f924df7 KH |
378 | (nil . "JISX0208*") |
379 | (nil . "JISX0212*") | |
380 | (nil . "big5*") | |
381 | (nil . "KSC5601.1987*") | |
382 | (nil . "CNS11643.1992-1") | |
383 | (nil . "CNS11643.1992-2") | |
384 | (nil . "CNS11643.1992-3") | |
385 | (nil . "CNS11643.1992-4") | |
386 | (nil . "CNS11643.1992-5") | |
387 | (nil . "CNS11643.1992-6") | |
388 | (nil . "CNS11643.1992-7") | |
389 | (nil . "gbk-0") | |
c7606603 | 390 | (nil . "gb18030") |
8f924df7 | 391 | (nil . "JISX0213.2000-1") |
a16abfed KH |
392 | (nil . "JISX0213.2000-2") |
393 | (nil . "JISX0213.2004-1")) | |
8f924df7 | 394 | |
e585323a KH |
395 | (cjk-misc ,(font-spec :registry "iso10646-1" :language 'ja) |
396 | ,(font-spec :registry "iso10646-1" :language 'zh) | |
397 | (nil . "GB2312.1980-0") | |
8f924df7 KH |
398 | (nil . "JISX0208*") |
399 | (nil . "JISX0212*") | |
400 | (nil . "big5*") | |
401 | (nil . "KSC5601.1987*") | |
402 | (nil . "CNS11643.1992-1") | |
403 | (nil . "CNS11643.1992-2") | |
404 | (nil . "CNS11643.1992-3") | |
405 | (nil . "CNS11643.1992-4") | |
406 | (nil . "CNS11643.1992-5") | |
407 | (nil . "CNS11643.1992-6") | |
408 | (nil . "CNS11643.1992-7") | |
409 | (nil . "gbk-0") | |
c7606603 | 410 | (nil . "gb18030") |
8f924df7 KH |
411 | (nil . "JISX0213.2000-1") |
412 | (nil . "JISX0213.2000-2")) | |
413 | ||
6ce70459 KH |
414 | (hangul ,(font-spec :registry "iso10646-1" :language 'ko) |
415 | (nil . "KSC5601.1987-0")) | |
8f924df7 | 416 | |
66fb0117 JR |
417 | (braille ,(font-spec :registry "iso10646-1" :script 'braille)) |
418 | ||
419 | (mathematical ,(font-spec :registry "iso10646-1" :script 'mathematical)) | |
420 | ||
8f924df7 KH |
421 | ;; for each charset |
422 | (ascii (nil . "ISO8859-1")) | |
423 | (arabic-digit ("*" . "MuleArabic-0")) | |
424 | (arabic-1-column ("*" . "MuleArabic-1")) | |
425 | (arabic-2-column ("*" . "MuleArabic-2")) | |
426 | (indian-is13194 (nil . "is13194-devanagari")) | |
427 | (indian-1-column ("*" . "muleindian-2")) | |
428 | ;; Indian CDAC | |
429 | (devanagari-cdac (nil . "Devanagari-CDAC")) | |
430 | (sanskrit-cdac (nil . "Sanskrit-CDAC")) | |
431 | (bengali-cdac (nil . "Bengali-CDAC")) | |
432 | (assamese-cdac (nil . "Assamese-CDAC")) | |
433 | (punjabi-cdac (nil . "Punjabi-CDAC")) | |
434 | (gujarati-cdac (nil . "Gujarati-CDAC")) | |
435 | (oriya-cdac (nil . "Oriya-CDAC")) | |
436 | (tamil-cdac (nil . "Tamil-CDAC")) | |
437 | (telugu-cdac (nil . "Telugu-CDAC")) | |
438 | (kannada-cdac (nil . "Kannada-CDAC")) | |
439 | (malayalam-cdac (nil . "Malayalam-CDAC")) | |
440 | ;; Indian AKRUTI | |
441 | (devanagari-akruti (nil . "Devanagari-Akruti")) | |
442 | (bengali-akruti (nil . "Bengali-Akruti")) | |
443 | (punjabi-akruti (nil . "Punjabi-Akruti")) | |
444 | (gujarati-akruti (nil . "Gujarati-Akruti")) | |
445 | (oriya-akruti (nil . "Oriya-Akruti")) | |
446 | (tamil-akruti (nil . "Tamil-Akruti")) | |
447 | (telugu-akruti (nil . "Telugu-Akruti")) | |
448 | (kannada-akruti (nil . "Kannada-Akruti")) | |
449 | (malayalam-akruti (nil . "Malayalam-Akruti")) | |
450 | ;;(devanagari-glyph ("altsys-dv_ttsurekh" . "devanagari-cdac")) | |
451 | ;;(malayalam-glyph ("altsys-ml_ttkarthika" . "malayalam-cdac")) | |
66fb0117 JR |
452 | (ipa ,(font-spec :registry "iso10646-1" :script 'phonetic) |
453 | (nil . "MuleIPA-1") | |
e585323a | 454 | (nil . "iso10646-1")) |
d1bd4b12 KH |
455 | |
456 | ;; Fallback fonts | |
457 | (nil (nil . "gb2312.1980") | |
c7606603 KH |
458 | (nil . "gbk-0") |
459 | (nil . "gb18030") | |
d1bd4b12 KH |
460 | (nil . "jisx0208") |
461 | (nil . "ksc5601.1987") | |
eb62213c KH |
462 | (nil . "CNS11643.1992-1") |
463 | (nil . "CNS11643.1992-2") | |
464 | (nil . "CNS11643.1992-3") | |
465 | (nil . "CNS11643.1992-4") | |
466 | (nil . "CNS11643.1992-5") | |
467 | (nil . "CNS11643.1992-6") | |
468 | (nil . "CNS11643.1992-7") | |
d1bd4b12 KH |
469 | (nil . "big5") |
470 | (nil . "jisx0213.2000-1") | |
471 | (nil . "jisx0213.2004-1") | |
472 | (nil . "jisx0212")) | |
8f924df7 KH |
473 | )) |
474 | ||
475 | ;; Append Unicode fonts. | |
476 | ;; This may find fonts with more variants (bold, italic) but which | |
477 | ;; don't cover many characters. | |
d1bd4b12 | 478 | (set-fontset-font "fontset-default" nil |
8f924df7 KH |
479 | '(nil . "iso10646-1") nil 'append) |
480 | ;; These may find fonts that cover many characters but with fewer | |
481 | ;; variants. | |
d1bd4b12 | 482 | (set-fontset-font "fontset-default" nil |
8f924df7 | 483 | '("gnu-unifont" . "iso10646-1") nil 'append) |
d1bd4b12 | 484 | (set-fontset-font "fontset-default" nil |
e585323a KH |
485 | '("mutt-clearlyu" . "iso10646-1") nil 'append) |
486 | ||
487 | (set-fontset-font "fontset-default" '(#xE000 . #xF8FF) nil)) | |
06f76f0d | 488 | |
8135c753 DL |
489 | ;; These are the registered registries/encodings from |
490 | ;; ftp://ftp.x.org/pub/DOCS/registry 2001/06/01 | |
491 | ||
492 | ;; Name Reference | |
493 | ;; ---- --------- | |
494 | ;; "DEC" [27] | |
495 | ;; registry prefix | |
496 | ;; "DEC.CNS11643.1986-2" [53] | |
497 | ;; CNS11643 2-plane using the encoding | |
498 | ;; suggested in that standard | |
499 | ;; "DEC.DTSCS.1990-2" [54] | |
500 | ;; DEC Taiwan Supplemental Character Set | |
501 | ;; "fujitsu.u90x01.1991-0" [87] | |
502 | ;; "fujitsu.u90x03.1991-0" [87] | |
503 | ;; "GB2312.1980-0" [39],[12] | |
504 | ;; China (PRC) Hanzi, GL encoding | |
505 | ;; "GB2312.1980-1" [39] | |
506 | ;; (deprecated) | |
507 | ;; China (PRC) Hanzi, GR encoding | |
508 | ;; "HP-Arabic8" [36] | |
509 | ;; HPARABIC8 8-bit character set | |
510 | ;; "HP-East8" [36] | |
511 | ;; HPEAST8 8-bit character set | |
512 | ;; "HP-Greek8" [36] | |
513 | ;; HPGREEK8 8-bit character set | |
514 | ;; "HP-Hebrew8" [36] | |
515 | ;; HPHEBREW8 8-bit character set | |
516 | ;; "HP-Japanese15" [36] | |
517 | ;; HPJAPAN15 15-bit characer set, | |
518 | ;; modified from industry defacto | |
519 | ;; standard Shift-JIS | |
520 | ;; "HP-Kana8" [36] | |
521 | ;; HPKANA8 8-bit character set | |
522 | ;; "HP-Korean15" [36] | |
523 | ;; HPKOREAN15 15-bit character set | |
524 | ;; "HP-Roman8" [36] | |
525 | ;; HPROMAN8 8-bit character set | |
526 | ;; "HP-SChinese15" [36] | |
527 | ;; HPSCHINA15 15-bit character set for | |
528 | ;; support of Simplified Chinese | |
529 | ;; "HP-TChinese15" [36] | |
530 | ;; HPTCHINA15 15-bit character set for | |
531 | ;; support of Traditional Chinese | |
532 | ;; "HP-Turkish8" [36] | |
533 | ;; HPTURKISH8 8-bit character set | |
534 | ;; "IPSYS" [59] | |
535 | ;; registry prefix | |
536 | ;; "IPSYS.IE-1" [59] | |
537 | ;; "ISO2022"<REG>"-"<ENC> [44] | |
538 | ;; "ISO646.1991-IRV" [107] | |
539 | ;; ISO 646 International Reference Version | |
540 | ;; "ISO8859-1" [15],[12] | |
541 | ;; ISO Latin alphabet No. 1 | |
542 | ;; "ISO8859-2" [15],[12] | |
543 | ;; ISO Latin alphabet No. 2 | |
544 | ;; "ISO8859-3" [15],[12] | |
545 | ;; ISO Latin alphabet No. 3 | |
546 | ;; "ISO8859-4" [15],[12] | |
547 | ;; ISO Latin alphabet No. 4 | |
548 | ;; "ISO8859-5" [15],[12] | |
549 | ;; ISO Latin/Cyrillic alphabet | |
550 | ;; "ISO8859-6" [15],[12] | |
551 | ;; ISO Latin/Arabic alphabet | |
552 | ;; "ISO8859-7" [15],[12] | |
553 | ;; ISO Latin/Greek alphabet | |
554 | ;; "ISO8859-8" [15],[12] | |
555 | ;; ISO Latin/Hebrew alphabet | |
556 | ;; "ISO8859-9" [15],[12] | |
557 | ;; ISO Latin alphabet No. 5 | |
558 | ;; "ISO8859-10" [15],[12] | |
559 | ;; ISO Latin alphabet No. 6 | |
560 | ;; "ISO8859-13" [15],[12] | |
561 | ;; ISO Latin alphabet No. 7 | |
562 | ;; "ISO8859-14" [15],[12] | |
563 | ;; ISO Latin alphabet No. 8 | |
564 | ;; "ISO8859-15" [15],[12] | |
565 | ;; ISO Latin alphabet No. 9 | |
566 | ;; "FCD8859-15" [7] | |
567 | ;; (deprecated) | |
568 | ;; ISO Latin alphabet No. 9, Final Committee Draft | |
569 | ;; "ISO10646-1" [133] | |
570 | ;; Unicode Universal Multiple-Octet Coded Character Set | |
571 | ;; "ISO10646-MES" [133] | |
572 | ;; (deprecated) | |
573 | ;; Unicode Minimum European Subset | |
574 | ;; "JISX0201.1976-0" [38],[12] | |
575 | ;; 8-Bit Alphanumeric-Katakana Code | |
576 | ;; "JISX0208.1983-0" [40],[12] | |
577 | ;; Japanese Graphic Character Set, | |
578 | ;; GL encoding | |
579 | ;; "JISX0208.1990-0" [71] | |
580 | ;; Japanese Graphic Character Set, | |
581 | ;; GL encoding | |
582 | ;; "JISX0208.1983-1" [40] | |
583 | ;; (deprecated) | |
584 | ;; Japanese Graphic Character Set, | |
585 | ;; GR encoding | |
586 | ;; "JISX0212.1990-0" [72] | |
587 | ;; Supplementary Japanese Graphic Character Set, | |
588 | ;; GL encoding | |
589 | ;; "KOI8-R" [119] | |
590 | ;; Cyrillic alphabet | |
591 | ;; "KSC5601.1987-0" [41],[12] | |
592 | ;; Korean Graphic Character Set, | |
593 | ;; GL encoding | |
594 | ;; "KSC5601.1987-1" [41] | |
595 | ;; (deprecated) | |
596 | ;; Korean Graphic Character Set, | |
597 | ;; GR encoding | |
598 | ;; "omron_CNS11643-0" [45] | |
599 | ;; "omron_CNS11643-1" [45] | |
600 | ;; "omron_BIG5-0" [45] | |
601 | ;; "omron_BIG5-1" [45] | |
602 | ;; "wn.tamil.1993" [103] | |
4ed46869 | 603 | |
06f76f0d | 604 | (defun set-font-encoding (pattern charset) |
8135c753 | 605 | "Set arguments in `font-encoding-alist' (which see)." |
4ed46869 KH |
606 | (let ((slot (assoc pattern font-encoding-alist))) |
607 | (if slot | |
06f76f0d | 608 | (setcdr slot charset) |
4ed46869 | 609 | (setq font-encoding-alist |
06f76f0d | 610 | (cons (cons pattern charset) font-encoding-alist))))) |
12385722 | 611 | |
4ed46869 KH |
612 | ;; Setting for suppressing XLoadQueryFont on big fonts. |
613 | (setq x-pixel-size-width-font-regexp | |
c7606603 | 614 | "gb2312\\|gbk\\|gb18030\\|jisx0208\\|ksc5601\\|cns11643\\|big5") |
4ed46869 | 615 | |
6eca8d93 | 616 | ;; These fonts require vertical centering. |
0c4f97d0 | 617 | (setq vertical-centering-font-regexp |
c7606603 | 618 | "gb2312\\|gbk\\|gb18030\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5") |
0c4f97d0 | 619 | |
e46947a5 KH |
620 | ;; CDAC fonts are actually smaller than their design sizes. |
621 | (setq face-font-rescale-alist | |
622 | '(("-cdac$" . 1.3))) | |
623 | ||
06f76f0d KH |
624 | (defvar x-font-name-charset-alist nil |
625 | "This variable has no meaning now. Just kept for backward compatibility.") | |
6fb8f8bd | 626 | |
4ed46869 KH |
627 | ;;; XLFD (X Logical Font Description) format handler. |
628 | ||
629 | ;; Define XLFD's field index numbers. ; field name | |
06f76f0d KH |
630 | (defconst xlfd-regexp-family-subnum 0) ; FOUNDRY and FAMILY |
631 | (defconst xlfd-regexp-weight-subnum 1) ; WEIGHT_NAME | |
632 | (defconst xlfd-regexp-slant-subnum 2) ; SLANT | |
633 | (defconst xlfd-regexp-swidth-subnum 3) ; SETWIDTH_NAME | |
634 | (defconst xlfd-regexp-adstyle-subnum 4) ; ADD_STYLE_NAME | |
635 | (defconst xlfd-regexp-pixelsize-subnum 5) ; PIXEL_SIZE | |
636 | (defconst xlfd-regexp-pointsize-subnum 6) ; POINT_SIZE | |
637 | (defconst xlfd-regexp-resx-subnum 7) ; RESOLUTION_X | |
638 | (defconst xlfd-regexp-resy-subnum 8) ; RESOLUTION_Y | |
639 | (defconst xlfd-regexp-spacing-subnum 8) ; SPACING | |
640 | (defconst xlfd-regexp-avgwidth-subnum 10) ; AVERAGE_WIDTH | |
641 | (defconst xlfd-regexp-registry-subnum 11) ; REGISTRY and ENCODING | |
4ed46869 KH |
642 | |
643 | ;; Regular expression matching against a fontname which conforms to | |
644 | ;; XLFD (X Logical Font Description). All fields in XLFD should be | |
645 | ;; not be omitted (but can be a wild card) to be matched. | |
646 | (defconst xlfd-tight-regexp | |
647 | "^\ | |
06f76f0d | 648 | -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ |
4ed46869 | 649 | -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ |
06f76f0d KH |
650 | -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*-[^-]*\\)$") |
651 | ||
652 | ;; Regular expression matching against a fontname which conforms to | |
653 | ;; XLFD (X Logical Font Description). All fields in XLFD from FOUNDRY | |
8135c753 | 654 | ;; to ADSTYLE, REGISTRY, and ENCODING should be not be omitted (but |
06f76f0d KH |
655 | ;; can be a wild card) to be matched. |
656 | (defconst xlfd-style-regexp | |
657 | "^\ | |
658 | -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-.*\ | |
659 | -\\([^-]*-[^-]*\\)$") | |
4ed46869 KH |
660 | |
661 | ;; List of field numbers of XLFD whose values are numeric. | |
662 | (defconst xlfd-regexp-numeric-subnums | |
06f76f0d KH |
663 | (list xlfd-regexp-pixelsize-subnum ;5 |
664 | xlfd-regexp-pointsize-subnum ;6 | |
665 | xlfd-regexp-resx-subnum ;7 | |
666 | xlfd-regexp-resy-subnum ;8 | |
667 | xlfd-regexp-avgwidth-subnum ;10 | |
4ed46869 KH |
668 | )) |
669 | ||
670 | (defun x-decompose-font-name (pattern) | |
92438d6e | 671 | "Decompose PATTERN into XLFD fields and return a vector of the fields. |
06f76f0d | 672 | The length of the vector is 12. |
92438d6e KH |
673 | The FOUNDRY and FAMILY fields are concatinated and stored in the first |
674 | element of the vector. | |
675 | The REGISTRY and ENCODING fields are concatinated and stored in the last | |
676 | element of the vector. | |
677 | ||
678 | Return nil if PATTERN doesn't conform to XLFD." | |
679 | (if (string-match xlfd-tight-regexp pattern) | |
680 | (let ((xlfd-fields (make-vector 12 nil))) | |
681 | (dotimes (i 12) | |
682 | (aset xlfd-fields i (match-string (1+ i) pattern))) | |
683 | (dotimes (i 12) | |
684 | (if (string-match "^[*-]+$" (aref xlfd-fields i)) | |
685 | (aset xlfd-fields i nil))) | |
686 | xlfd-fields))) | |
441038a6 | 687 | |
bb98ead9 | 688 | (defun x-compose-font-name (fields &optional reduce) |
8135c753 | 689 | "Compose X fontname from FIELDS. |
a0451a71 | 690 | FIELDS is a vector of XLFD fields, of length 12. |
441038a6 | 691 | If a field is nil, wild-card letter `*' is embedded. |
33fac697 JB |
692 | Optional argument REDUCE exists just for backward compatibility, |
693 | and is always ignored." | |
6eca8d93 | 694 | (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-"))) |
bcb68cff | 695 | |
4fbe2b13 GM |
696 | |
697 | (defun x-must-resolve-font-name (xlfd-fields) | |
698 | "Like `x-resolve-font-name', but always return a font name. | |
699 | XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields. | |
700 | If no font matching XLFD-FIELDS is available, successively replace | |
701 | parts of the font name pattern with \"*\" until some font is found. | |
702 | Value is name of that font." | |
703 | (let ((ascii-font nil) (index 0)) | |
06f76f0d | 704 | (while (and (null ascii-font) (<= index xlfd-regexp-registry-subnum)) |
4fbe2b13 GM |
705 | (let ((pattern (x-compose-font-name xlfd-fields))) |
706 | (condition-case nil | |
707 | (setq ascii-font (x-resolve-font-name pattern)) | |
708 | (error | |
709 | (message "Warning: no fonts matching `%s' available" pattern) | |
710 | (aset xlfd-fields index "*") | |
711 | (setq index (1+ index)))))) | |
712 | (unless ascii-font | |
37aad8f5 | 713 | (error "No fonts found")) |
4fbe2b13 GM |
714 | ascii-font)) |
715 | ||
716 | ||
6ce70459 KH |
717 | (defun x-complement-fontset-spec (default-spec fontlist) |
718 | "Complement elements of FONTLIST based on DEFAULT-SPEC. | |
719 | DEFAULT-SPEC is a font-spec object providing default font properties. | |
92438d6e KH |
720 | FONTLIST is an alist of script names vs the corresponding font names. |
721 | ||
6ce70459 KH |
722 | The font names are parsed and unspecified font properties are |
723 | given from DEFAULT-SPEC." | |
5db50cca | 724 | (let ((prop-list '(:foundry :family :weight :slant :width :adstyle :size))) |
06f76f0d | 725 | (dolist (elt fontlist) |
6ce70459 KH |
726 | (let ((spec (font-spec :name (cadr elt)))) |
727 | (dolist (prop prop-list) | |
728 | (let ((val (font-get spec prop))) | |
729 | (or val | |
730 | (font-put spec prop (font-get default-spec prop))))) | |
731 | (setcar (cdr elt) spec))) | |
6eca8d93 | 732 | fontlist)) |
4ed46869 | 733 | |
35d4066a KH |
734 | (defun fontset-name-p (fontset) |
735 | "Return non-nil if FONTSET is valid as fontset name. | |
736 | A valid fontset name should conform to XLFD (X Logical Font Description) | |
33fac697 | 737 | with \"fontset\" in `<CHARSET_REGISTRY>' field." |
35d4066a KH |
738 | (and (string-match xlfd-tight-regexp fontset) |
739 | (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset) | |
740 | "fontset"))) | |
741 | ||
4ed46869 | 742 | (defun generate-fontset-menu () |
8135c753 DL |
743 | "Return list to be appended to `x-fixed-font-alist'. |
744 | Done when `mouse-set-font' is called." | |
d58b6a31 KH |
745 | (let (l) |
746 | (dolist (fontset (fontset-list)) | |
747 | (or (string-match "fontset-default$" fontset) | |
748 | (push (list (fontset-plain-name fontset) fontset) l))) | |
80ae5f3a | 749 | (cons "Fontset" |
d58b6a31 | 750 | (sort l #'(lambda (x y) (string< (car x) (car y))))))) |
4ed46869 KH |
751 | |
752 | (defun fontset-plain-name (fontset) | |
753 | "Return a plain and descriptive name of FONTSET." | |
494ec9bc KH |
754 | (if (not (setq fontset (query-fontset fontset))) |
755 | (error "Invalid fontset: %s" fontset)) | |
4ed46869 KH |
756 | (let ((xlfd-fields (x-decompose-font-name fontset))) |
757 | (if xlfd-fields | |
87997c2c KH |
758 | (let ((family (aref xlfd-fields xlfd-regexp-family-subnum)) |
759 | (weight (aref xlfd-fields xlfd-regexp-weight-subnum)) | |
4ed46869 KH |
760 | (slant (aref xlfd-fields xlfd-regexp-slant-subnum)) |
761 | (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum)) | |
762 | (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum)) | |
06f76f0d | 763 | (nickname (aref xlfd-fields xlfd-regexp-registry-subnum)) |
4ed46869 | 764 | name) |
06f76f0d | 765 | (if (not (string-match "^fontset-\\(.*\\)$" nickname)) |
87997c2c KH |
766 | (setq nickname family) |
767 | (setq nickname (match-string 1 nickname))) | |
09fd851a | 768 | (if (and size (> (string-to-number size) 0)) |
87997c2c KH |
769 | (setq name (format "%s: %s-dot" nickname size)) |
770 | (setq name nickname)) | |
771 | (and weight | |
772 | (cond ((string-match "^medium$" weight) | |
773 | (setq name (concat name " " "medium"))) | |
774 | ((string-match "^bold$\\|^demibold$" weight) | |
775 | (setq name (concat name " " weight))))) | |
776 | (and slant | |
777 | (cond ((string-match "^i$" slant) | |
778 | (setq name (concat name " " "italic"))) | |
779 | ((string-match "^o$" slant) | |
780 | (setq name (concat name " " "slant"))) | |
781 | ((string-match "^ri$" slant) | |
782 | (setq name (concat name " " "reverse italic"))) | |
783 | ((string-match "^ro$" slant) | |
784 | (setq name (concat name " " "reverse slant"))))) | |
785 | name) | |
4ed46869 KH |
786 | fontset))) |
787 | ||
37a94e2f | 788 | (defvar charset-script-alist |
8a020f4c | 789 | '((ascii . latin) |
37a94e2f KH |
790 | (latin-iso8859-1 . latin) |
791 | (latin-iso8859-2 . latin) | |
792 | (latin-iso8859-3 . latin) | |
793 | (latin-iso8859-4 . latin) | |
794 | (latin-iso8859-9 . latin) | |
795 | (latin-iso8859-10 . latin) | |
796 | (latin-iso8859-13 . latin) | |
797 | (latin-iso8859-14 . latin) | |
798 | (latin-iso8859-15 . latin) | |
799 | (latin-iso8859-16 . latin) | |
800 | (latin-jisx0201 . latin) | |
801 | (thai-tis620 . thai) | |
802 | (cyrillic-iso8859-5 . cyrillic) | |
803 | (arabic-iso8859-6 . arabic) | |
804 | (greek-iso8859-7 . latin) | |
805 | (hebrew-iso8859-8 . latin) | |
8a020f4c | 806 | (katakana-jisx0201 . kana) |
37a94e2f | 807 | (chinese-gb2312 . han) |
28f2f887 | 808 | (chinese-gbk . han) |
c7606603 KH |
809 | (gb18030-2-byte . han) |
810 | (gb18030-4-byte-bmp . han) | |
811 | (gb18030-4-byte-ext-1 . han) | |
812 | (gb18030-4-byte-ext-2 . han) | |
813 | (gb18030-4-byte-smp . han) | |
37a94e2f KH |
814 | (chinese-big5-1 . han) |
815 | (chinese-big5-2 . han) | |
816 | (chinese-cns11643-1 . han) | |
817 | (chinese-cns11643-2 . han) | |
818 | (chinese-cns11643-3 . han) | |
819 | (chinese-cns11643-4 . han) | |
820 | (chinese-cns11643-5 . han) | |
821 | (chinese-cns11643-6 . han) | |
822 | (chinese-cns11643-7 . han) | |
823 | (japanese-jisx0208 . han) | |
824 | (japanese-jisx0208-1978 . han) | |
825 | (japanese-jisx0212 . han) | |
826 | (japanese-jisx0213-1 . han) | |
827 | (japanese-jisx0213-2 . han) | |
8a020f4c | 828 | (korean-ksc5601 . hangul) |
37a94e2f KH |
829 | (chinese-sisheng . bopomofo) |
830 | (vietnamese-viscii-lower . latin) | |
831 | (vietnamese-viscii-upper . latin) | |
832 | (arabic-digit . arabic) | |
833 | (arabic-1-column . arabic) | |
834 | (arabic-2-column . arabic) | |
835 | (indian-is13194 . devanagari) | |
836 | (indian-glyph . devanagari) | |
837 | (indian-1-column . devanagari) | |
838 | (indian-2-column . devanagari) | |
839 | (tibetan-1-column . tibetan)) | |
840 | "Alist of charsets vs the corresponding most appropriate scripts. | |
841 | ||
842 | This alist is used by the function `create-fontset-from-fontset-spec' | |
843 | to map charsets to scripts.") | |
c963bbc2 | 844 | |
6fb8f8bd | 845 | (defun create-fontset-from-fontset-spec (fontset-spec |
bb98ead9 | 846 | &optional style-variant noerror) |
4ed46869 KH |
847 | "Create a fontset from fontset specification string FONTSET-SPEC. |
848 | FONTSET-SPEC is a string of the format: | |
a0451a71 | 849 | FONTSET-NAME,SCRIPT0:FONT0,SCRIPT1:FONT1, ... |
494ec9bc | 850 | Any number of SPACE, TAB, and NEWLINE can be put before and after commas. |
bb98ead9 | 851 | |
92438d6e KH |
852 | When a frame uses the fontset as the `font' parameter, the frame's |
853 | default font name is derived from FONTSET-NAME by substituting | |
854 | \"iso8859-1\" for the tail part \"fontset-XXX\". But, if SCRIPT-NAMEn | |
855 | is \"ascii\", use the corresponding FONT-NAMEn as the default font | |
856 | name. | |
bb98ead9 | 857 | |
a0451a71 MB |
858 | Optional 2nd and 3rd arguments exist just for backward compatibility, |
859 | and are ignored. | |
1f50fef9 | 860 | |
37a94e2f KH |
861 | It returns a name of the created fontset. |
862 | ||
863 | For backward compatibility, SCRIPT-NAME may be a charset name, in | |
864 | which case, the corresponding script is decided by the variable | |
865 | `charset-script-alist' (which see)." | |
92438d6e | 866 | (or (string-match "^[^,]+" fontset-spec) |
494ec9bc KH |
867 | (error "Invalid fontset spec: %s" fontset-spec)) |
868 | (let ((idx (match-end 0)) | |
869 | (name (match-string 0 fontset-spec)) | |
6ce70459 KH |
870 | default-spec target script fontlist) |
871 | (or (string-match xlfd-tight-regexp name) | |
92438d6e | 872 | (error "Fontset name \"%s\" not conforming to XLFD" name)) |
6ce70459 | 873 | (setq default-spec (font-spec :name name)) |
92438d6e | 874 | ;; At first, extract pairs of charset and fontname from FONTSET-SPEC. |
31f5d05a KH |
875 | (while (string-match "[, \t\n]*\\([^:]+\\):[ \t]*\\([^,]+\\)" |
876 | fontset-spec idx) | |
92438d6e | 877 | (setq idx (match-end 0)) |
09fd851a KH |
878 | (setq target (intern (match-string 1 fontset-spec))) |
879 | (cond ((or (eq target 'ascii) | |
4b89b5e2 KH |
880 | (memq target (char-table-extra-slot char-script-table 0))) |
881 | (push (list target (match-string 2 fontset-spec)) fontlist)) | |
882 | ((setq script (cdr (assq target charset-script-alist))) | |
09fd851a KH |
883 | (push (list script (match-string 2 fontset-spec)) fontlist)) |
884 | ((charsetp target) | |
885 | (push (list target (match-string 2 fontset-spec)) fontlist)))) | |
92438d6e KH |
886 | |
887 | ;; Complement FONTLIST. | |
6ce70459 | 888 | (setq fontlist (x-complement-fontset-spec default-spec fontlist)) |
92438d6e KH |
889 | |
890 | ;; Create a fontset. | |
09fd851a | 891 | (new-fontset name (nreverse fontlist)))) |
1f50fef9 KH |
892 | |
893 | (defun create-fontset-from-ascii-font (font &optional resolved-font | |
894 | fontset-name) | |
895 | "Create a fontset from an ASCII font FONT. | |
896 | ||
33fac697 JB |
897 | Optional 2nd arg RESOLVED-FONT is a resolved name of FONT. |
898 | If omitted, `x-resolve-font-name' is called to get the resolved name. | |
899 | At this time, if FONT is not available, an error is signaled. | |
1f50fef9 | 900 | |
33fac697 | 901 | Optional 3rd arg FONTSET-NAME is a string to be used in |
1f50fef9 KH |
902 | `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted, |
903 | an appropriate name is generated automatically. | |
904 | ||
1f50fef9 | 905 | It returns a name of the created fontset." |
6eca8d93 | 906 | (setq font (downcase font)) |
37a94e2f KH |
907 | (setq resolved-font |
908 | (downcase (or resolved-font (x-resolve-font-name font)))) | |
06f76f0d KH |
909 | (let ((xlfd (x-decompose-font-name resolved-font)) |
910 | fontset) | |
6eca8d93 KH |
911 | (if fontset-name |
912 | (setq fontset-name (downcase fontset-name)) | |
87997c2c KH |
913 | (if (query-fontset "fontset-startup") |
914 | (setq fontset-name | |
915 | (subst-char-in-string | |
916 | ?- ?_ (aref xlfd xlfd-regexp-registry-subnum) t)) | |
917 | (setq fontset-name "startup"))) | |
06f76f0d KH |
918 | (aset xlfd xlfd-regexp-registry-subnum |
919 | (format "fontset-%s" fontset-name)) | |
1f50fef9 KH |
920 | (setq fontset (x-compose-font-name xlfd)) |
921 | (or (query-fontset fontset) | |
6eca8d93 KH |
922 | (create-fontset-from-fontset-spec (concat fontset ", ascii:" font))))) |
923 | ||
4ed46869 | 924 | \f |
acfb10b8 | 925 | ;; Create standard fontset from 16 dots fonts which are the most widely |
80d4ea92 KH |
926 | ;; installed fonts. Fonts for Chinese-GB, Korean, and Chinese-CNS are |
927 | ;; specified here because FAMILY of those fonts are not "fixed" in | |
928 | ;; many cases. | |
acfb10b8 | 929 | (defvar standard-fontset-spec |
06f76f0d | 930 | (purecopy "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard") |
acfb10b8 KH |
931 | "String of fontset spec of the standard fontset. |
932 | You have the biggest chance to display international characters | |
933 | with correct glyphs by using the standard fontset. | |
4ed46869 KH |
934 | See the documentation of `create-fontset-from-fontset-spec' for the format.") |
935 | ||
37a94e2f | 936 | |
4ed46869 KH |
937 | ;; Create fontsets from X resources of the name `fontset-N (class |
938 | ;; Fontset-N)' where N is integer 0, 1, ... | |
939 | ;; The values of the resources the string of the same format as | |
acfb10b8 | 940 | ;; `standard-fontset-spec'. |
4ed46869 KH |
941 | |
942 | (defun create-fontset-from-x-resource () | |
943 | (let ((idx 0) | |
944 | fontset-spec) | |
cdd675ad DL |
945 | (while (setq fontset-spec (x-get-resource (format "fontset-%d" idx) |
946 | (format "Fontset-%d" idx))) | |
1c9992b7 KH |
947 | (condition-case nil |
948 | (create-fontset-from-fontset-spec fontset-spec t 'noerror) | |
949 | (error (message "Fontset-%d: invalid specification in X resource" idx))) | |
4ed46869 KH |
950 | (setq idx (1+ idx))))) |
951 | ||
4ed46869 KH |
952 | ;; |
953 | (provide 'fontset) | |
954 | ||
cbee283d | 955 | ;; arch-tag: bb53e629-0234-403c-950e-551e61554849 |
4ed46869 | 956 | ;;; fontset.el ends here |