1 ;;; fontset.el --- commands for handling fontset
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6 ;; 2005, 2006, 2007, 2008, 2009, 2010
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/>.
34 ;; Setup font-encoding-alist for all known encodings.
36 (setq font-encoding-alist
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
)
55 ("gb2312.1980" . chinese-gb2312
)
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
)
79 ("tis620" . tis620-2533
)
80 ("microsoft-cp1251" . windows-1251
)
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
)
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
)
176 (canadian-aboriginal #x14C0
)
181 (symbol .
[#x201C
#x2200
#x2500
])
183 (ideographic-description #x2FF0
)
194 (aegean-number #x10100
)
195 (ancient-greek-number #x10140
)
196 (ancient-symbol #x10190
)
197 (phaistos-disc #x101D0
)
202 (old-persian #x103A0
)
206 (cypriot-syllabary #x10800
)
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
231 (byzm . byzantine-musical-symbol
)
232 (cans . canadian-aboriginal
)
260 (math . mathematical
)
262 (musc . musical-symbol
)
275 (sylo . syloti_nagri
)
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
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
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
))
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
)))
333 (:registry
"iso10646-1" :otf
(tibt nil
(ccmp blws abvs
)))
334 (:family
"mtib" :registry
"iso10646-1")
335 (:registry
"muletibetan-2"))
337 (:registry
"iso10646-1" :script ethiopic
)
338 (:registry
"ethiopic-unicode"))
340 (:registry
"iso10646-1" :script phonetic
)
341 (:registry
"MuleIPA-1")
342 (:registry
"iso10646-1"))))
343 (cjk-table (make-char-table nil
))
348 #'(lambda (range val
)
349 (when (eq val script
)
351 (setq range
(cons (car range
) (cdr range
))))
352 (push range coverage
)))
355 (data (list (vconcat (mapcar 'car cjk
))))
358 (let ((mask (lsh 1 i
)))
360 #'(lambda (range arg
)
361 (let ((from (car range
)) (to (cdr range
)))
364 (or (memq (aref char-script-table from
)
365 '(kana hangul han cjk-misc
))
367 (logior (or (aref cjk-table from
) 0) mask
)))
368 (setq from
(1+ from
))))))
369 (nth 1 elt
) nil
(nth 2 elt
) (nth 3 elt
)))
372 #'(lambda (range val
)
374 (setq range
(cons (car range
) (cdr range
))))
375 (push (cons range val
) data
))
377 (dolist (script scripts
)
378 (dolist (range (funcall script-coverage
(car script
)))
379 (push (cons range
(cdr script
)) data
)))
380 `(quote ,(nreverse data
))))
383 (defun setup-default-fontset ()
384 "Setup the default fontset."
388 (latin (nil .
"ISO8859-1")
398 (nil .
"VISCII1.1-1")
399 ,(font-spec :registry
"iso10646-1" :script
'latin
))
401 (thai ,(font-spec :registry
"iso10646-1" :otf
'(thai nil nil
(mark)))
402 ,(font-spec :registry
"iso10646-1" :script
'thai
)
404 (nil .
"ISO8859-11"))
406 (devanagari ,(font-spec :registry
"iso10646-1" :otf
'(deva nil
(rphf)))
407 (nil .
"iso10646.indian-1"))
408 (bengali ,(font-spec :registry
"iso10646-1" :otf
'(beng nil
(rphf))))
409 (gurmukhi ,(font-spec :registry
"iso10646-1" :otf
'(guru nil
(blwf))))
410 (gujarati ,(font-spec :registry
"iso10646-1" :otf
'(gujr nil
(rphf))))
411 (oriya ,(font-spec :registry
"iso10646-1" :otf
'(orya nil
(rphf))))
412 (tamil ,(font-spec :registry
"iso10646-1" :otf
'(taml nil
(akhn))))
413 (telugu ,(font-spec :registry
"iso10646-1" :otf
'(telu nil
(blwf))))
414 (kannada ,(font-spec :registry
"iso10646-1" :otf
'(knda nil
(rphf))))
415 (sinhala ,(font-spec :registry
"iso10646-1" :otf
'(sinh nil
(akhn))))
416 (malayalam ,(font-spec :registry
"iso10646-1" :otf
'(mlym nil
(akhn))))
418 (lao ,(font-spec :registry
"iso10646-1" :otf
'(lao\ nil nil
(mark)))
419 ,(font-spec :registry
"iso10646-1" :script
'lao
)
422 (tai-viet ("TaiViet" .
"iso10646-1"))
424 (greek ,(font-spec :registry
"iso10646-1" :script
'greek
)
427 (cyrillic ,(font-spec :registry
"iso10646-1" :script
'cyrillic
)
429 (nil .
"microsoft-cp1251")
432 (arabic ,(font-spec :registry
"iso10646-1"
433 :otf
'(arab nil
(init medi fini liga
)))
434 (nil .
"MuleArabic-0")
435 (nil .
"MuleArabic-1")
436 (nil .
"MuleArabic-2")
439 (hebrew ,(font-spec :registry
"iso10646-1" :script
'hebrew
)
442 (khmer ,(font-spec :registry
"iso10646-1" :otf
'(khmr nil
(pres))))
444 (kana (nil .
"JISX0208*")
445 (nil .
"GB2312.1980-0")
446 (nil .
"KSC5601.1987*")
448 (nil .
"JISX0213.2000-1")
449 (nil .
"JISX0213.2004-1")
450 ,(font-spec :registry
"iso10646-1" :script
'kana
))
452 (bopomofo ,(font-spec :registry
"iso10646-1" :script
'bopomofo
)
453 (nil .
"sisheng_cwnn-0"))
455 (han (nil .
"GB2312.1980-0")
459 (nil .
"KSC5601.1987*")
460 (nil .
"CNS11643.1992-1")
461 (nil .
"CNS11643.1992-2")
462 (nil .
"CNS11643.1992-3")
463 (nil .
"CNS11643.1992-4")
464 (nil .
"CNS11643.1992-5")
465 (nil .
"CNS11643.1992-6")
466 (nil .
"CNS11643.1992-7")
469 (nil .
"JISX0213.2000-1")
470 (nil .
"JISX0213.2000-2")
471 (nil .
"JISX0213.2004-1")
472 ,(font-spec :registry
"iso10646-1" :lang
'ja
)
473 ,(font-spec :registry
"iso10646-1" :lang
'zh
))
475 (cjk-misc (nil .
"GB2312.1980-0")
479 (nil .
"KSC5601.1987*")
480 (nil .
"CNS11643.1992-1")
481 (nil .
"CNS11643.1992-2")
482 (nil .
"CNS11643.1992-3")
483 (nil .
"CNS11643.1992-4")
484 (nil .
"CNS11643.1992-5")
485 (nil .
"CNS11643.1992-6")
486 (nil .
"CNS11643.1992-7")
489 (nil .
"JISX0213.2000-1")
490 (nil .
"JISX0213.2000-2")
491 ,(font-spec :registry
"iso10646-1" :lang
'ja
)
492 ,(font-spec :registry
"iso10646-1" :lang
'zh
))
494 (hangul (nil .
"KSC5601.1987-0")
495 ,(font-spec :registry
"iso10646-1" :lang
'ko
))
498 (ascii (nil .
"ISO8859-1"))
499 (arabic-digit ("*" .
"MuleArabic-0"))
500 (arabic-1-column ("*" .
"MuleArabic-1"))
501 (arabic-2-column ("*" .
"MuleArabic-2"))
502 (indian-is13194 (nil .
"is13194-devanagari"))
503 (indian-1-column ("*" .
"muleindian-2"))
505 (devanagari-cdac (nil .
"Devanagari-CDAC"))
506 (sanskrit-cdac (nil .
"Sanskrit-CDAC"))
507 (bengali-cdac (nil .
"Bengali-CDAC"))
508 (assamese-cdac (nil .
"Assamese-CDAC"))
509 (punjabi-cdac (nil .
"Punjabi-CDAC"))
510 (gujarati-cdac (nil .
"Gujarati-CDAC"))
511 (oriya-cdac (nil .
"Oriya-CDAC"))
512 (tamil-cdac (nil .
"Tamil-CDAC"))
513 (telugu-cdac (nil .
"Telugu-CDAC"))
514 (kannada-cdac (nil .
"Kannada-CDAC"))
515 (malayalam-cdac (nil .
"Malayalam-CDAC"))
517 (devanagari-akruti (nil .
"Devanagari-Akruti"))
518 (bengali-akruti (nil .
"Bengali-Akruti"))
519 (punjabi-akruti (nil .
"Punjabi-Akruti"))
520 (gujarati-akruti (nil .
"Gujarati-Akruti"))
521 (oriya-akruti (nil .
"Oriya-Akruti"))
522 (tamil-akruti (nil .
"Tamil-Akruti"))
523 (telugu-akruti (nil .
"Telugu-Akruti"))
524 (kannada-akruti (nil .
"Kannada-Akruti"))
525 (malayalam-akruti (nil .
"Malayalam-Akruti"))
528 (nil (nil .
"gb2312.1980")
532 (nil .
"ksc5601.1987")
533 (nil .
"CNS11643.1992-1")
534 (nil .
"CNS11643.1992-2")
535 (nil .
"CNS11643.1992-3")
536 (nil .
"CNS11643.1992-4")
537 (nil .
"CNS11643.1992-5")
538 (nil .
"CNS11643.1992-6")
539 (nil .
"CNS11643.1992-7")
541 (nil .
"jisx0213.2000-1")
542 (nil .
"jisx0213.2004-1")
546 ;; For simple scripts
547 (dolist (script '(phonetic
577 cuneiform-numbers-and-punctuation
578 byzantine-musical-symbol
580 ancient-greek-musical-notation
585 (set-fontset-font "fontset-default"
586 script
(font-spec :registry
"iso10646-1" :script script
)
589 ;; Special settings for `MATHEMATICAL (U+1D400..U+1D7FF)'.
590 (dolist (math-subgroup '((#x1D400
#x1D433 mathematical-bold
)
591 (#x1D434
#x1D467 mathematical-italic
)
592 (#x1D468
#x1D49B mathematical-bold-italic
)
593 (#x1D49C
#x1D4CF mathematical-script
)
594 (#x1D4D0
#x1D503 mathematical-bold-script
)
595 (#x1D504
#x1D537 mathematical-fraktur
)
596 (#x1D538
#x1D56B mathematical-double-struck
)
597 (#x1D56C
#x1D59F mathematical-bold-fraktur
)
598 (#x1D5A0
#x1D5D3 mathematical-sans-serif
)
599 (#x1D5D4
#x1D607 mathematical-sans-serif-bold
)
600 (#x1D608
#x1D63B mathematical-sans-serif-italic
)
601 (#x1D63C
#x1D66F mathematical-sans-serif-bold-italic
)
602 (#x1D670
#x1D6A3 mathematical-monospace
)
603 (#x1D6A4
#x1D6A5 mathematical-italic
)
604 (#x1D6A8
#x1D6E1 mathematical-bold
)
605 (#x1D6E2
#x1D71B mathematical-italic
)
606 (#x1D71C
#x1D755 mathematical-bold-italic
)
607 (#x1D756
#x1D78F mathematical-sans-serif-bold
)
608 (#x1D790
#x1D7C9 mathematical-sans-serif-bold-italic
)
609 (#x1D7CA
#x1D7D7 mathematical-bold
)
610 (#x1D7D8
#x1D7E1 mathematical-double-struck
)
611 (#x1D7E2
#x1D7EB mathematical-sans-serif
)
612 (#x1D7EC
#x1D7F5 mathematical-sans-serif-bold
)
613 (#x1D7F6
#x1D7FF mathematical-monospace
)))
614 (let ((slot (assq (nth 2 math-subgroup
) script-representative-chars
)))
616 (if (vectorp (cdr slot
))
617 (setcdr slot
(vconcat (cdr slot
) (vector (car math-subgroup
))))
618 (setcdr slot
(vector (cadr slot
) (car math-subgroup
))))
619 (setq slot
(list (nth 2 math-subgroup
) (car math-subgroup
)))
620 (nconc script-representative-chars
(list slot
))))
623 (cons (car math-subgroup
) (nth 1 math-subgroup
))
624 (font-spec :registry
"iso10646-1" :script
(nth 2 math-subgroup
))))
626 ;; Append CJK fonts for characters other than han, kana, cjk-misc.
627 ;; Append fonts for scripts whose name is also a charset name.
628 (let* ((data (build-default-fontset-data))
629 (registries (car data
)))
630 (dolist (target-spec (cdr data
))
631 (let ((target (car target-spec
))
632 (spec (cdr target-spec
)))
634 (dotimes (i (length registries
))
635 (if (> (logand spec
(lsh 1 i
)) 0)
636 (set-fontset-font "fontset-default" target
637 (cons nil
(aref registries i
))
640 (set-fontset-font "fontset-default" target
641 (apply 'font-spec args
) nil
'append
))))))
643 ;; Append Unicode fonts.
644 ;; This may find fonts with more variants (bold, italic) but which
645 ;; don't cover many characters.
646 (set-fontset-font "fontset-default" nil
647 '(nil .
"iso10646-1") nil
'prepend
)
648 ;; These may find fonts that cover many characters but with fewer
650 (set-fontset-font "fontset-default" nil
651 '("gnu-unifont" .
"iso10646-1") nil
'prepend
)
652 (set-fontset-font "fontset-default" nil
653 '("mutt-clearlyu" .
"iso10646-1") nil
'prepend
)
654 (set-fontset-font "fontset-default" '(#x20000 .
#x2FFFF
)
655 '(nil .
"unicode-sip"))
657 (set-fontset-font "fontset-default" '(#xE000 .
#xF8FF
)
658 '(nil .
"iso10646-1"))
659 ;; Don't try the fallback fonts even if no suitable font was found
660 ;; by the above font-spec.
661 (set-fontset-font "fontset-default" '(#xE000 .
#xF8FF
) nil nil
'append
))
663 (defun create-default-fontset ()
664 "Create the default fontset.
665 Internal use only. Should be called at startup time."
667 (setup-default-fontset)
668 (error (display-warning
670 (format "Creation of the default fontsets failed: %s" err
)
673 ;; These are the registered registries/encodings from
674 ;; ftp://ftp.x.org/pub/DOCS/registry 2001/06/01
680 ;; "DEC.CNS11643.1986-2" [53]
681 ;; CNS11643 2-plane using the encoding
682 ;; suggested in that standard
683 ;; "DEC.DTSCS.1990-2" [54]
684 ;; DEC Taiwan Supplemental Character Set
685 ;; "fujitsu.u90x01.1991-0" [87]
686 ;; "fujitsu.u90x03.1991-0" [87]
687 ;; "GB2312.1980-0" [39],[12]
688 ;; China (PRC) Hanzi, GL encoding
689 ;; "GB2312.1980-1" [39]
691 ;; China (PRC) Hanzi, GR encoding
693 ;; HPARABIC8 8-bit character set
695 ;; HPEAST8 8-bit character set
697 ;; HPGREEK8 8-bit character set
699 ;; HPHEBREW8 8-bit character set
700 ;; "HP-Japanese15" [36]
701 ;; HPJAPAN15 15-bit characer set,
702 ;; modified from industry defacto
703 ;; standard Shift-JIS
705 ;; HPKANA8 8-bit character set
706 ;; "HP-Korean15" [36]
707 ;; HPKOREAN15 15-bit character set
709 ;; HPROMAN8 8-bit character set
710 ;; "HP-SChinese15" [36]
711 ;; HPSCHINA15 15-bit character set for
712 ;; support of Simplified Chinese
713 ;; "HP-TChinese15" [36]
714 ;; HPTCHINA15 15-bit character set for
715 ;; support of Traditional Chinese
716 ;; "HP-Turkish8" [36]
717 ;; HPTURKISH8 8-bit character set
721 ;; "ISO2022"<REG>"-"<ENC> [44]
722 ;; "ISO646.1991-IRV" [107]
723 ;; ISO 646 International Reference Version
724 ;; "ISO8859-1" [15],[12]
725 ;; ISO Latin alphabet No. 1
726 ;; "ISO8859-2" [15],[12]
727 ;; ISO Latin alphabet No. 2
728 ;; "ISO8859-3" [15],[12]
729 ;; ISO Latin alphabet No. 3
730 ;; "ISO8859-4" [15],[12]
731 ;; ISO Latin alphabet No. 4
732 ;; "ISO8859-5" [15],[12]
733 ;; ISO Latin/Cyrillic alphabet
734 ;; "ISO8859-6" [15],[12]
735 ;; ISO Latin/Arabic alphabet
736 ;; "ISO8859-7" [15],[12]
737 ;; ISO Latin/Greek alphabet
738 ;; "ISO8859-8" [15],[12]
739 ;; ISO Latin/Hebrew alphabet
740 ;; "ISO8859-9" [15],[12]
741 ;; ISO Latin alphabet No. 5
742 ;; "ISO8859-10" [15],[12]
743 ;; ISO Latin alphabet No. 6
744 ;; "ISO8859-13" [15],[12]
745 ;; ISO Latin alphabet No. 7
746 ;; "ISO8859-14" [15],[12]
747 ;; ISO Latin alphabet No. 8
748 ;; "ISO8859-15" [15],[12]
749 ;; ISO Latin alphabet No. 9
752 ;; ISO Latin alphabet No. 9, Final Committee Draft
753 ;; "ISO10646-1" [133]
754 ;; Unicode Universal Multiple-Octet Coded Character Set
755 ;; "ISO10646-MES" [133]
757 ;; Unicode Minimum European Subset
758 ;; "JISX0201.1976-0" [38],[12]
759 ;; 8-Bit Alphanumeric-Katakana Code
760 ;; "JISX0208.1983-0" [40],[12]
761 ;; Japanese Graphic Character Set,
763 ;; "JISX0208.1990-0" [71]
764 ;; Japanese Graphic Character Set,
766 ;; "JISX0208.1983-1" [40]
768 ;; Japanese Graphic Character Set,
770 ;; "JISX0212.1990-0" [72]
771 ;; Supplementary Japanese Graphic Character Set,
775 ;; "KSC5601.1987-0" [41],[12]
776 ;; Korean Graphic Character Set,
778 ;; "KSC5601.1987-1" [41]
780 ;; Korean Graphic Character Set,
782 ;; "omron_CNS11643-0" [45]
783 ;; "omron_CNS11643-1" [45]
784 ;; "omron_BIG5-0" [45]
785 ;; "omron_BIG5-1" [45]
786 ;; "wn.tamil.1993" [103]
788 (defun set-font-encoding (pattern charset
)
789 "Set arguments in `font-encoding-alist' (which see)."
790 (let ((slot (assoc pattern font-encoding-alist
)))
792 (setcdr slot charset
)
793 (setq font-encoding-alist
794 (cons (cons pattern charset
) font-encoding-alist
)))))
796 (defvar x-pixel-size-width-font-regexp
)
797 (defvar vertical-centering-font-regexp
)
799 ;; Setting for suppressing XLoadQueryFont on big fonts.
800 (setq x-pixel-size-width-font-regexp
801 (purecopy "gb2312\\|gbk\\|gb18030\\|jisx0208\\|ksc5601\\|cns11643\\|big5"))
803 ;; These fonts require vertical centering.
804 (setq vertical-centering-font-regexp
805 (purecopy "gb2312\\|gbk\\|gb18030\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5"))
807 ;; CDAC fonts are actually smaller than their design sizes.
808 (setq face-font-rescale-alist
809 (list (cons (purecopy "-cdac$") 1.3)))
811 (defvar x-font-name-charset-alist nil
812 "This variable has no meaning now. Just kept for backward compatibility.")
814 ;;; XLFD (X Logical Font Description) format handler.
816 ;; Define XLFD's field index numbers. ; field name
817 (defconst xlfd-regexp-family-subnum
0) ; FOUNDRY and FAMILY
818 (defconst xlfd-regexp-weight-subnum
1) ; WEIGHT_NAME
819 (defconst xlfd-regexp-slant-subnum
2) ; SLANT
820 (defconst xlfd-regexp-swidth-subnum
3) ; SETWIDTH_NAME
821 (defconst xlfd-regexp-adstyle-subnum
4) ; ADD_STYLE_NAME
822 (defconst xlfd-regexp-pixelsize-subnum
5) ; PIXEL_SIZE
823 (defconst xlfd-regexp-pointsize-subnum
6) ; POINT_SIZE
824 (defconst xlfd-regexp-resx-subnum
7) ; RESOLUTION_X
825 (defconst xlfd-regexp-resy-subnum
8) ; RESOLUTION_Y
826 (defconst xlfd-regexp-spacing-subnum
8) ; SPACING
827 (defconst xlfd-regexp-avgwidth-subnum
10) ; AVERAGE_WIDTH
828 (defconst xlfd-regexp-registry-subnum
11) ; REGISTRY and ENCODING
830 ;; Regular expression matching against a fontname which conforms to
831 ;; XLFD (X Logical Font Description). All fields in XLFD should be
832 ;; not be omitted (but can be a wild card) to be matched.
833 (defconst xlfd-tight-regexp
835 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
836 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
837 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*-[^-]*\\)$")
839 ;; Regular expression matching against a fontname which conforms to
840 ;; XLFD (X Logical Font Description). All fields in XLFD from FOUNDRY
841 ;; to ADSTYLE, REGISTRY, and ENCODING should be not be omitted (but
842 ;; can be a wild card) to be matched.
843 (defconst xlfd-style-regexp
845 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-.*\
846 -\\([^-]*-[^-]*\\)$")
848 ;; List of field numbers of XLFD whose values are numeric.
849 (defconst xlfd-regexp-numeric-subnums
850 (list xlfd-regexp-pixelsize-subnum
;5
851 xlfd-regexp-pointsize-subnum
;6
852 xlfd-regexp-resx-subnum
;7
853 xlfd-regexp-resy-subnum
;8
854 xlfd-regexp-avgwidth-subnum
;10
857 (defun x-decompose-font-name (pattern)
858 "Decompose PATTERN into XLFD fields and return a vector of the fields.
859 The length of the vector is 12.
860 The FOUNDRY and FAMILY fields are concatinated and stored in the first
861 element of the vector.
862 The REGISTRY and ENCODING fields are concatinated and stored in the last
863 element of the vector.
865 Return nil if PATTERN doesn't conform to XLFD."
866 (if (string-match xlfd-tight-regexp pattern
)
867 (let ((xlfd-fields (make-vector 12 nil
)))
869 (aset xlfd-fields i
(match-string (1+ i
) pattern
)))
871 (if (string-match "^[*-]+$" (aref xlfd-fields i
))
872 (aset xlfd-fields i nil
)))
875 (defun x-compose-font-name (fields &optional reduce
)
876 "Compose X fontname from FIELDS.
877 FIELDS is a vector of XLFD fields, of length 12.
878 If a field is nil, wild-card letter `*' is embedded.
879 Optional argument REDUCE exists just for backward compatibility,
880 and is always ignored."
881 (concat "-" (mapconcat (lambda (x) (or x
"*")) fields
"-")))
884 (defun x-must-resolve-font-name (xlfd-fields)
885 "Like `x-resolve-font-name', but always return a font name.
886 XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
887 If no font matching XLFD-FIELDS is available, successively replace
888 parts of the font name pattern with \"*\" until some font is found.
889 Value is name of that font."
890 (let ((ascii-font nil
) (index 0))
891 (while (and (null ascii-font
) (<= index xlfd-regexp-registry-subnum
))
892 (let ((pattern (x-compose-font-name xlfd-fields
)))
894 (setq ascii-font
(x-resolve-font-name pattern
))
896 (message "Warning: no fonts matching `%s' available" pattern
)
897 (aset xlfd-fields index
"*")
898 (setq index
(1+ index
))))))
900 (error "No fonts found"))
904 (defun x-complement-fontset-spec (default-spec fontlist
)
905 "Complement elements of FONTLIST based on DEFAULT-SPEC.
906 DEFAULT-SPEC is a font-spec object providing default font properties.
907 FONTLIST is an alist of script names vs the corresponding font names.
909 The font names are parsed and unspecified font properties are
910 given from DEFAULT-SPEC."
911 (let ((prop-list '(:foundry
:family
:weight
:slant
:width
:adstyle
:size
)))
912 (dolist (elt fontlist
)
913 (let ((spec (font-spec :name
(cadr elt
))))
914 (dolist (prop prop-list
)
915 (let ((val (font-get spec prop
)))
917 (font-put spec prop
(font-get default-spec prop
)))))
918 (setcar (cdr elt
) spec
)))
921 (defun fontset-name-p (fontset)
922 "Return non-nil if FONTSET is valid as fontset name.
923 A valid fontset name should conform to XLFD (X Logical Font Description)
924 with \"fontset\" in `<CHARSET_REGISTRY>' field."
925 (and (string-match xlfd-tight-regexp fontset
)
926 (string= (match-string (1+ xlfd-regexp-registry-subnum
) fontset
)
929 (declare-function fontset-list
"fontset.c" ())
931 (defun generate-fontset-menu ()
932 "Return list to be appended to `x-fixed-font-alist'.
933 Done when `mouse-set-font' is called."
935 (dolist (fontset (fontset-list))
936 (or (string-match "fontset-default$" fontset
)
937 (string-match "fontset-auto[0-9]+$" fontset
)
938 (push (list (fontset-plain-name fontset
) fontset
) l
)))
940 (sort l
#'(lambda (x y
) (string< (car x
) (car y
)))))))
942 (declare-function query-fontset
"fontset.c" (pattern &optional regexpp
))
944 (defun fontset-plain-name (fontset)
945 "Return a plain and descriptive name of FONTSET."
946 (if (not (setq fontset
(query-fontset fontset
)))
947 (error "Invalid fontset: %s" fontset
))
948 (let ((xlfd-fields (x-decompose-font-name fontset
)))
950 (let ((family (aref xlfd-fields xlfd-regexp-family-subnum
))
951 (weight (aref xlfd-fields xlfd-regexp-weight-subnum
))
952 (slant (aref xlfd-fields xlfd-regexp-slant-subnum
))
953 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum
))
954 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum
))
955 (nickname (aref xlfd-fields xlfd-regexp-registry-subnum
))
957 (if (not (string-match "^fontset-\\(.*\\)$" nickname
))
958 (setq nickname family
)
959 (setq nickname
(match-string 1 nickname
)))
960 (if (and size
(> (string-to-number size
) 0))
961 (setq name
(format "%s: %s-dot" nickname size
))
962 (setq name nickname
))
964 (cond ((string-match "^medium$" weight
)
965 (setq name
(concat name
" " "medium")))
966 ((string-match "^bold$\\|^demibold$" weight
)
967 (setq name
(concat name
" " weight
)))))
969 (cond ((string-match "^i$" slant
)
970 (setq name
(concat name
" " "italic")))
971 ((string-match "^o$" slant
)
972 (setq name
(concat name
" " "slant")))
973 ((string-match "^ri$" slant
)
974 (setq name
(concat name
" " "reverse italic")))
975 ((string-match "^ro$" slant
)
976 (setq name
(concat name
" " "reverse slant")))))
980 (defvar charset-script-alist
982 (latin-iso8859-1 . latin
)
983 (latin-iso8859-2 . latin
)
984 (latin-iso8859-3 . latin
)
985 (latin-iso8859-4 . latin
)
986 (latin-iso8859-9 . latin
)
987 (latin-iso8859-10 . latin
)
988 (latin-iso8859-13 . latin
)
989 (latin-iso8859-14 . latin
)
990 (latin-iso8859-15 . latin
)
991 (latin-iso8859-16 . latin
)
992 (latin-jisx0201 . latin
)
994 (cyrillic-iso8859-5 . cyrillic
)
995 (arabic-iso8859-6 . arabic
)
996 (greek-iso8859-7 . latin
)
997 (hebrew-iso8859-8 . latin
)
998 (katakana-jisx0201 . kana
)
999 (chinese-gb2312 . han
)
1001 (gb18030-2-byte . han
)
1002 (gb18030-4-byte-bmp . han
)
1003 (gb18030-4-byte-ext-1 . han
)
1004 (gb18030-4-byte-ext-2 . han
)
1005 (gb18030-4-byte-smp . han
)
1006 (chinese-big5-1 . han
)
1007 (chinese-big5-2 . han
)
1008 (chinese-cns11643-1 . han
)
1009 (chinese-cns11643-2 . han
)
1010 (chinese-cns11643-3 . han
)
1011 (chinese-cns11643-4 . han
)
1012 (chinese-cns11643-5 . han
)
1013 (chinese-cns11643-6 . han
)
1014 (chinese-cns11643-7 . han
)
1015 (japanese-jisx0208 . han
)
1016 (japanese-jisx0208-1978 . han
)
1017 (japanese-jisx0212 . han
)
1018 (japanese-jisx0213-1 . han
)
1019 (japanese-jisx0213-2 . han
)
1020 (korean-ksc5601 . hangul
)
1021 (chinese-sisheng . bopomofo
)
1022 (vietnamese-viscii-lower . latin
)
1023 (vietnamese-viscii-upper . latin
)
1024 (arabic-digit . arabic
)
1025 (arabic-1-column . arabic
)
1026 (arabic-2-column . arabic
)
1027 (indian-is13194 . devanagari
)
1028 (indian-glyph . devanagari
)
1029 (indian-1-column . devanagari
)
1030 (indian-2-column . devanagari
)
1031 (tibetan-1-column . tibetan
))
1032 "Alist of charsets vs the corresponding most appropriate scripts.
1034 This alist is used by the function `create-fontset-from-fontset-spec'
1035 to map charsets to scripts.")
1037 (defun create-fontset-from-fontset-spec (fontset-spec
1038 &optional style-variant noerror
)
1039 "Create a fontset from fontset specification string FONTSET-SPEC.
1040 FONTSET-SPEC is a string of the format:
1041 FONTSET-NAME,SCRIPT-NAME0:FONT-NAME0,SCRIPT-NAME1:FONT-NAME1, ...
1042 Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
1044 When a frame uses the fontset as the `font' parameter, the frame's
1045 default font name is derived from FONTSET-NAME by substituting
1046 \"iso8859-1\" for the tail part \"fontset-XXX\". But, if SCRIPT-NAMEn
1047 is \"ascii\", use the corresponding FONT-NAMEn as the default font
1050 Optional 2nd and 3rd arguments exist just for backward compatibility,
1053 It returns a name of the created fontset.
1055 For backward compatibility, SCRIPT-NAME may be a charset name, in
1056 which case, the corresponding script is decided by the variable
1057 `charset-script-alist' (which see)."
1058 (or (string-match "^[^,]+" fontset-spec
)
1059 (error "Invalid fontset spec: %s" fontset-spec
))
1060 (let ((idx (match-end 0))
1061 (name (match-string 0 fontset-spec
))
1062 default-spec target script fontlist
)
1063 (or (string-match xlfd-tight-regexp name
)
1064 (error "Fontset name \"%s\" not conforming to XLFD" name
))
1065 (setq default-spec
(font-spec :name name
))
1066 ;; At first, extract pairs of charset and fontname from FONTSET-SPEC.
1067 (while (string-match "[, \t\n]*\\([^:]+\\):[ \t]*\\([^,]+\\)"
1069 (setq idx
(match-end 0))
1070 (setq target
(intern (match-string 1 fontset-spec
)))
1071 (cond ((or (eq target
'ascii
)
1072 (memq target
(char-table-extra-slot char-script-table
0)))
1073 (push (list target
(match-string 2 fontset-spec
)) fontlist
))
1074 ((setq script
(cdr (assq target charset-script-alist
)))
1075 (push (list script
(match-string 2 fontset-spec
)) fontlist
))
1077 (push (list target
(match-string 2 fontset-spec
)) fontlist
))))
1079 ;; Complement FONTLIST.
1080 (setq fontlist
(x-complement-fontset-spec default-spec fontlist
))
1082 ;; Create a fontset.
1083 (new-fontset name
(nreverse fontlist
))))
1085 (defun create-fontset-from-ascii-font (font &optional resolved-font
1087 "Create a fontset from an ASCII font FONT.
1089 Optional 2nd arg RESOLVED-FONT is a resolved name of FONT.
1090 If omitted, `x-resolve-font-name' is called to get the resolved name.
1091 At this time, if FONT is not available, an error is signaled.
1093 Optional 3rd arg FONTSET-NAME is a string to be used in
1094 `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
1095 an appropriate name is generated automatically.
1097 It returns a name of the created fontset."
1098 (setq font
(downcase font
))
1100 (downcase (or resolved-font
(x-resolve-font-name font
))))
1101 (let ((xlfd (x-decompose-font-name resolved-font
))
1104 (setq fontset-name
(downcase fontset-name
))
1105 (if (query-fontset "fontset-startup")
1107 (subst-char-in-string
1108 ?- ?_
(aref xlfd xlfd-regexp-registry-subnum
) t
))
1109 (setq fontset-name
"startup")))
1110 (aset xlfd xlfd-regexp-registry-subnum
1111 (format "fontset-%s" fontset-name
))
1112 (setq fontset
(x-compose-font-name xlfd
))
1113 (or (query-fontset fontset
)
1114 (create-fontset-from-fontset-spec (concat fontset
", ascii:" font
)))))
1117 ;; Create standard fontset from 16 dots fonts which are the most widely
1118 ;; installed fonts. Fonts for Chinese-GB, Korean, and Chinese-CNS are
1119 ;; specified here because FAMILY of those fonts are not "fixed" in
1121 (defvar standard-fontset-spec
1122 (purecopy "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard")
1123 "String of fontset spec of the standard fontset.
1124 You have the biggest chance to display international characters
1125 with correct glyphs by using the standard fontset.
1126 See the documentation of `create-fontset-from-fontset-spec' for the format.")
1129 ;; Create fontsets from X resources of the name `fontset-N (class
1130 ;; Fontset-N)' where N is integer 0, 1, ...
1131 ;; The values of the resources the string of the same format as
1132 ;; `standard-fontset-spec'.
1134 (declare-function x-get-resource
"frame.c"
1135 (attribute class
&optional component subclass
))
1137 (defun create-fontset-from-x-resource ()
1140 (while (setq fontset-spec
(x-get-resource (format "fontset-%d" idx
)
1141 (format "Fontset-%d" idx
)))
1143 (create-fontset-from-fontset-spec fontset-spec t
)
1144 (error (display-warning
1146 (format "Fontset-%d: invalid specification in X resource" idx
)
1148 (setq idx
(1+ idx
)))))
1153 ;; arch-tag: bb53e629-0234-403c-950e-551e61554849
1154 ;;; fontset.el ends here