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