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