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