(setup-default-fontset): Add a spec of non-OTF unicode font for Thai.
[emacs.git] / lisp / international / fontset.el
blob423dfa5d3646c225b5a1b18b82246d79ebee31c0
1 ;;; fontset.el --- commands for handling fontset
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6 ;; 2005, 2006, 2007, 2008, 2009
7 ;; National Institute of Advanced Industrial Science and Technology (AIST)
8 ;; Registration Number H14PRO021
9 ;; Copyright (C) 2003, 2006
10 ;; National Institute of Advanced Industrial Science and Technology (AIST)
11 ;; Registration Number H13PRO009
13 ;; Keywords: mule, i18n, fontset
15 ;; This file is part of GNU Emacs.
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
19 ;; the Free Software Foundation, either version 3 of the License, or
20 ;; (at your option) any later version.
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.
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 ;;; Commentary:
32 ;;; Code:
34 ;; Setup font-encoding-alist for all known encodings.
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)
51 ("iso8859-16$" . iso-8859-16)
52 ("ascii-0$" . ascii)
53 ("gb2312.1980" . chinese-gb2312)
54 ("gbk" . chinese-gbk)
55 ("gb18030" . (unicode . nil))
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)
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)
75 ("big5" . big5)
76 ("viscii" . viscii)
77 ("tis620" . tis620-2533)
78 ("microsoft-cp1251" . windows-1251)
79 ("koi8-r" . koi8-r)
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)
88 ("mulearabic-0" . arabic-digit)
89 ("mulearabic-1" . arabic-1-column)
90 ("mulearabic-2" . arabic-2-column)
91 ("muleipa" . ipa)
92 ("ethiopic-unicode" . (unicode-bmp . ethiopic))
93 ("is13194-devanagari" . indian-is13194)
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)
114 ("muleindian-2" . indian-2-column)
115 ("muleindian-1" . indian-1-column)
116 ("mulelao-1" . mule-lao)
117 ("muletibetan-2" . tibetan)
118 ("muletibetan-0" . tibetan)
119 ("muletibetan-1" . tibetan-1-column)))
121 (defvar font-encoding-charset-alist)
123 (setq font-encoding-charset-alist
124 '((latin-iso8859-1 . iso-8859-1)
125 (latin-iso8859-2 . iso-8859-2)
126 (latin-iso8859-3 . iso-8859-3)
127 (latin-iso8859-4 . iso-8859-4)
128 (latin-iso8859-9 . iso-8859-9)
129 (latin-iso8859-10 . iso-8859-10)
130 (latin-iso8859-13 . iso-8859-13)
131 (latin-iso8859-14 . iso-8859-14)
132 (latin-iso8859-15 . iso-8859-15)
133 (latin-iso8859-16 . iso-8859-16)
134 (cyrillic-iso8859-5 . iso-8859-5)
135 (greek-iso8859-7 . iso-8859-7)
136 (arabic-iso8859-6 . iso-8859-6)
137 (thai-tis620 . tis620-2533)
138 (latin-jisx0201 . jisx0201)
139 (katakana-jisx0201 . jisx0201)
140 (chinese-big5-1 . big5)
141 (chinese-big5-2 . big5)
142 (vietnamese-viscii-lower . viscii)
143 (vietnamese-viscii-upper . viscii)
144 (tibetan . unicode-bmp)))
146 (setq script-representative-chars
147 '((latin ?A ?Z ?a ?z #x00C0 #x0100 #x0180 #x1e00)
148 (phonetic #x250 #x283)
149 (greek #x3A9)
150 (coptic #x3E2)
151 (cyrillic #x42F)
152 (armenian #x531)
153 (hebrew #x5D0)
154 (arabic #x628)
155 (syriac #x710)
156 (thaana #x78C)
157 (devanagari #x915)
158 (bengali #x995)
159 (gurmukhi #xA15)
160 (gujarati #xA95)
161 (oriya #xB15)
162 (tamil #xB95)
163 (telugu #xC15)
164 (kannada #xC95)
165 (malayalam #xD15)
166 (sinhala #xD95)
167 (thai #xE17)
168 (lao #xEA5)
169 (tibetan #xF40)
170 (myanmar #x1000)
171 (georgian #x10D3)
172 (ethiopic #x1208)
173 (cherokee #x13B6)
174 (canadian-aboriginal #x14C0)
175 (ogham #x168F)
176 (runic #x16A0)
177 (khmer #x1780)
178 (mongolian #x1826)
179 (symbol . [#x201C #x2200 #x2500])
180 (braille #x2800)
181 (ideographic-description #x2FF0)
182 (cjk-misc #x300E)
183 (kana #x304B)
184 (bopomofo #x3105)
185 (kanbun #x319D)
186 (han #x5B57)
187 (yi #xA288)
188 (cham #xAA00)
189 (tai-viet #xAA80)
190 (hangul #xAC00)
191 (linear-b #x10000)
192 (aegean-number #x10100)
193 (ancient-greek-number #x10140)
194 (ancient-symbol #x10190)
195 (phaistos-disc #x101D0)
196 (lycian #x10280)
197 (carian #x102A0)
198 (olt-italic #x10300)
199 (ugaritic #x10380)
200 (old-persian #x103A0)
201 (deseret #x10400)
202 (shavian #x10450)
203 (osmanya #x10480)
204 (cypriot-syllabary #x10800)
205 (phoenician #x10900)
206 (lydian #x10920)
207 (kharoshthi #x10A00)
208 (cuneiform #x12000)
209 (cuneiform-numbers-and-punctuation #x12400)
210 (byzantine-musical-symbol #x1D000)
211 (musical-symbol #x1D100)
212 (ancient-greek-musical-notation #x1D200)
213 (tai-xuan-jing-symbol #x1D300)
214 (counting-rod-numeral #x1D360)
215 (mahjong-tile #x1F000)
216 (domino-tile #x1F030)))
218 (defvar otf-script-alist)
220 (setq otf-script-alist
221 '((arab . arabic)
222 (armn . armenian)
223 (bali . balinese)
224 (beng . bengali)
225 (bopo . bopomofo)
226 (brai . braille)
227 (bugi . buginese)
228 (buhd . buhid)
229 (byzm . byzantine-musical-symbol)
230 (cans . canadian-aboriginal)
231 (cher . cherokee)
232 (copt . coptic)
233 (xsux . cuneiform)
234 (cyrl . cyrillic)
235 (cprt . cypriot)
236 (dsrt . deseret)
237 (deva . devanagari)
238 (ethi . ethiopic)
239 (geor . georgian)
240 (glag . glagolitic)
241 (goth . gothic)
242 (grek . greek)
243 (gujr . gujarati)
244 (guru . gurmukhi)
245 (hani . han)
246 (hang . hangul)
247 (hano . hanunoo)
248 (hebr . hebrew)
249 (kana . kana)
250 (knda . kannada)
251 (khar . kharoshthi)
252 (khmr . khmer)
253 (lao\ . lao)
254 (latn . latin)
255 (limb . limbu)
256 (linb . linear_b)
257 (mlym . malayalam)
258 (math . mathematical)
259 (mong . mongolian)
260 (musc . musical-symbol)
261 (mymr . myanmar)
262 (nko\ . nko)
263 (ogam . ogham)
264 (ital . old_italic)
265 (xpeo . old_persian)
266 (orya . oriya)
267 (osma . osmanya)
268 (phag . phags-pa)
269 (phnx . phoenician)
270 (runr . runic)
271 (shaw . shavian)
272 (sinh . sinhala)
273 (sylo . syloti_nagri)
274 (syrc . syriac)
275 (tglg . tagalog)
276 (tagb . tagbanwa)
277 (taml . tamil)
278 (tale . tai_le)
279 (telu . telugu)
280 (thaa . thaana)
281 (thai . thai)
282 (tibt . tibetan)
283 (tfng . tifinagh)
284 (ugar . ugaritic)
285 (yi\ \ . yi)))
287 ;; Set standard fontname specification of characters in the default
288 ;; fontset to find an appropriate font for each script/charset. The
289 ;; specification has the form ((SCRIPT FONT-SPEC ...) ...), where
290 ;; FONT-SPEC is:
291 ;; a cons (FAMILY . REGISTRY),
292 ;; or a string FONT-NAME,
293 ;; or an object created by `font-spec'.
295 ;; FAMILY may be nil, in which case, the the corresponding name of
296 ;; default face is used. If REGISTRY contains a character `-', the
297 ;; string before that is embedded in `CHARSET_REGISTRY' field, and the
298 ;; string after that is embedded in `CHARSET_ENCODING' field. If it
299 ;; does not contain `-', the whole string is embedded in
300 ;; `CHARSET_REGISTRY' field, and a wild card character `*' is embedded
301 ;; in `CHARSET_ENCODING' field.
303 ;; SCRIPT is a symbol that appears as an element of the char table
304 ;; `char-script-table'. SCRIPT may be a charset specifying the range
305 ;; of characters.
307 (declare-function new-fontset "fontset.c" (name fontlist))
308 (declare-function set-fontset-font "fontset.c"
309 (name target font-spec &optional frame add))
311 (defun setup-default-fontset ()
312 "Setup the default fontset."
313 (new-fontset
314 "fontset-default"
315 `(;; for each script
316 (latin (nil . "ISO8859-1")
317 (nil . "ISO8859-2")
318 (nil . "ISO8859-3")
319 (nil . "ISO8859-4")
320 (nil . "ISO8859-9")
321 (nil . "ISO8859-10")
322 (nil . "ISO8859-13")
323 (nil . "ISO8859-14")
324 (nil . "ISO8859-15")
325 (nil . "ISO8859-16")
326 (nil . "VISCII1.1-1")
327 ,(font-spec :registry "iso10646-1" :script 'latin))
329 (thai ,(font-spec :registry "iso10646-1" :otf '(thai nil nil (mark))
330 ,(font-spec :registry "iso10646-1" :script 'thai))
331 (nil . "TIS620*")
332 (nil . "ISO8859-11"))
334 (devanagari ,(font-spec :registry "iso10646-1" :otf '(deva nil (rphf)))
335 (nil . "iso10646.indian-1"))
336 (bengali ,(font-spec :registry "iso10646-1" :otf '(beng nil (rphf))))
337 (gurmukhi ,(font-spec :registry "iso10646-1" :otf '(guru nil (blwf))))
338 (gujarati ,(font-spec :registry "iso10646-1" :otf '(gujr nil (rphf))))
339 (oriya ,(font-spec :registry "iso10646-1" :otf '(orya nil (rphf))))
340 (tamil ,(font-spec :registry "iso10646-1" :otf '(taml nil (akhn))))
341 (telugu ,(font-spec :registry "iso10646-1" :otf '(telu nil (blwf))))
342 (kannada ,(font-spec :registry "iso10646-1" :otf '(knda nil (rphf))))
343 (sinhala ,(font-spec :registry "iso10646-1" :otf '(sinh nil (akhn))))
344 (malayalam ,(font-spec :registry "iso10646-1" :otf '(mlym nil (akhn))))
346 (lao ,(font-spec :registry "iso10646-1" :otf '(lao\ nil nil (mark)))
347 ,(font-spec :registry "iso10646-1" :script 'lao)
348 (nil . "MuleLao-1"))
350 (tai-viet ("TaiViet" . "iso10646-1"))
352 ;; both for script and charset.
353 (tibetan ,(font-spec :registry "iso10646-1"
354 :otf '(tibt nil (ccmp blws abvs)))
355 ,(font-spec :family "mtib" :registry "iso10646-1")
356 (nil . "muletibetan-2"))
358 ;; both for script and charset.
359 (ethiopic ,(font-spec :registry "iso10646-1" :script 'ethiopic)
360 (nil . "ethiopic-unicode"))
362 (greek ,(font-spec :registry "iso10646-1" :script 'greek)
363 (nil . "ISO8859-7"))
365 (cyrillic ,(font-spec :registry "iso10646-1" :script 'cyrillic)
366 (nil . "ISO8859-5")
367 (nil . "microsoft-cp1251")
368 (nil . "koi8-r"))
370 (arabic ,(font-spec :registry "iso10646-1"
371 :otf '(arab nil (init medi fini liga)))
372 (nil . "MuleArabic-0")
373 (nil . "MuleArabic-1")
374 (nil . "MuleArabic-2")
375 (nil . "ISO8859-6"))
377 (hebrew ,(font-spec :registry "iso10646-1" :script 'hebrew)
378 (nil . "ISO8859-8"))
380 (khmer ,(font-spec :registry "iso10646-1" :otf '(khmr nil (pres))))
382 (kana (nil . "JISX0208*")
383 (nil . "GB2312.1980-0")
384 (nil . "KSC5601.1987*")
385 (nil . "JISX0201*")
386 (nil . "JISX0213.2000-1")
387 (nil . "JISX0213.2004-1")
388 ,(font-spec :registry "iso10646-1" :script 'kana))
390 (bopomofo ,(font-spec :registry "iso10646-1" :script 'bopomofo)
391 (nil . "sisheng_cwnn-0"))
393 (han (nil . "GB2312.1980-0")
394 (nil . "JISX0208*")
395 (nil . "JISX0212*")
396 (nil . "big5*")
397 (nil . "KSC5601.1987*")
398 (nil . "CNS11643.1992-1")
399 (nil . "CNS11643.1992-2")
400 (nil . "CNS11643.1992-3")
401 (nil . "CNS11643.1992-4")
402 (nil . "CNS11643.1992-5")
403 (nil . "CNS11643.1992-6")
404 (nil . "CNS11643.1992-7")
405 (nil . "gbk-0")
406 (nil . "gb18030")
407 (nil . "JISX0213.2000-1")
408 (nil . "JISX0213.2000-2")
409 (nil . "JISX0213.2004-1")
410 ,(font-spec :registry "iso10646-1" :lang 'ja)
411 ,(font-spec :registry "iso10646-1" :lang 'zh))
413 (cjk-misc (nil . "GB2312.1980-0")
414 (nil . "JISX0208*")
415 (nil . "JISX0212*")
416 (nil . "big5*")
417 (nil . "KSC5601.1987*")
418 (nil . "CNS11643.1992-1")
419 (nil . "CNS11643.1992-2")
420 (nil . "CNS11643.1992-3")
421 (nil . "CNS11643.1992-4")
422 (nil . "CNS11643.1992-5")
423 (nil . "CNS11643.1992-6")
424 (nil . "CNS11643.1992-7")
425 (nil . "gbk-0")
426 (nil . "gb18030")
427 (nil . "JISX0213.2000-1")
428 (nil . "JISX0213.2000-2")
429 ,(font-spec :registry "iso10646-1" :lang 'ja)
430 ,(font-spec :registry "iso10646-1" :lang 'zh))
432 (hangul (nil . "KSC5601.1987-0")
433 ,(font-spec :registry "iso10646-1" :lang 'ko))
435 ;; for each charset
436 (ascii (nil . "ISO8859-1"))
437 (arabic-digit ("*" . "MuleArabic-0"))
438 (arabic-1-column ("*" . "MuleArabic-1"))
439 (arabic-2-column ("*" . "MuleArabic-2"))
440 (indian-is13194 (nil . "is13194-devanagari"))
441 (indian-1-column ("*" . "muleindian-2"))
442 ;; Indian CDAC
443 (devanagari-cdac (nil . "Devanagari-CDAC"))
444 (sanskrit-cdac (nil . "Sanskrit-CDAC"))
445 (bengali-cdac (nil . "Bengali-CDAC"))
446 (assamese-cdac (nil . "Assamese-CDAC"))
447 (punjabi-cdac (nil . "Punjabi-CDAC"))
448 (gujarati-cdac (nil . "Gujarati-CDAC"))
449 (oriya-cdac (nil . "Oriya-CDAC"))
450 (tamil-cdac (nil . "Tamil-CDAC"))
451 (telugu-cdac (nil . "Telugu-CDAC"))
452 (kannada-cdac (nil . "Kannada-CDAC"))
453 (malayalam-cdac (nil . "Malayalam-CDAC"))
454 ;; Indian AKRUTI
455 (devanagari-akruti (nil . "Devanagari-Akruti"))
456 (bengali-akruti (nil . "Bengali-Akruti"))
457 (punjabi-akruti (nil . "Punjabi-Akruti"))
458 (gujarati-akruti (nil . "Gujarati-Akruti"))
459 (oriya-akruti (nil . "Oriya-Akruti"))
460 (tamil-akruti (nil . "Tamil-Akruti"))
461 (telugu-akruti (nil . "Telugu-Akruti"))
462 (kannada-akruti (nil . "Kannada-Akruti"))
463 (malayalam-akruti (nil . "Malayalam-Akruti"))
464 ;;(devanagari-glyph ("altsys-dv_ttsurekh" . "devanagari-cdac"))
465 ;;(malayalam-glyph ("altsys-ml_ttkarthika" . "malayalam-cdac"))
466 (ipa ,(font-spec :registry "iso10646-1" :script 'phonetic)
467 (nil . "MuleIPA-1")
468 (nil . "iso10646-1"))
470 ;; Fallback fonts
471 (nil (nil . "gb2312.1980")
472 (nil . "gbk-0")
473 (nil . "gb18030")
474 (nil . "jisx0208")
475 (nil . "ksc5601.1987")
476 (nil . "CNS11643.1992-1")
477 (nil . "CNS11643.1992-2")
478 (nil . "CNS11643.1992-3")
479 (nil . "CNS11643.1992-4")
480 (nil . "CNS11643.1992-5")
481 (nil . "CNS11643.1992-6")
482 (nil . "CNS11643.1992-7")
483 (nil . "big5")
484 (nil . "jisx0213.2000-1")
485 (nil . "jisx0213.2004-1")
486 (nil . "jisx0212"))
489 ;; For simple scripts
490 (dolist (script '(phonetic
491 armenian
492 syriac
493 thaana
494 myanmar
495 georgian
496 cherokee
497 canadian-aboriginal
498 ogham
499 runic
500 symbol
501 braille
503 aegean-number
504 ancient-greek-number
505 ancient-symbol
506 phaistos-disc
507 lycian
508 carian
509 olt-italic
510 ugaritic
511 old-persian
512 deseret
513 shavian
514 osmanya
515 cypriot-syllabary
516 phoenician
517 lydian
518 kharoshthi
519 cuneiform
520 cuneiform-numbers-and-punctuation
521 byzantine-musical-symbol
522 musical-symbol
523 ancient-greek-musical-notation
524 tai-xuan-jing-symbol
525 counting-rod-numeral
526 mahjong-tile
527 domino-tile))
528 (set-fontset-font "fontset-default"
529 script (font-spec :registry "iso10646-1" :script script)))
531 ;; Special settings for `MATHEMATICAL (U+1D400..U+1D7FF)'.
532 (dolist (math-subgroup '((#x1D400 #x1D433 mathematical-bold)
533 (#x1D434 #x1D467 mathematical-italic)
534 (#x1D468 #x1D49B mathematical-bold-italic)
535 (#x1D49C #x1D4CF mathematical-script)
536 (#x1D4D0 #x1D503 mathematical-bold-script)
537 (#x1D504 #x1D537 mathematical-fraktur)
538 (#x1D538 #x1D56B mathematical-double-struck)
539 (#x1D56C #x1D59F mathematical-bold-fraktur)
540 (#x1D5A0 #x1D5D3 mathematical-sans-serif)
541 (#x1D5D4 #x1D607 mathematical-sans-serif-bold)
542 (#x1D608 #x1D63B mathematical-sans-serif-italic)
543 (#x1D63C #x1D66F mathematical-sans-serif-bold-italic)
544 (#x1D670 #x1D6A3 mathematical-monospace)
545 (#x1D6A4 #x1D6A5 mathematical-italic)
546 (#x1D6A8 #x1D6E1 mathematical-bold)
547 (#x1D6E2 #x1D71B mathematical-italic)
548 (#x1D71C #x1D755 mathematical-bold-italic)
549 (#x1D756 #x1D78F mathematical-sans-serif-bold)
550 (#x1D790 #x1D7C9 mathematical-sans-serif-bold-italic)
551 (#x1D7CA #x1D7D7 mathematical-bold)
552 (#x1D7D8 #x1D7E1 mathematical-double-struck)
553 (#x1D7E2 #x1D7EB mathematical-sans-serif)
554 (#x1D7EC #x1D7F5 mathematical-sans-serif-bold)
555 (#x1D7F6 #x1D7FF mathematical-monospace)))
556 (let ((slot (assq (nth 2 math-subgroup) script-representative-chars)))
557 (if slot
558 (if (vectorp (cdr slot))
559 (setcdr slot (vconcat (cdr slot) (vector (car math-subgroup))))
560 (setcdr slot (vector (cadr slot) (car math-subgroup))))
561 (setq slot (list (nth 2 math-subgroup) (car math-subgroup)))
562 (nconc script-representative-chars (list slot))))
563 (set-fontset-font
564 "fontset-default"
565 (cons (car math-subgroup) (nth 1 math-subgroup))
566 (font-spec :registry "iso10646-1" :script (nth 2 math-subgroup))))
568 ;; Append Unicode fonts.
569 ;; This may find fonts with more variants (bold, italic) but which
570 ;; don't cover many characters.
571 (set-fontset-font "fontset-default" nil
572 '(nil . "iso10646-1") nil 'prepend)
573 ;; These may find fonts that cover many characters but with fewer
574 ;; variants.
575 (set-fontset-font "fontset-default" nil
576 '("gnu-unifont" . "iso10646-1") nil 'prepend)
577 (set-fontset-font "fontset-default" nil
578 '("mutt-clearlyu" . "iso10646-1") nil 'prepend)
579 (set-fontset-font "fontset-default" '(#x20000 . #x2FFFF)
580 '(nil . "unicode-sip"))
582 (set-fontset-font "fontset-default" '(#xE000 . #xF8FF)
583 '(nil . "iso10646-1"))
584 ;; Don't try the fallback fonts even if no suitable font was found
585 ;; by the above font-spec.
586 (set-fontset-font "fontset-default" '(#xE000 . #xF8FF) nil nil 'append))
588 (defun create-default-fontset ()
589 "Create the default fontset.
590 Internal use only. Should be called at startup time."
591 (condition-case err
592 (setup-default-fontset)
593 (error (display-warning
594 'initialization
595 (format "Creation of the default fontsets failed: %s" err)
596 :error))))
598 ;; These are the registered registries/encodings from
599 ;; ftp://ftp.x.org/pub/DOCS/registry 2001/06/01
601 ;; Name Reference
602 ;; ---- ---------
603 ;; "DEC" [27]
604 ;; registry prefix
605 ;; "DEC.CNS11643.1986-2" [53]
606 ;; CNS11643 2-plane using the encoding
607 ;; suggested in that standard
608 ;; "DEC.DTSCS.1990-2" [54]
609 ;; DEC Taiwan Supplemental Character Set
610 ;; "fujitsu.u90x01.1991-0" [87]
611 ;; "fujitsu.u90x03.1991-0" [87]
612 ;; "GB2312.1980-0" [39],[12]
613 ;; China (PRC) Hanzi, GL encoding
614 ;; "GB2312.1980-1" [39]
615 ;; (deprecated)
616 ;; China (PRC) Hanzi, GR encoding
617 ;; "HP-Arabic8" [36]
618 ;; HPARABIC8 8-bit character set
619 ;; "HP-East8" [36]
620 ;; HPEAST8 8-bit character set
621 ;; "HP-Greek8" [36]
622 ;; HPGREEK8 8-bit character set
623 ;; "HP-Hebrew8" [36]
624 ;; HPHEBREW8 8-bit character set
625 ;; "HP-Japanese15" [36]
626 ;; HPJAPAN15 15-bit characer set,
627 ;; modified from industry defacto
628 ;; standard Shift-JIS
629 ;; "HP-Kana8" [36]
630 ;; HPKANA8 8-bit character set
631 ;; "HP-Korean15" [36]
632 ;; HPKOREAN15 15-bit character set
633 ;; "HP-Roman8" [36]
634 ;; HPROMAN8 8-bit character set
635 ;; "HP-SChinese15" [36]
636 ;; HPSCHINA15 15-bit character set for
637 ;; support of Simplified Chinese
638 ;; "HP-TChinese15" [36]
639 ;; HPTCHINA15 15-bit character set for
640 ;; support of Traditional Chinese
641 ;; "HP-Turkish8" [36]
642 ;; HPTURKISH8 8-bit character set
643 ;; "IPSYS" [59]
644 ;; registry prefix
645 ;; "IPSYS.IE-1" [59]
646 ;; "ISO2022"<REG>"-"<ENC> [44]
647 ;; "ISO646.1991-IRV" [107]
648 ;; ISO 646 International Reference Version
649 ;; "ISO8859-1" [15],[12]
650 ;; ISO Latin alphabet No. 1
651 ;; "ISO8859-2" [15],[12]
652 ;; ISO Latin alphabet No. 2
653 ;; "ISO8859-3" [15],[12]
654 ;; ISO Latin alphabet No. 3
655 ;; "ISO8859-4" [15],[12]
656 ;; ISO Latin alphabet No. 4
657 ;; "ISO8859-5" [15],[12]
658 ;; ISO Latin/Cyrillic alphabet
659 ;; "ISO8859-6" [15],[12]
660 ;; ISO Latin/Arabic alphabet
661 ;; "ISO8859-7" [15],[12]
662 ;; ISO Latin/Greek alphabet
663 ;; "ISO8859-8" [15],[12]
664 ;; ISO Latin/Hebrew alphabet
665 ;; "ISO8859-9" [15],[12]
666 ;; ISO Latin alphabet No. 5
667 ;; "ISO8859-10" [15],[12]
668 ;; ISO Latin alphabet No. 6
669 ;; "ISO8859-13" [15],[12]
670 ;; ISO Latin alphabet No. 7
671 ;; "ISO8859-14" [15],[12]
672 ;; ISO Latin alphabet No. 8
673 ;; "ISO8859-15" [15],[12]
674 ;; ISO Latin alphabet No. 9
675 ;; "FCD8859-15" [7]
676 ;; (deprecated)
677 ;; ISO Latin alphabet No. 9, Final Committee Draft
678 ;; "ISO10646-1" [133]
679 ;; Unicode Universal Multiple-Octet Coded Character Set
680 ;; "ISO10646-MES" [133]
681 ;; (deprecated)
682 ;; Unicode Minimum European Subset
683 ;; "JISX0201.1976-0" [38],[12]
684 ;; 8-Bit Alphanumeric-Katakana Code
685 ;; "JISX0208.1983-0" [40],[12]
686 ;; Japanese Graphic Character Set,
687 ;; GL encoding
688 ;; "JISX0208.1990-0" [71]
689 ;; Japanese Graphic Character Set,
690 ;; GL encoding
691 ;; "JISX0208.1983-1" [40]
692 ;; (deprecated)
693 ;; Japanese Graphic Character Set,
694 ;; GR encoding
695 ;; "JISX0212.1990-0" [72]
696 ;; Supplementary Japanese Graphic Character Set,
697 ;; GL encoding
698 ;; "KOI8-R" [119]
699 ;; Cyrillic alphabet
700 ;; "KSC5601.1987-0" [41],[12]
701 ;; Korean Graphic Character Set,
702 ;; GL encoding
703 ;; "KSC5601.1987-1" [41]
704 ;; (deprecated)
705 ;; Korean Graphic Character Set,
706 ;; GR encoding
707 ;; "omron_CNS11643-0" [45]
708 ;; "omron_CNS11643-1" [45]
709 ;; "omron_BIG5-0" [45]
710 ;; "omron_BIG5-1" [45]
711 ;; "wn.tamil.1993" [103]
713 (defun set-font-encoding (pattern charset)
714 "Set arguments in `font-encoding-alist' (which see)."
715 (let ((slot (assoc pattern font-encoding-alist)))
716 (if slot
717 (setcdr slot charset)
718 (setq font-encoding-alist
719 (cons (cons pattern charset) font-encoding-alist)))))
721 (defvar x-pixel-size-width-font-regexp)
722 (defvar vertical-centering-font-regexp)
724 ;; Setting for suppressing XLoadQueryFont on big fonts.
725 (setq x-pixel-size-width-font-regexp
726 "gb2312\\|gbk\\|gb18030\\|jisx0208\\|ksc5601\\|cns11643\\|big5")
728 ;; These fonts require vertical centering.
729 (setq vertical-centering-font-regexp
730 "gb2312\\|gbk\\|gb18030\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5")
732 ;; CDAC fonts are actually smaller than their design sizes.
733 (setq face-font-rescale-alist
734 '(("-cdac$" . 1.3)))
736 (defvar x-font-name-charset-alist nil
737 "This variable has no meaning now. Just kept for backward compatibility.")
739 ;;; XLFD (X Logical Font Description) format handler.
741 ;; Define XLFD's field index numbers. ; field name
742 (defconst xlfd-regexp-family-subnum 0) ; FOUNDRY and FAMILY
743 (defconst xlfd-regexp-weight-subnum 1) ; WEIGHT_NAME
744 (defconst xlfd-regexp-slant-subnum 2) ; SLANT
745 (defconst xlfd-regexp-swidth-subnum 3) ; SETWIDTH_NAME
746 (defconst xlfd-regexp-adstyle-subnum 4) ; ADD_STYLE_NAME
747 (defconst xlfd-regexp-pixelsize-subnum 5) ; PIXEL_SIZE
748 (defconst xlfd-regexp-pointsize-subnum 6) ; POINT_SIZE
749 (defconst xlfd-regexp-resx-subnum 7) ; RESOLUTION_X
750 (defconst xlfd-regexp-resy-subnum 8) ; RESOLUTION_Y
751 (defconst xlfd-regexp-spacing-subnum 8) ; SPACING
752 (defconst xlfd-regexp-avgwidth-subnum 10) ; AVERAGE_WIDTH
753 (defconst xlfd-regexp-registry-subnum 11) ; REGISTRY and ENCODING
755 ;; Regular expression matching against a fontname which conforms to
756 ;; XLFD (X Logical Font Description). All fields in XLFD should be
757 ;; not be omitted (but can be a wild card) to be matched.
758 (defconst xlfd-tight-regexp
760 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
761 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
762 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*-[^-]*\\)$")
764 ;; Regular expression matching against a fontname which conforms to
765 ;; XLFD (X Logical Font Description). All fields in XLFD from FOUNDRY
766 ;; to ADSTYLE, REGISTRY, and ENCODING should be not be omitted (but
767 ;; can be a wild card) to be matched.
768 (defconst xlfd-style-regexp
770 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-.*\
771 -\\([^-]*-[^-]*\\)$")
773 ;; List of field numbers of XLFD whose values are numeric.
774 (defconst xlfd-regexp-numeric-subnums
775 (list xlfd-regexp-pixelsize-subnum ;5
776 xlfd-regexp-pointsize-subnum ;6
777 xlfd-regexp-resx-subnum ;7
778 xlfd-regexp-resy-subnum ;8
779 xlfd-regexp-avgwidth-subnum ;10
782 (defun x-decompose-font-name (pattern)
783 "Decompose PATTERN into XLFD fields and return a vector of the fields.
784 The length of the vector is 12.
785 The FOUNDRY and FAMILY fields are concatinated and stored in the first
786 element of the vector.
787 The REGISTRY and ENCODING fields are concatinated and stored in the last
788 element of the vector.
790 Return nil if PATTERN doesn't conform to XLFD."
791 (if (string-match xlfd-tight-regexp pattern)
792 (let ((xlfd-fields (make-vector 12 nil)))
793 (dotimes (i 12)
794 (aset xlfd-fields i (match-string (1+ i) pattern)))
795 (dotimes (i 12)
796 (if (string-match "^[*-]+$" (aref xlfd-fields i))
797 (aset xlfd-fields i nil)))
798 xlfd-fields)))
800 (defun x-compose-font-name (fields &optional reduce)
801 "Compose X fontname from FIELDS.
802 FIELDS is a vector of XLFD fields, of length 12.
803 If a field is nil, wild-card letter `*' is embedded.
804 Optional argument REDUCE exists just for backward compatibility,
805 and is always ignored."
806 (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-")))
809 (defun x-must-resolve-font-name (xlfd-fields)
810 "Like `x-resolve-font-name', but always return a font name.
811 XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
812 If no font matching XLFD-FIELDS is available, successively replace
813 parts of the font name pattern with \"*\" until some font is found.
814 Value is name of that font."
815 (let ((ascii-font nil) (index 0))
816 (while (and (null ascii-font) (<= index xlfd-regexp-registry-subnum))
817 (let ((pattern (x-compose-font-name xlfd-fields)))
818 (condition-case nil
819 (setq ascii-font (x-resolve-font-name pattern))
820 (error
821 (message "Warning: no fonts matching `%s' available" pattern)
822 (aset xlfd-fields index "*")
823 (setq index (1+ index))))))
824 (unless ascii-font
825 (error "No fonts found"))
826 ascii-font))
829 (defun x-complement-fontset-spec (default-spec fontlist)
830 "Complement elements of FONTLIST based on DEFAULT-SPEC.
831 DEFAULT-SPEC is a font-spec object providing default font properties.
832 FONTLIST is an alist of script names vs the corresponding font names.
834 The font names are parsed and unspecified font properties are
835 given from DEFAULT-SPEC."
836 (let ((prop-list '(:foundry :family :weight :slant :width :adstyle :size)))
837 (dolist (elt fontlist)
838 (let ((spec (font-spec :name (cadr elt))))
839 (dolist (prop prop-list)
840 (let ((val (font-get spec prop)))
841 (or val
842 (font-put spec prop (font-get default-spec prop)))))
843 (setcar (cdr elt) spec)))
844 fontlist))
846 (defun fontset-name-p (fontset)
847 "Return non-nil if FONTSET is valid as fontset name.
848 A valid fontset name should conform to XLFD (X Logical Font Description)
849 with \"fontset\" in `<CHARSET_REGISTRY>' field."
850 (and (string-match xlfd-tight-regexp fontset)
851 (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset)
852 "fontset")))
854 (declare-function fontset-list "fontset.c" ())
856 (defun generate-fontset-menu ()
857 "Return list to be appended to `x-fixed-font-alist'.
858 Done when `mouse-set-font' is called."
859 (let (l)
860 (dolist (fontset (fontset-list))
861 (or (string-match "fontset-default$" fontset)
862 (string-match "fontset-auto[0-9]+$" fontset)
863 (push (list (fontset-plain-name fontset) fontset) l)))
864 (cons "Fontset"
865 (sort l #'(lambda (x y) (string< (car x) (car y)))))))
867 (declare-function query-fontset "fontset.c" (pattern &optional regexpp))
869 (defun fontset-plain-name (fontset)
870 "Return a plain and descriptive name of FONTSET."
871 (if (not (setq fontset (query-fontset fontset)))
872 (error "Invalid fontset: %s" fontset))
873 (let ((xlfd-fields (x-decompose-font-name fontset)))
874 (if xlfd-fields
875 (let ((family (aref xlfd-fields xlfd-regexp-family-subnum))
876 (weight (aref xlfd-fields xlfd-regexp-weight-subnum))
877 (slant (aref xlfd-fields xlfd-regexp-slant-subnum))
878 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum))
879 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum))
880 (nickname (aref xlfd-fields xlfd-regexp-registry-subnum))
881 name)
882 (if (not (string-match "^fontset-\\(.*\\)$" nickname))
883 (setq nickname family)
884 (setq nickname (match-string 1 nickname)))
885 (if (and size (> (string-to-number size) 0))
886 (setq name (format "%s: %s-dot" nickname size))
887 (setq name nickname))
888 (and weight
889 (cond ((string-match "^medium$" weight)
890 (setq name (concat name " " "medium")))
891 ((string-match "^bold$\\|^demibold$" weight)
892 (setq name (concat name " " weight)))))
893 (and slant
894 (cond ((string-match "^i$" slant)
895 (setq name (concat name " " "italic")))
896 ((string-match "^o$" slant)
897 (setq name (concat name " " "slant")))
898 ((string-match "^ri$" slant)
899 (setq name (concat name " " "reverse italic")))
900 ((string-match "^ro$" slant)
901 (setq name (concat name " " "reverse slant")))))
902 name)
903 fontset)))
905 (defvar charset-script-alist
906 '((ascii . latin)
907 (latin-iso8859-1 . latin)
908 (latin-iso8859-2 . latin)
909 (latin-iso8859-3 . latin)
910 (latin-iso8859-4 . latin)
911 (latin-iso8859-9 . latin)
912 (latin-iso8859-10 . latin)
913 (latin-iso8859-13 . latin)
914 (latin-iso8859-14 . latin)
915 (latin-iso8859-15 . latin)
916 (latin-iso8859-16 . latin)
917 (latin-jisx0201 . latin)
918 (thai-tis620 . thai)
919 (cyrillic-iso8859-5 . cyrillic)
920 (arabic-iso8859-6 . arabic)
921 (greek-iso8859-7 . latin)
922 (hebrew-iso8859-8 . latin)
923 (katakana-jisx0201 . kana)
924 (chinese-gb2312 . han)
925 (chinese-gbk . han)
926 (gb18030-2-byte . han)
927 (gb18030-4-byte-bmp . han)
928 (gb18030-4-byte-ext-1 . han)
929 (gb18030-4-byte-ext-2 . han)
930 (gb18030-4-byte-smp . han)
931 (chinese-big5-1 . han)
932 (chinese-big5-2 . han)
933 (chinese-cns11643-1 . han)
934 (chinese-cns11643-2 . han)
935 (chinese-cns11643-3 . han)
936 (chinese-cns11643-4 . han)
937 (chinese-cns11643-5 . han)
938 (chinese-cns11643-6 . han)
939 (chinese-cns11643-7 . han)
940 (japanese-jisx0208 . han)
941 (japanese-jisx0208-1978 . han)
942 (japanese-jisx0212 . han)
943 (japanese-jisx0213-1 . han)
944 (japanese-jisx0213-2 . han)
945 (korean-ksc5601 . hangul)
946 (chinese-sisheng . bopomofo)
947 (vietnamese-viscii-lower . latin)
948 (vietnamese-viscii-upper . latin)
949 (arabic-digit . arabic)
950 (arabic-1-column . arabic)
951 (arabic-2-column . arabic)
952 (indian-is13194 . devanagari)
953 (indian-glyph . devanagari)
954 (indian-1-column . devanagari)
955 (indian-2-column . devanagari)
956 (tibetan-1-column . tibetan))
957 "Alist of charsets vs the corresponding most appropriate scripts.
959 This alist is used by the function `create-fontset-from-fontset-spec'
960 to map charsets to scripts.")
962 (defun create-fontset-from-fontset-spec (fontset-spec
963 &optional style-variant noerror)
964 "Create a fontset from fontset specification string FONTSET-SPEC.
965 FONTSET-SPEC is a string of the format:
966 FONTSET-NAME,SCRIPT-NAME0:FONT-NAME0,SCRIPT-NAME1:FONT-NAME1, ...
967 Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
969 When a frame uses the fontset as the `font' parameter, the frame's
970 default font name is derived from FONTSET-NAME by substituting
971 \"iso8859-1\" for the tail part \"fontset-XXX\". But, if SCRIPT-NAMEn
972 is \"ascii\", use the corresponding FONT-NAMEn as the default font
973 name.
975 Optional 2nd and 3rd arguments exist just for backward compatibility,
976 and are ignored.
978 It returns a name of the created fontset.
980 For backward compatibility, SCRIPT-NAME may be a charset name, in
981 which case, the corresponding script is decided by the variable
982 `charset-script-alist' (which see)."
983 (or (string-match "^[^,]+" fontset-spec)
984 (error "Invalid fontset spec: %s" fontset-spec))
985 (let ((idx (match-end 0))
986 (name (match-string 0 fontset-spec))
987 default-spec target script fontlist)
988 (or (string-match xlfd-tight-regexp name)
989 (error "Fontset name \"%s\" not conforming to XLFD" name))
990 (setq default-spec (font-spec :name name))
991 ;; At first, extract pairs of charset and fontname from FONTSET-SPEC.
992 (while (string-match "[, \t\n]*\\([^:]+\\):[ \t]*\\([^,]+\\)"
993 fontset-spec idx)
994 (setq idx (match-end 0))
995 (setq target (intern (match-string 1 fontset-spec)))
996 (cond ((or (eq target 'ascii)
997 (memq target (char-table-extra-slot char-script-table 0)))
998 (push (list target (match-string 2 fontset-spec)) fontlist))
999 ((setq script (cdr (assq target charset-script-alist)))
1000 (push (list script (match-string 2 fontset-spec)) fontlist))
1001 ((charsetp target)
1002 (push (list target (match-string 2 fontset-spec)) fontlist))))
1004 ;; Complement FONTLIST.
1005 (setq fontlist (x-complement-fontset-spec default-spec fontlist))
1007 ;; Create a fontset.
1008 (new-fontset name (nreverse fontlist))))
1010 (defun create-fontset-from-ascii-font (font &optional resolved-font
1011 fontset-name)
1012 "Create a fontset from an ASCII font FONT.
1014 Optional 2nd arg RESOLVED-FONT is a resolved name of FONT.
1015 If omitted, `x-resolve-font-name' is called to get the resolved name.
1016 At this time, if FONT is not available, an error is signaled.
1018 Optional 3rd arg FONTSET-NAME is a string to be used in
1019 `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
1020 an appropriate name is generated automatically.
1022 It returns a name of the created fontset."
1023 (setq font (downcase font))
1024 (setq resolved-font
1025 (downcase (or resolved-font (x-resolve-font-name font))))
1026 (let ((xlfd (x-decompose-font-name resolved-font))
1027 fontset)
1028 (if fontset-name
1029 (setq fontset-name (downcase fontset-name))
1030 (if (query-fontset "fontset-startup")
1031 (setq fontset-name
1032 (subst-char-in-string
1033 ?- ?_ (aref xlfd xlfd-regexp-registry-subnum) t))
1034 (setq fontset-name "startup")))
1035 (aset xlfd xlfd-regexp-registry-subnum
1036 (format "fontset-%s" fontset-name))
1037 (setq fontset (x-compose-font-name xlfd))
1038 (or (query-fontset fontset)
1039 (create-fontset-from-fontset-spec (concat fontset ", ascii:" font)))))
1042 ;; Create standard fontset from 16 dots fonts which are the most widely
1043 ;; installed fonts. Fonts for Chinese-GB, Korean, and Chinese-CNS are
1044 ;; specified here because FAMILY of those fonts are not "fixed" in
1045 ;; many cases.
1046 (defvar standard-fontset-spec
1047 (purecopy "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard")
1048 "String of fontset spec of the standard fontset.
1049 You have the biggest chance to display international characters
1050 with correct glyphs by using the standard fontset.
1051 See the documentation of `create-fontset-from-fontset-spec' for the format.")
1054 ;; Create fontsets from X resources of the name `fontset-N (class
1055 ;; Fontset-N)' where N is integer 0, 1, ...
1056 ;; The values of the resources the string of the same format as
1057 ;; `standard-fontset-spec'.
1059 (declare-function x-get-resource "frame.c"
1060 (attribute class &optional component subclass))
1062 (defun create-fontset-from-x-resource ()
1063 (let ((idx 0)
1064 fontset-spec)
1065 (while (setq fontset-spec (x-get-resource (format "fontset-%d" idx)
1066 (format "Fontset-%d" idx)))
1067 (condition-case nil
1068 (create-fontset-from-fontset-spec fontset-spec t)
1069 (error (display-warning
1070 'initialization
1071 (format "Fontset-%d: invalid specification in X resource" idx)
1072 :warning)))
1073 (setq idx (1+ idx)))))
1076 (provide 'fontset)
1078 ;; arch-tag: bb53e629-0234-403c-950e-551e61554849
1079 ;;; fontset.el ends here