(cal-tex-hook, cal-tex-insert-preamble, cal-tex-month-name): Doc fix.
[emacs.git] / lisp / international / fontset.el
blob748ab0eed3661db12cf7aebd67d385fb6ae06d73
1 ;;; fontset.el --- commands for handling fontset
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6 ;; 2005, 2006, 2007, 2008
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, or (at your option)
20 ;; 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; see the file COPYING. If not, write to the
29 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
30 ;; Boston, MA 02110-1301, USA.
32 ;;; Commentary:
34 ;;; Code:
36 ;; Setup font-encoding-alist for all known encodings.
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)
53 ("iso8859-16$" . iso-8859-16)
54 ("gb2312.1980" . chinese-gb2312)
55 ("gbk" . chinese-gbk)
56 ("gb18030" . (unicode . nil))
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)
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)
76 ("big5" . big5)
77 ("viscii" . viscii)
78 ("tis620" . tis620-2533)
79 ("microsoft-cp1251" . windows-1251)
80 ("koi8-r" . koi8-r)
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)
89 ("mulearabic-0" . arabic-digit)
90 ("mulearabic-1" . arabic-1-column)
91 ("mulearabic-2" . arabic-2-column)
92 ("muleipa" . ipa)
93 ("ethiopic-unicode" . (unicode-bmp . ethiopic))
94 ("is13194-devanagari" . indian-is13194)
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)
115 ("muleindian-2" . indian-2-column)
116 ("muleindian-1" . indian-1-column)
117 ("mulelao-1" . mule-lao)
118 ("muletibetan-2" . tibetan)
119 ("muletibetan-1" . tibetan-1-column)))
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)))
144 (setq script-representative-chars
145 '((latin ?A ?Z ?a ?z)
146 (greek #x3A9)
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)
184 (cham #xAA00)
185 (tai-viet #xAA80)
186 (hangul #xAC00)))
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)
197 (byzm . byzantine-musical-symbol)
198 (cans . canadian-aboriginal)
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)
221 (lao\ . lao)
222 (latn . latin)
223 (limb . limbu)
224 (linb . linear_b)
225 (mlym . malayalam)
226 (math . mathematical)
227 (mong . mongolian)
228 (musc . musical-symbol)
229 (mymr . myanmar)
230 (nko\ . nko)
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)
253 (yi\ \ . yi)))
255 ;; Set standard fontname specification of characters in the default
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:
259 ;; a cons (FAMILY . REGISTRY),
260 ;; or a string FONT-NAME,
261 ;; or an object created by `font-spec'.
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.
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.
275 (defun setup-default-fontset ()
276 "Setup the default fontset."
277 (new-fontset
278 "fontset-default"
279 `(;; for each script
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")
289 (nil . "ISO8859-16")
290 (nil . "VISCII1.1-1")
291 (nil . "ISO10646-1"))
293 (thai ,(font-spec :registry "iso10646-1" :otf '(thai nil nil (mark)))
294 (nil . "TIS620*")
295 (nil . "ISO8859-11"))
297 (devanagari ,(font-spec :registry "iso10646-1" :otf '(deva nil (rphf)))
298 (nil . "iso10646.indian-1"))
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))))
303 (tamil ,(font-spec :registry "iso10646-1" :otf '(taml nil (akhn))))
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))))
309 (lao ,(font-spec :registry "iso10646-1" :otf '(lao\ nil nil (mark)))
310 ,(font-spec :registry "iso10646-1" :script 'lao)
311 (nil . "MuleLao-1"))
313 (tai-viet ("TaiViet" . "iso10646-1"))
315 ;; both for script and charset.
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"))
321 ;; both for script and charset.
322 (ethiopic ,(font-spec :registry "iso10646-1" :script 'ethiopic)
323 (nil . "ethiopic-unicode"))
325 (greek ,(font-spec :registry "iso10646-1" :script 'greek)
326 (nil . "ISO8859-7"))
328 (cyrillic ,(font-spec :registry "iso10646-1" :script 'cyrillic)
329 (nil . "ISO8859-5")
330 (nil . "microsoft-cp1251")
331 (nil . "koi8-r"))
333 (arabic ,(font-spec :registry "iso10646-1"
334 :otf '(arab nil (init medi fini liga)))
335 (nil . "MuleArabic-0")
336 (nil . "MuleArabic-1")
337 (nil . "MuleArabic-2")
338 (nil . "ISO8859-6"))
340 (hebrew ,(font-spec :registry "iso10646-1" :script 'hebrew)
341 (nil . "ISO8859-8"))
343 (syriac ,(font-spec :registry "iso10646-1" :script 'syriac))
345 (thaana ,(font-spec :registry "iso10646-1" :otf '(thaa nil nil)))
347 (myanmar ,(font-spec :registry "iso10646-1" :script 'myanmar))
349 (georgian ,(font-spec :registry "iso10646-1" :script 'georgian))
351 (cherokee ,(font-spec :registry "iso10646-1" :script 'cherokee))
353 (canadian-aboriginal ,(font-spec :registry "iso10646-1"
354 :script 'canadian-aboriginal))
356 (ogham ,(font-spec :registry "iso10646-1" :script 'ogham))
358 (runic ,(font-spec :registry "iso10646-1" :script 'runic))
360 (khmer ,(font-spec :registry "iso10646-1" :otf '(khmr nil (pres))))
362 (yi ,(font-spec :registry "iso10646-1" :script 'yi))
364 (kana ,(font-spec :registry "iso10646-1" :script 'kana)
365 (nil . "JISX0208*")
366 (nil . "GB2312.1980-0")
367 (nil . "KSC5601.1987*")
368 (nil . "JISX0201*")
369 (nil . "JISX0213.2000-1")
370 (nil . "JISX0213.2004-1"))
372 (bopomofo (nil . "sisheng_cwnn-0"))
374 (han ,(font-spec :registry "iso10646-1" :language 'ja)
375 ,(font-spec :registry "iso10646-1" :language 'zh)
376 (nil . "GB2312.1980-0")
377 (nil . "JISX0208*")
378 (nil . "JISX0212*")
379 (nil . "big5*")
380 (nil . "KSC5601.1987*")
381 (nil . "CNS11643.1992-1")
382 (nil . "CNS11643.1992-2")
383 (nil . "CNS11643.1992-3")
384 (nil . "CNS11643.1992-4")
385 (nil . "CNS11643.1992-5")
386 (nil . "CNS11643.1992-6")
387 (nil . "CNS11643.1992-7")
388 (nil . "gbk-0")
389 (nil . "gb18030")
390 (nil . "JISX0213.2000-1")
391 (nil . "JISX0213.2000-2")
392 (nil . "JISX0213.2004-1"))
394 (cjk-misc ,(font-spec :registry "iso10646-1" :language 'ja)
395 ,(font-spec :registry "iso10646-1" :language 'zh)
396 (nil . "GB2312.1980-0")
397 (nil . "JISX0208*")
398 (nil . "JISX0212*")
399 (nil . "big5*")
400 (nil . "KSC5601.1987*")
401 (nil . "CNS11643.1992-1")
402 (nil . "CNS11643.1992-2")
403 (nil . "CNS11643.1992-3")
404 (nil . "CNS11643.1992-4")
405 (nil . "CNS11643.1992-5")
406 (nil . "CNS11643.1992-6")
407 (nil . "CNS11643.1992-7")
408 (nil . "gbk-0")
409 (nil . "gb18030")
410 (nil . "JISX0213.2000-1")
411 (nil . "JISX0213.2000-2"))
413 (hangul ,(font-spec :registry "iso10646-1" :language 'ko)
414 (nil . "KSC5601.1987-0"))
416 ;; for each charset
417 (ascii (nil . "ISO8859-1"))
418 (arabic-digit ("*" . "MuleArabic-0"))
419 (arabic-1-column ("*" . "MuleArabic-1"))
420 (arabic-2-column ("*" . "MuleArabic-2"))
421 (indian-is13194 (nil . "is13194-devanagari"))
422 (indian-1-column ("*" . "muleindian-2"))
423 ;; Indian CDAC
424 (devanagari-cdac (nil . "Devanagari-CDAC"))
425 (sanskrit-cdac (nil . "Sanskrit-CDAC"))
426 (bengali-cdac (nil . "Bengali-CDAC"))
427 (assamese-cdac (nil . "Assamese-CDAC"))
428 (punjabi-cdac (nil . "Punjabi-CDAC"))
429 (gujarati-cdac (nil . "Gujarati-CDAC"))
430 (oriya-cdac (nil . "Oriya-CDAC"))
431 (tamil-cdac (nil . "Tamil-CDAC"))
432 (telugu-cdac (nil . "Telugu-CDAC"))
433 (kannada-cdac (nil . "Kannada-CDAC"))
434 (malayalam-cdac (nil . "Malayalam-CDAC"))
435 ;; Indian AKRUTI
436 (devanagari-akruti (nil . "Devanagari-Akruti"))
437 (bengali-akruti (nil . "Bengali-Akruti"))
438 (punjabi-akruti (nil . "Punjabi-Akruti"))
439 (gujarati-akruti (nil . "Gujarati-Akruti"))
440 (oriya-akruti (nil . "Oriya-Akruti"))
441 (tamil-akruti (nil . "Tamil-Akruti"))
442 (telugu-akruti (nil . "Telugu-Akruti"))
443 (kannada-akruti (nil . "Kannada-Akruti"))
444 (malayalam-akruti (nil . "Malayalam-Akruti"))
445 ;;(devanagari-glyph ("altsys-dv_ttsurekh" . "devanagari-cdac"))
446 ;;(malayalam-glyph ("altsys-ml_ttkarthika" . "malayalam-cdac"))
447 (ipa (nil . "MuleIPA-1")
448 (nil . "iso10646-1"))
450 ;; Fallback fonts
451 (nil (nil . "gb2312.1980")
452 (nil . "gbk-0")
453 (nil . "gb18030")
454 (nil . "jisx0208")
455 (nil . "ksc5601.1987")
456 (nil . "CNS11643.1992-1")
457 (nil . "CNS11643.1992-2")
458 (nil . "CNS11643.1992-3")
459 (nil . "CNS11643.1992-4")
460 (nil . "CNS11643.1992-5")
461 (nil . "CNS11643.1992-6")
462 (nil . "CNS11643.1992-7")
463 (nil . "big5")
464 (nil . "jisx0213.2000-1")
465 (nil . "jisx0213.2004-1")
466 (nil . "jisx0212"))
469 ;; Append Unicode fonts.
470 ;; This may find fonts with more variants (bold, italic) but which
471 ;; don't cover many characters.
472 (set-fontset-font "fontset-default" nil
473 '(nil . "iso10646-1") nil 'append)
474 ;; These may find fonts that cover many characters but with fewer
475 ;; variants.
476 (set-fontset-font "fontset-default" nil
477 '("gnu-unifont" . "iso10646-1") nil 'append)
478 (set-fontset-font "fontset-default" nil
479 '("mutt-clearlyu" . "iso10646-1") nil 'append)
481 (set-fontset-font "fontset-default" '(#xE000 . #xF8FF) nil))
483 ;; These are the registered registries/encodings from
484 ;; ftp://ftp.x.org/pub/DOCS/registry 2001/06/01
486 ;; Name Reference
487 ;; ---- ---------
488 ;; "DEC" [27]
489 ;; registry prefix
490 ;; "DEC.CNS11643.1986-2" [53]
491 ;; CNS11643 2-plane using the encoding
492 ;; suggested in that standard
493 ;; "DEC.DTSCS.1990-2" [54]
494 ;; DEC Taiwan Supplemental Character Set
495 ;; "fujitsu.u90x01.1991-0" [87]
496 ;; "fujitsu.u90x03.1991-0" [87]
497 ;; "GB2312.1980-0" [39],[12]
498 ;; China (PRC) Hanzi, GL encoding
499 ;; "GB2312.1980-1" [39]
500 ;; (deprecated)
501 ;; China (PRC) Hanzi, GR encoding
502 ;; "HP-Arabic8" [36]
503 ;; HPARABIC8 8-bit character set
504 ;; "HP-East8" [36]
505 ;; HPEAST8 8-bit character set
506 ;; "HP-Greek8" [36]
507 ;; HPGREEK8 8-bit character set
508 ;; "HP-Hebrew8" [36]
509 ;; HPHEBREW8 8-bit character set
510 ;; "HP-Japanese15" [36]
511 ;; HPJAPAN15 15-bit characer set,
512 ;; modified from industry defacto
513 ;; standard Shift-JIS
514 ;; "HP-Kana8" [36]
515 ;; HPKANA8 8-bit character set
516 ;; "HP-Korean15" [36]
517 ;; HPKOREAN15 15-bit character set
518 ;; "HP-Roman8" [36]
519 ;; HPROMAN8 8-bit character set
520 ;; "HP-SChinese15" [36]
521 ;; HPSCHINA15 15-bit character set for
522 ;; support of Simplified Chinese
523 ;; "HP-TChinese15" [36]
524 ;; HPTCHINA15 15-bit character set for
525 ;; support of Traditional Chinese
526 ;; "HP-Turkish8" [36]
527 ;; HPTURKISH8 8-bit character set
528 ;; "IPSYS" [59]
529 ;; registry prefix
530 ;; "IPSYS.IE-1" [59]
531 ;; "ISO2022"<REG>"-"<ENC> [44]
532 ;; "ISO646.1991-IRV" [107]
533 ;; ISO 646 International Reference Version
534 ;; "ISO8859-1" [15],[12]
535 ;; ISO Latin alphabet No. 1
536 ;; "ISO8859-2" [15],[12]
537 ;; ISO Latin alphabet No. 2
538 ;; "ISO8859-3" [15],[12]
539 ;; ISO Latin alphabet No. 3
540 ;; "ISO8859-4" [15],[12]
541 ;; ISO Latin alphabet No. 4
542 ;; "ISO8859-5" [15],[12]
543 ;; ISO Latin/Cyrillic alphabet
544 ;; "ISO8859-6" [15],[12]
545 ;; ISO Latin/Arabic alphabet
546 ;; "ISO8859-7" [15],[12]
547 ;; ISO Latin/Greek alphabet
548 ;; "ISO8859-8" [15],[12]
549 ;; ISO Latin/Hebrew alphabet
550 ;; "ISO8859-9" [15],[12]
551 ;; ISO Latin alphabet No. 5
552 ;; "ISO8859-10" [15],[12]
553 ;; ISO Latin alphabet No. 6
554 ;; "ISO8859-13" [15],[12]
555 ;; ISO Latin alphabet No. 7
556 ;; "ISO8859-14" [15],[12]
557 ;; ISO Latin alphabet No. 8
558 ;; "ISO8859-15" [15],[12]
559 ;; ISO Latin alphabet No. 9
560 ;; "FCD8859-15" [7]
561 ;; (deprecated)
562 ;; ISO Latin alphabet No. 9, Final Committee Draft
563 ;; "ISO10646-1" [133]
564 ;; Unicode Universal Multiple-Octet Coded Character Set
565 ;; "ISO10646-MES" [133]
566 ;; (deprecated)
567 ;; Unicode Minimum European Subset
568 ;; "JISX0201.1976-0" [38],[12]
569 ;; 8-Bit Alphanumeric-Katakana Code
570 ;; "JISX0208.1983-0" [40],[12]
571 ;; Japanese Graphic Character Set,
572 ;; GL encoding
573 ;; "JISX0208.1990-0" [71]
574 ;; Japanese Graphic Character Set,
575 ;; GL encoding
576 ;; "JISX0208.1983-1" [40]
577 ;; (deprecated)
578 ;; Japanese Graphic Character Set,
579 ;; GR encoding
580 ;; "JISX0212.1990-0" [72]
581 ;; Supplementary Japanese Graphic Character Set,
582 ;; GL encoding
583 ;; "KOI8-R" [119]
584 ;; Cyrillic alphabet
585 ;; "KSC5601.1987-0" [41],[12]
586 ;; Korean Graphic Character Set,
587 ;; GL encoding
588 ;; "KSC5601.1987-1" [41]
589 ;; (deprecated)
590 ;; Korean Graphic Character Set,
591 ;; GR encoding
592 ;; "omron_CNS11643-0" [45]
593 ;; "omron_CNS11643-1" [45]
594 ;; "omron_BIG5-0" [45]
595 ;; "omron_BIG5-1" [45]
596 ;; "wn.tamil.1993" [103]
598 (defun set-font-encoding (pattern charset)
599 "Set arguments in `font-encoding-alist' (which see)."
600 (let ((slot (assoc pattern font-encoding-alist)))
601 (if slot
602 (setcdr slot charset)
603 (setq font-encoding-alist
604 (cons (cons pattern charset) font-encoding-alist)))))
606 ;; Setting for suppressing XLoadQueryFont on big fonts.
607 (setq x-pixel-size-width-font-regexp
608 "gb2312\\|gbk\\|gb18030\\|jisx0208\\|ksc5601\\|cns11643\\|big5")
610 ;; These fonts require vertical centering.
611 (setq vertical-centering-font-regexp
612 "gb2312\\|gbk\\|gb18030\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5")
614 ;; CDAC fonts are actually smaller than their design sizes.
615 (setq face-font-rescale-alist
616 '(("-cdac$" . 1.3)))
618 (defvar x-font-name-charset-alist nil
619 "This variable has no meaning now. Just kept for backward compatibility.")
621 ;;; XLFD (X Logical Font Description) format handler.
623 ;; Define XLFD's field index numbers. ; field name
624 (defconst xlfd-regexp-family-subnum 0) ; FOUNDRY and FAMILY
625 (defconst xlfd-regexp-weight-subnum 1) ; WEIGHT_NAME
626 (defconst xlfd-regexp-slant-subnum 2) ; SLANT
627 (defconst xlfd-regexp-swidth-subnum 3) ; SETWIDTH_NAME
628 (defconst xlfd-regexp-adstyle-subnum 4) ; ADD_STYLE_NAME
629 (defconst xlfd-regexp-pixelsize-subnum 5) ; PIXEL_SIZE
630 (defconst xlfd-regexp-pointsize-subnum 6) ; POINT_SIZE
631 (defconst xlfd-regexp-resx-subnum 7) ; RESOLUTION_X
632 (defconst xlfd-regexp-resy-subnum 8) ; RESOLUTION_Y
633 (defconst xlfd-regexp-spacing-subnum 8) ; SPACING
634 (defconst xlfd-regexp-avgwidth-subnum 10) ; AVERAGE_WIDTH
635 (defconst xlfd-regexp-registry-subnum 11) ; REGISTRY and ENCODING
637 ;; Regular expression matching against a fontname which conforms to
638 ;; XLFD (X Logical Font Description). All fields in XLFD should be
639 ;; not be omitted (but can be a wild card) to be matched.
640 (defconst xlfd-tight-regexp
642 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
643 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
644 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*-[^-]*\\)$")
646 ;; Regular expression matching against a fontname which conforms to
647 ;; XLFD (X Logical Font Description). All fields in XLFD from FOUNDRY
648 ;; to ADSTYLE, REGISTRY, and ENCODING should be not be omitted (but
649 ;; can be a wild card) to be matched.
650 (defconst xlfd-style-regexp
652 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-.*\
653 -\\([^-]*-[^-]*\\)$")
655 ;; List of field numbers of XLFD whose values are numeric.
656 (defconst xlfd-regexp-numeric-subnums
657 (list xlfd-regexp-pixelsize-subnum ;5
658 xlfd-regexp-pointsize-subnum ;6
659 xlfd-regexp-resx-subnum ;7
660 xlfd-regexp-resy-subnum ;8
661 xlfd-regexp-avgwidth-subnum ;10
664 (defun x-decompose-font-name (pattern)
665 "Decompose PATTERN into XLFD fields and return a vector of the fields.
666 The length of the vector is 12.
667 The FOUNDRY and FAMILY fields are concatinated and stored in the first
668 element of the vector.
669 The REGISTRY and ENCODING fields are concatinated and stored in the last
670 element of the vector.
672 Return nil if PATTERN doesn't conform to XLFD."
673 (if (string-match xlfd-tight-regexp pattern)
674 (let ((xlfd-fields (make-vector 12 nil)))
675 (dotimes (i 12)
676 (aset xlfd-fields i (match-string (1+ i) pattern)))
677 (dotimes (i 12)
678 (if (string-match "^[*-]+$" (aref xlfd-fields i))
679 (aset xlfd-fields i nil)))
680 xlfd-fields)))
682 (defun x-compose-font-name (fields &optional reduce)
683 "Compose X fontname from FIELDS.
684 FIELDS is a vector of XLFD fields, of length 12.
685 If a field is nil, wild-card letter `*' is embedded.
686 Optional argument REDUCE exists just for backward compatibility,
687 and is always ignored."
688 (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-")))
691 (defun x-must-resolve-font-name (xlfd-fields)
692 "Like `x-resolve-font-name', but always return a font name.
693 XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
694 If no font matching XLFD-FIELDS is available, successively replace
695 parts of the font name pattern with \"*\" until some font is found.
696 Value is name of that font."
697 (let ((ascii-font nil) (index 0))
698 (while (and (null ascii-font) (<= index xlfd-regexp-registry-subnum))
699 (let ((pattern (x-compose-font-name xlfd-fields)))
700 (condition-case nil
701 (setq ascii-font (x-resolve-font-name pattern))
702 (error
703 (message "Warning: no fonts matching `%s' available" pattern)
704 (aset xlfd-fields index "*")
705 (setq index (1+ index))))))
706 (unless ascii-font
707 (error "No fonts found"))
708 ascii-font))
711 (defun x-complement-fontset-spec (default-spec fontlist)
712 "Complement elements of FONTLIST based on DEFAULT-SPEC.
713 DEFAULT-SPEC is a font-spec object providing default font properties.
714 FONTLIST is an alist of script names vs the corresponding font names.
716 The font names are parsed and unspecified font properties are
717 given from DEFAULT-SPEC."
718 (let ((prop-list '(:foundry :family :weight :slant :width :adstyle :size)))
719 (dolist (elt fontlist)
720 (let ((spec (font-spec :name (cadr elt))))
721 (dolist (prop prop-list)
722 (let ((val (font-get spec prop)))
723 (or val
724 (font-put spec prop (font-get default-spec prop)))))
725 (setcar (cdr elt) spec)))
726 fontlist))
728 (defun fontset-name-p (fontset)
729 "Return non-nil if FONTSET is valid as fontset name.
730 A valid fontset name should conform to XLFD (X Logical Font Description)
731 with \"fontset\" in `<CHARSET_REGISTRY>' field."
732 (and (string-match xlfd-tight-regexp fontset)
733 (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset)
734 "fontset")))
736 (defun generate-fontset-menu ()
737 "Return list to be appended to `x-fixed-font-alist'.
738 Done when `mouse-set-font' is called."
739 (let (l)
740 (dolist (fontset (fontset-list))
741 (or (string-match "fontset-default$" fontset)
742 (push (list (fontset-plain-name fontset) fontset) l)))
743 (cons "Fontset"
744 (sort l #'(lambda (x y) (string< (car x) (car y)))))))
746 (defun fontset-plain-name (fontset)
747 "Return a plain and descriptive name of FONTSET."
748 (if (not (setq fontset (query-fontset fontset)))
749 (error "Invalid fontset: %s" fontset))
750 (let ((xlfd-fields (x-decompose-font-name fontset)))
751 (if xlfd-fields
752 (let ((family (aref xlfd-fields xlfd-regexp-family-subnum))
753 (weight (aref xlfd-fields xlfd-regexp-weight-subnum))
754 (slant (aref xlfd-fields xlfd-regexp-slant-subnum))
755 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum))
756 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum))
757 (nickname (aref xlfd-fields xlfd-regexp-registry-subnum))
758 name)
759 (if (not (string-match "^fontset-\\(.*\\)$" nickname))
760 (setq nickname family)
761 (setq nickname (match-string 1 nickname)))
762 (if (and size (> (string-to-number size) 0))
763 (setq name (format "%s: %s-dot" nickname size))
764 (setq name nickname))
765 (and weight
766 (cond ((string-match "^medium$" weight)
767 (setq name (concat name " " "medium")))
768 ((string-match "^bold$\\|^demibold$" weight)
769 (setq name (concat name " " weight)))))
770 (and slant
771 (cond ((string-match "^i$" slant)
772 (setq name (concat name " " "italic")))
773 ((string-match "^o$" slant)
774 (setq name (concat name " " "slant")))
775 ((string-match "^ri$" slant)
776 (setq name (concat name " " "reverse italic")))
777 ((string-match "^ro$" slant)
778 (setq name (concat name " " "reverse slant")))))
779 name)
780 fontset)))
782 (defvar charset-script-alist
783 '((ascii . latin)
784 (latin-iso8859-1 . latin)
785 (latin-iso8859-2 . latin)
786 (latin-iso8859-3 . latin)
787 (latin-iso8859-4 . latin)
788 (latin-iso8859-9 . latin)
789 (latin-iso8859-10 . latin)
790 (latin-iso8859-13 . latin)
791 (latin-iso8859-14 . latin)
792 (latin-iso8859-15 . latin)
793 (latin-iso8859-16 . latin)
794 (latin-jisx0201 . latin)
795 (thai-tis620 . thai)
796 (cyrillic-iso8859-5 . cyrillic)
797 (arabic-iso8859-6 . arabic)
798 (greek-iso8859-7 . latin)
799 (hebrew-iso8859-8 . latin)
800 (katakana-jisx0201 . kana)
801 (chinese-gb2312 . han)
802 (chinese-gbk . han)
803 (gb18030-2-byte . han)
804 (gb18030-4-byte-bmp . han)
805 (gb18030-4-byte-ext-1 . han)
806 (gb18030-4-byte-ext-2 . han)
807 (gb18030-4-byte-smp . han)
808 (chinese-big5-1 . han)
809 (chinese-big5-2 . han)
810 (chinese-cns11643-1 . han)
811 (chinese-cns11643-2 . han)
812 (chinese-cns11643-3 . han)
813 (chinese-cns11643-4 . han)
814 (chinese-cns11643-5 . han)
815 (chinese-cns11643-6 . han)
816 (chinese-cns11643-7 . han)
817 (japanese-jisx0208 . han)
818 (japanese-jisx0208-1978 . han)
819 (japanese-jisx0212 . han)
820 (japanese-jisx0213-1 . han)
821 (japanese-jisx0213-2 . han)
822 (korean-ksc5601 . hangul)
823 (chinese-sisheng . bopomofo)
824 (vietnamese-viscii-lower . latin)
825 (vietnamese-viscii-upper . latin)
826 (arabic-digit . arabic)
827 (arabic-1-column . arabic)
828 (arabic-2-column . arabic)
829 (indian-is13194 . devanagari)
830 (indian-glyph . devanagari)
831 (indian-1-column . devanagari)
832 (indian-2-column . devanagari)
833 (tibetan-1-column . tibetan))
834 "Alist of charsets vs the corresponding most appropriate scripts.
836 This alist is used by the function `create-fontset-from-fontset-spec'
837 to map charsets to scripts.")
839 (defun create-fontset-from-fontset-spec (fontset-spec
840 &optional style-variant noerror)
841 "Create a fontset from fontset specification string FONTSET-SPEC.
842 FONTSET-SPEC is a string of the format:
843 FONTSET-NAME,SCRIPT0:FONT0,SCRIPT1:FONT1, ...
844 Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
846 When a frame uses the fontset as the `font' parameter, the frame's
847 default font name is derived from FONTSET-NAME by substituting
848 \"iso8859-1\" for the tail part \"fontset-XXX\". But, if SCRIPT-NAMEn
849 is \"ascii\", use the corresponding FONT-NAMEn as the default font
850 name.
852 Optional 2nd and 3rd arguments exist just for backward compatibility,
853 and are ignored.
855 It returns a name of the created fontset.
857 For backward compatibility, SCRIPT-NAME may be a charset name, in
858 which case, the corresponding script is decided by the variable
859 `charset-script-alist' (which see)."
860 (or (string-match "^[^,]+" fontset-spec)
861 (error "Invalid fontset spec: %s" fontset-spec))
862 (let ((idx (match-end 0))
863 (name (match-string 0 fontset-spec))
864 default-spec target script fontlist)
865 (or (string-match xlfd-tight-regexp name)
866 (error "Fontset name \"%s\" not conforming to XLFD" name))
867 (setq default-spec (font-spec :name name))
868 ;; At first, extract pairs of charset and fontname from FONTSET-SPEC.
869 (while (string-match "[, \t\n]*\\([^:]+\\):[ \t]*\\([^,]+\\)"
870 fontset-spec idx)
871 (setq idx (match-end 0))
872 (setq target (intern (match-string 1 fontset-spec)))
873 (cond ((or (eq target 'ascii)
874 (memq target (char-table-extra-slot char-script-table 0)))
875 (push (list target (match-string 2 fontset-spec)) fontlist))
876 ((setq script (cdr (assq target charset-script-alist)))
877 (push (list script (match-string 2 fontset-spec)) fontlist))
878 ((charsetp target)
879 (push (list target (match-string 2 fontset-spec)) fontlist))))
881 ;; Complement FONTLIST.
882 (setq fontlist (x-complement-fontset-spec default-spec fontlist))
884 ;; Create a fontset.
885 (new-fontset name (nreverse fontlist))))
887 (defun create-fontset-from-ascii-font (font &optional resolved-font
888 fontset-name)
889 "Create a fontset from an ASCII font FONT.
891 Optional 2nd arg RESOLVED-FONT is a resolved name of FONT.
892 If omitted, `x-resolve-font-name' is called to get the resolved name.
893 At this time, if FONT is not available, an error is signaled.
895 Optional 3rd arg FONTSET-NAME is a string to be used in
896 `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
897 an appropriate name is generated automatically.
899 It returns a name of the created fontset."
900 (setq font (downcase font))
901 (setq resolved-font
902 (downcase (or resolved-font (x-resolve-font-name font))))
903 (let ((xlfd (x-decompose-font-name resolved-font))
904 fontset)
905 (if fontset-name
906 (setq fontset-name (downcase fontset-name))
907 (if (query-fontset "fontset-startup")
908 (setq fontset-name
909 (subst-char-in-string
910 ?- ?_ (aref xlfd xlfd-regexp-registry-subnum) t))
911 (setq fontset-name "startup")))
912 (aset xlfd xlfd-regexp-registry-subnum
913 (format "fontset-%s" fontset-name))
914 (setq fontset (x-compose-font-name xlfd))
915 (or (query-fontset fontset)
916 (create-fontset-from-fontset-spec (concat fontset ", ascii:" font)))))
919 ;; Create standard fontset from 16 dots fonts which are the most widely
920 ;; installed fonts. Fonts for Chinese-GB, Korean, and Chinese-CNS are
921 ;; specified here because FAMILY of those fonts are not "fixed" in
922 ;; many cases.
923 (defvar standard-fontset-spec
924 (purecopy "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard")
925 "String of fontset spec of the standard fontset.
926 You have the biggest chance to display international characters
927 with correct glyphs by using the standard fontset.
928 See the documentation of `create-fontset-from-fontset-spec' for the format.")
931 ;; Create fontsets from X resources of the name `fontset-N (class
932 ;; Fontset-N)' where N is integer 0, 1, ...
933 ;; The values of the resources the string of the same format as
934 ;; `standard-fontset-spec'.
936 (defun create-fontset-from-x-resource ()
937 (let ((idx 0)
938 fontset-spec)
939 (while (setq fontset-spec (x-get-resource (format "fontset-%d" idx)
940 (format "Fontset-%d" idx)))
941 (create-fontset-from-fontset-spec fontset-spec t 'noerror)
942 (setq idx (1+ idx)))))
945 (provide 'fontset)
947 ;;; arch-tag: bb53e629-0234-403c-950e-551e61554849
948 ;;; fontset.el ends here