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