Line data Source code
1 : ;;; fontset.el --- commands for handling fontset
2 :
3 : ;; Copyright (C) 1997-2017 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
11 :
12 : ;; Keywords: mule, i18n, fontset
13 :
14 : ;; This file is part of GNU Emacs.
15 :
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.
20 :
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.
25 :
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/>.
28 :
29 : ;;; Commentary:
30 :
31 : ;;; Code:
32 :
33 : ;; Setup font-encoding-alist for all known encodings.
34 :
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 : ("ksx1001" . korean-ksc5601)
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))))
122 :
123 : (defvar font-encoding-charset-alist)
124 :
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)))
147 :
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 : (vai #xA500)
157 : (arabic #x628)
158 : (syriac #x710)
159 : (thaana #x78C)
160 : (devanagari #x915)
161 : (bengali #x995)
162 : (gurmukhi #xA15)
163 : (gujarati #xA95)
164 : (oriya #xB15)
165 : (tamil #xB95)
166 : (telugu #xC15)
167 : (kannada #xC95)
168 : (malayalam #xD15)
169 : (sinhala #xD95)
170 : (thai #xE17)
171 : (lao #xEA5)
172 : (tibetan #xF40)
173 : (burmese #x1000)
174 : (georgian #x10D3)
175 : (ethiopic #x1208)
176 : (cherokee #x13B6)
177 : (canadian-aboriginal #x14C0)
178 : (ogham #x168F)
179 : (runic #x16A0)
180 : (khmer #x1780)
181 : (mongolian #x1826)
182 : (symbol . [#x201C #x2200 #x2500])
183 : (braille #x2800)
184 : (ideographic-description #x2FF0)
185 : (cjk-misc #x300E)
186 : (kana #x304B)
187 : (bopomofo #x3105)
188 : (kanbun #x319D)
189 : (han #x5B57)
190 : (yi #xA288)
191 : (cham #xAA00)
192 : (tai-viet #xAA80)
193 : (hangul #xAC00)
194 : (linear-b #x10000)
195 : (aegean-number #x10100)
196 : (ancient-greek-number #x10140)
197 : (ancient-symbol #x10190)
198 : (phaistos-disc #x101D0)
199 : (lycian #x10280)
200 : (carian #x102A0)
201 : (old-italic #x10300)
202 : (ugaritic #x10380)
203 : (old-permic #x10350)
204 : (old-persian #x103A0)
205 : (deseret #x10400)
206 : (shavian #x10450)
207 : (osmanya #x10480)
208 : (osage #x104B0)
209 : (elbasan #x10500)
210 : (caucasian-albanian #x10530)
211 : (linear-a #x10600)
212 : (cypriot-syllabary #x10800)
213 : (palmyrene #x10860)
214 : (nabataean #x10880)
215 : (phoenician #x10900)
216 : (lydian #x10920)
217 : (kharoshthi #x10A00)
218 : (manichaean #x10AC0)
219 : (mahajani #x11150)
220 : (sinhala-archaic-number #x111E1)
221 : (khojki #x11200)
222 : (khudawadi #x112B0)
223 : (grantha #x11305)
224 : (newa #x11400)
225 : (tirhuta #x11481)
226 : (siddham #x11580)
227 : (modi #x11600)
228 : (takri #x11680)
229 : (warang-citi #x118A1)
230 : (zanabazar-square #x11A00)
231 : (soyombo #x11A50)
232 : (pau-cin-hau #x11AC0)
233 : (bhaiksuki #x11C00)
234 : (marchen #x11C72)
235 : (masaram-gondi #x11D00)
236 : (cuneiform #x12000)
237 : (cuneiform-numbers-and-punctuation #x12400)
238 : (mro #x16A40)
239 : (bassa-vah #x16AD0)
240 : (pahawh-hmong #x16B11)
241 : (tangut #x17000)
242 : (tangut-components #x18800)
243 : (nushu #x1B170)
244 : (duployan-shorthand #x1BC20)
245 : (byzantine-musical-symbol #x1D000)
246 : (musical-symbol #x1D100)
247 : (ancient-greek-musical-notation #x1D200)
248 : (tai-xuan-jing-symbol #x1D300)
249 : (counting-rod-numeral #x1D360)
250 : (mende-kikakui #x1E810)
251 : (adlam #x1E900)
252 : (mahjong-tile #x1F000)
253 : (domino-tile #x1F030)))
254 :
255 : (defvar otf-script-alist)
256 :
257 : ;; The below was synchronized with the latest Feb 25, 2016 version of
258 : ;; https://www.microsoft.com/typography/otspec/scripttags.htm.
259 : (setq otf-script-alist
260 : '((adlm . adlam)
261 : (ahom . ahom)
262 : (hluw . anatolian)
263 : (arab . arabic)
264 : (armi . aramaic)
265 : (armn . armenian)
266 : (avst . avestan)
267 : (bali . balinese)
268 : (bamu . bamum)
269 : (bass . bassa-vah)
270 : (batk . batak)
271 : (bng2 . bengali)
272 : (beng . bengali)
273 : (bhks . bhaiksuki)
274 : (bopo . bopomofo)
275 : (brah . brahmi)
276 : (brai . braille)
277 : (bugi . buginese)
278 : (buhd . buhid)
279 : (byzm . byzantine-musical-symbol)
280 : (cans . canadian-aboriginal)
281 : (cari . carian)
282 : (aghb . caucasian-albanian)
283 : (cakm . chakma)
284 : (cham . cham)
285 : (cher . cherokee)
286 : (copt . coptic)
287 : (xsux . cuneiform)
288 : (cprt . cypriot)
289 : (cyrl . cyrillic)
290 : (dsrt . deseret)
291 : (deva . devanagari)
292 : (dev2 . devanagari)
293 : (dupl . duployan-shorthand)
294 : (egyp . egyptian)
295 : (elba . elbasan)
296 : (ethi . ethiopic)
297 : (geor . georgian)
298 : (glag . glagolitic)
299 : (goth . gothic)
300 : (gran . grantha)
301 : (grek . greek)
302 : (gujr . gujarati)
303 : (gjr2 . gujarati)
304 : (guru . gurmukhi)
305 : (gur2 . gurmukhi)
306 : (hani . han)
307 : (hang . hangul)
308 : (jamo . hangul)
309 : (hano . hanunoo)
310 : (hatr . hatran)
311 : (hebr . hebrew)
312 : (phli . inscriptional-pahlavi)
313 : (prti . inscriptional-parthian)
314 : (java . javanese)
315 : (kthi . kaithi)
316 : (kana . kana) ; Hiragana
317 : (knda . kannada)
318 : (knd2 . kannada)
319 : (kali . kayah-li)
320 : (khar . kharoshthi)
321 : (khmr . khmer)
322 : (khoj . khojki)
323 : (sind . khudawadi)
324 : (lao\ . lao)
325 : (latn . latin)
326 : (lepc . lepcha)
327 : (limb . limbu)
328 : (lina . linear_a)
329 : (linb . linear_b)
330 : (lisu . lisu)
331 : (lyci . lycian)
332 : (lydi . lydian)
333 : (mahj . mahajani)
334 : (marc . marchen)
335 : (mlym . malayalam)
336 : (mlm2 . malayalam)
337 : (mand . mandaic)
338 : (mani . manichaean)
339 : (math . mathematical)
340 : (mtei . meetei-mayek)
341 : (mend . mende-kikakui)
342 : (merc . meroitic)
343 : (mero . meroitic)
344 : (plrd . miao)
345 : (modi . modi)
346 : (mong . mongolian)
347 : (mroo . mro)
348 : (mult . multani)
349 : (musc . musical-symbol)
350 : (mym2 . burmese)
351 : (mymr . burmese)
352 : (nbat . nabataean)
353 : (newa . newa)
354 : (nko\ . nko)
355 : (ogam . ogham)
356 : (olck . ol-chiki)
357 : (ital . old_italic)
358 : (xpeo . old_persian)
359 : (narb . old-north-arabian)
360 : (perm . old-permic)
361 : (sarb . old-south-arabian)
362 : (orkh . old-turkic)
363 : (orya . oriya)
364 : (ory2 . oriya)
365 : (osge . osage)
366 : (osma . osmanya)
367 : (hmng . pahawh-hmong)
368 : (palm . palmyrene)
369 : (pauc . pau-cin-hau)
370 : (phag . phags-pa)
371 : (phli . inscriptional-pahlavi)
372 : (phnx . phoenician)
373 : (phlp . psalter-pahlavi)
374 : (prti . inscriptional-parthian)
375 : (rjng . rejang)
376 : (runr . runic)
377 : (samr . samaritan)
378 : (saur . saurashtra)
379 : (shrd . sharada)
380 : (shaw . shavian)
381 : (sidd . siddham)
382 : (sgnw . sutton-sign-writing)
383 : (sinh . sinhala)
384 : (sora . sora-sompeng)
385 : (sund . sundanese)
386 : (sylo . syloti_nagri)
387 : (syrc . syriac)
388 : (tglg . tagalog)
389 : (tagb . tagbanwa)
390 : (tale . tai_le)
391 : (talu . tai-lue)
392 : (lana . tai-tham)
393 : (tavt . tai-viet)
394 : (takr . takri)
395 : (taml . tamil)
396 : (tml2 . tamil)
397 : (tang . tangut)
398 : (telu . telugu)
399 : (tel2 . telugu)
400 : (thaa . thaana)
401 : (thai . thai)
402 : (tibt . tibetan)
403 : (tfng . tifinagh)
404 : (tirh . tirhuta)
405 : (ugar . ugaritic)
406 : (vai\ . vai)
407 : (wara . warang-citi)
408 : (yi\ \ . yi)))
409 :
410 : ;; Set standard fontname specification of characters in the default
411 : ;; fontset to find an appropriate font for each script/charset. The
412 : ;; specification has the form ((SCRIPT FONT-SPEC ...) ...), where
413 : ;; FONT-SPEC is:
414 : ;; a cons (FAMILY . REGISTRY),
415 : ;; or a string FONT-NAME,
416 : ;; or an object created by `font-spec'.
417 : ;;
418 : ;; FAMILY may be nil, in which case, the corresponding name of
419 : ;; default face is used. If REGISTRY contains a character `-', the
420 : ;; string before that is embedded in `CHARSET_REGISTRY' field, and the
421 : ;; string after that is embedded in `CHARSET_ENCODING' field. If it
422 : ;; does not contain `-', the whole string is embedded in
423 : ;; `CHARSET_REGISTRY' field, and a wild card character `*' is embedded
424 : ;; in `CHARSET_ENCODING' field.
425 : ;;
426 : ;; SCRIPT is a symbol that appears as an element of the char table
427 : ;; `char-script-table'. SCRIPT may be a charset specifying the range
428 : ;; of characters.
429 :
430 : (declare-function new-fontset "fontset.c" (name fontlist))
431 : (declare-function set-fontset-font "fontset.c"
432 : (name target font-spec &optional frame add))
433 :
434 : (eval-when-compile
435 :
436 : ;; Build data to initialize the default fontset at compile time to
437 : ;; avoid loading charsets that won't be necessary at runtime.
438 :
439 : ;; The value is (CJK-REGISTRY-VECTOR TARGET-SPEC ...), where
440 : ;; CJK-REGISTRY-VECTOR is ["JISX0208.1983-0" "GB2312.1980-0" ...],
441 : ;; TARGET-SPEC is (TARGET . BITMASK) or (TARGET SPEC ...),
442 : ;; TARGET is CHAR or (FROM-CHAR . TO-CHAR),
443 : ;; BITMASK is a bitmask of indices to CJK-REGISTRY-VECTOR,
444 : ;; SPEC is a list of arguments to font-spec.
445 :
446 : (defmacro build-default-fontset-data ()
447 : (let* (;; CHARSET-REGISTRY CHARSET FROM-CODE TO-CODE
448 : (cjk '(("JISX0208.1983-0" japanese-jisx0208 #x2121 #x287E)
449 : ("GB2312.1980-0" chinese-gb2312 #x2121 #x297E)
450 : ("BIG5-0" big5 #xA140 #xA3FE)
451 : ("CNS11643.1992-1" chinese-cns11643-1 #x2121 #x427E)
452 : ("KSC5601.1987-0" korean-ksc5601 #x2121 #x2C7E)))
453 : (scripts '((tibetan
454 : (:registry "iso10646-1" :otf (tibt nil (ccmp blws abvs)))
455 : (:family "mtib" :registry "iso10646-1")
456 : (:registry "muletibetan-2"))
457 : (ethiopic
458 : (:registry "iso10646-1" :script ethiopic)
459 : (:registry "ethiopic-unicode"))
460 : (phonetic
461 : (:registry "iso10646-1" :script phonetic)
462 : (:registry "MuleIPA-1")
463 : (:registry "iso10646-1"))))
464 : (cjk-table (make-char-table nil))
465 : (script-coverage
466 : #'(lambda (script)
467 : (let ((coverage))
468 : (map-char-table
469 : #'(lambda (range val)
470 : (when (eq val script)
471 : (if (consp range)
472 : (setq range (cons (car range) (cdr range))))
473 : (push range coverage)))
474 : char-script-table)
475 : coverage)))
476 : (data (list (vconcat (mapcar 'car cjk))))
477 : (i 0))
478 : (dolist (elt cjk)
479 : (let ((mask (lsh 1 i)))
480 : (map-charset-chars
481 : #'(lambda (range _arg)
482 : (let ((from (car range)) (to (cdr range)))
483 : (if (< to #x110000)
484 : (while (<= from to)
485 : (or (memq (aref char-script-table from)
486 : '(kana hangul han cjk-misc))
487 : (aset cjk-table from
488 : (logior (or (aref cjk-table from) 0) mask)))
489 : (setq from (1+ from))))))
490 : (nth 1 elt) nil (nth 2 elt) (nth 3 elt)))
491 : (setq i (1+ i)))
492 : (map-char-table
493 : #'(lambda (range val)
494 : (if (consp range)
495 : (setq range (cons (car range) (cdr range))))
496 : (push (cons range val) data))
497 : cjk-table)
498 : (dolist (script scripts)
499 : (dolist (range (funcall script-coverage (car script)))
500 : (push (cons range (cdr script)) data)))
501 : `(quote ,(nreverse data))))
502 : )
503 :
504 : (defun setup-default-fontset ()
505 : "Setup the default fontset."
506 0 : (new-fontset
507 : "fontset-default"
508 0 : `(;; for each script
509 : (latin (nil . "ISO8859-1")
510 : (nil . "ISO8859-2")
511 : (nil . "ISO8859-3")
512 : (nil . "ISO8859-4")
513 : (nil . "ISO8859-9")
514 : (nil . "ISO8859-10")
515 : (nil . "ISO8859-13")
516 : (nil . "ISO8859-14")
517 : (nil . "ISO8859-15")
518 : (nil . "ISO8859-16")
519 : (nil . "VISCII1.1-1")
520 0 : ,(font-spec :registry "iso10646-1" :script 'latin))
521 :
522 0 : (thai ,(font-spec :registry "iso10646-1" :otf '(thai nil nil (mark)))
523 0 : ,(font-spec :registry "iso10646-1" :script 'thai)
524 : (nil . "TIS620*")
525 : (nil . "ISO8859-11"))
526 :
527 0 : (devanagari ,(font-spec :registry "iso10646-1" :otf '(dev2 nil (rphf)))
528 0 : ,(font-spec :registry "iso10646-1" :otf '(deva nil (rphf)))
529 : (nil . "iso10646.indian-1"))
530 0 : (bengali ,(font-spec :registry "iso10646-1" :otf '(bng2 nil (rphf)))
531 0 : ,(font-spec :registry "iso10646-1" :otf '(beng nil (rphf))))
532 0 : (gurmukhi ,(font-spec :registry "iso10646-1" :otf '(gur2 nil (blwf)))
533 0 : ,(font-spec :registry "iso10646-1" :otf '(guru nil (blwf))))
534 0 : (gujarati ,(font-spec :registry "iso10646-1" :otf '(gjr2 nil (rphf)))
535 0 : ,(font-spec :registry "iso10646-1" :otf '(gujr nil (rphf))))
536 0 : (oriya ,(font-spec :registry "iso10646-1" :otf '(ory2 nil (rphf)))
537 0 : ,(font-spec :registry "iso10646-1" :otf '(orya nil (rphf))))
538 0 : (tamil ,(font-spec :registry "iso10646-1" :otf '(tml2 nil (akhn)))
539 0 : ,(font-spec :registry "iso10646-1" :otf '(taml nil (akhn))))
540 0 : (telugu ,(font-spec :registry "iso10646-1" :otf '(tel2 nil (blwf)))
541 0 : ,(font-spec :registry "iso10646-1" :otf '(telu nil (blwf))))
542 0 : (kannada ,(font-spec :registry "iso10646-1" :otf '(knd2 nil (rphf)))
543 0 : ,(font-spec :registry "iso10646-1" :otf '(knda nil (rphf))))
544 0 : (sinhala ,(font-spec :registry "iso10646-1" :otf '(sinh nil (akhn))))
545 0 : (malayalam ,(font-spec :registry "iso10646-1" :otf '(mlm2 nil (akhn)))
546 0 : ,(font-spec :registry "iso10646-1" :otf '(mlym nil (akhn))))
547 :
548 0 : (burmese ,(font-spec :registry "iso10646-1" :otf '(mym2 nil nil))
549 0 : ,(font-spec :registry "iso10646-1" :otf '(mymr nil nil))
550 0 : ,(font-spec :registry "iso10646-1" :script 'burmese))
551 :
552 0 : (lao ,(font-spec :registry "iso10646-1" :otf '(lao\ nil nil (mark)))
553 0 : ,(font-spec :registry "iso10646-1" :script 'lao)
554 : (nil . "MuleLao-1"))
555 :
556 : (tai-viet ("TaiViet" . "iso10646-1"))
557 :
558 0 : (greek ,(font-spec :registry "iso10646-1" :script 'greek)
559 : (nil . "ISO8859-7"))
560 :
561 0 : (cyrillic ,(font-spec :registry "iso10646-1" :script 'cyrillic)
562 : (nil . "ISO8859-5")
563 : (nil . "microsoft-cp1251")
564 : (nil . "koi8-r"))
565 :
566 0 : (arabic ,(font-spec :registry "iso10646-1"
567 0 : :otf '(arab nil (init medi fina liga)))
568 : (nil . "MuleArabic-0")
569 : (nil . "MuleArabic-1")
570 : (nil . "MuleArabic-2")
571 : (nil . "ISO8859-6"))
572 :
573 0 : (hebrew ,(font-spec :registry "iso10646-1" :script 'hebrew)
574 : (nil . "ISO8859-8"))
575 :
576 0 : (khmer ,(font-spec :registry "iso10646-1" :otf '(khmr nil (pres))))
577 :
578 : (kana (nil . "JISX0208*")
579 : (nil . "GB2312.1980-0")
580 : (nil . "KSC5601.1987*")
581 : (nil . "JISX0201*")
582 : (nil . "JISX0213.2000-1")
583 : (nil . "JISX0213.2004-1")
584 0 : ,(font-spec :registry "iso10646-1" :script 'kana))
585 :
586 0 : (bopomofo ,(font-spec :registry "iso10646-1" :script 'bopomofo)
587 : (nil . "sisheng_cwnn-0"))
588 :
589 : (han (nil . "GB2312.1980-0")
590 : (nil . "JISX0208*")
591 : (nil . "JISX0212*")
592 : (nil . "big5*")
593 : (nil . "KSC5601.1987*")
594 : (nil . "CNS11643.1992-1")
595 : (nil . "CNS11643.1992-2")
596 : (nil . "CNS11643.1992-3")
597 : (nil . "CNS11643.1992-4")
598 : (nil . "CNS11643.1992-5")
599 : (nil . "CNS11643.1992-6")
600 : (nil . "CNS11643.1992-7")
601 : (nil . "gbk-0")
602 : (nil . "gb18030")
603 : (nil . "JISX0213.2000-1")
604 : (nil . "JISX0213.2000-2")
605 : (nil . "JISX0213.2004-1")
606 0 : ,(font-spec :registry "iso10646-1" :lang 'ja)
607 0 : ,(font-spec :registry "iso10646-1" :lang 'zh))
608 :
609 : (cjk-misc (nil . "GB2312.1980-0")
610 : (nil . "JISX0208*")
611 : (nil . "JISX0212*")
612 : (nil . "big5*")
613 : (nil . "KSC5601.1987*")
614 : (nil . "CNS11643.1992-1")
615 : (nil . "CNS11643.1992-2")
616 : (nil . "CNS11643.1992-3")
617 : (nil . "CNS11643.1992-4")
618 : (nil . "CNS11643.1992-5")
619 : (nil . "CNS11643.1992-6")
620 : (nil . "CNS11643.1992-7")
621 : (nil . "gbk-0")
622 : (nil . "gb18030")
623 : (nil . "JISX0213.2000-1")
624 : (nil . "JISX0213.2000-2")
625 0 : ,(font-spec :registry "iso10646-1" :lang 'ja)
626 0 : ,(font-spec :registry "iso10646-1" :lang 'zh))
627 :
628 : (hangul (nil . "KSC5601.1987-0")
629 0 : ,(font-spec :registry "iso10646-1" :lang 'ko))
630 :
631 : ;; for each charset
632 : (ascii (nil . "ISO8859-1"))
633 : (arabic-digit ("*" . "MuleArabic-0"))
634 : (arabic-1-column ("*" . "MuleArabic-1"))
635 : (arabic-2-column ("*" . "MuleArabic-2"))
636 : (indian-is13194 (nil . "is13194-devanagari"))
637 : (indian-1-column ("*" . "muleindian-2"))
638 : ;; Indian CDAC
639 : (devanagari-cdac (nil . "Devanagari-CDAC"))
640 : (sanskrit-cdac (nil . "Sanskrit-CDAC"))
641 : (bengali-cdac (nil . "Bengali-CDAC"))
642 : (assamese-cdac (nil . "Assamese-CDAC"))
643 : (punjabi-cdac (nil . "Punjabi-CDAC"))
644 : (gujarati-cdac (nil . "Gujarati-CDAC"))
645 : (oriya-cdac (nil . "Oriya-CDAC"))
646 : (tamil-cdac (nil . "Tamil-CDAC"))
647 : (telugu-cdac (nil . "Telugu-CDAC"))
648 : (kannada-cdac (nil . "Kannada-CDAC"))
649 : (malayalam-cdac (nil . "Malayalam-CDAC"))
650 : ;; Indian AKRUTI
651 : (devanagari-akruti (nil . "Devanagari-Akruti"))
652 : (bengali-akruti (nil . "Bengali-Akruti"))
653 : (punjabi-akruti (nil . "Punjabi-Akruti"))
654 : (gujarati-akruti (nil . "Gujarati-Akruti"))
655 : (oriya-akruti (nil . "Oriya-Akruti"))
656 : (tamil-akruti (nil . "Tamil-Akruti"))
657 : (telugu-akruti (nil . "Telugu-Akruti"))
658 : (kannada-akruti (nil . "Kannada-Akruti"))
659 : (malayalam-akruti (nil . "Malayalam-Akruti"))
660 :
661 : ;; Fallback fonts
662 : (nil (nil . "gb2312.1980")
663 : (nil . "gbk-0")
664 : (nil . "gb18030")
665 : (nil . "jisx0208")
666 : (nil . "ksc5601.1987")
667 : (nil . "CNS11643.1992-1")
668 : (nil . "CNS11643.1992-2")
669 : (nil . "CNS11643.1992-3")
670 : (nil . "CNS11643.1992-4")
671 : (nil . "CNS11643.1992-5")
672 : (nil . "CNS11643.1992-6")
673 : (nil . "CNS11643.1992-7")
674 : (nil . "big5")
675 : (nil . "jisx0213.2000-1")
676 : (nil . "jisx0213.2004-1")
677 : (nil . "jisx0212"))
678 0 : ))
679 :
680 : ;; For simple scripts
681 0 : (dolist (script '(phonetic
682 : armenian
683 : syriac
684 : thaana
685 : georgian
686 : cherokee
687 : canadian-aboriginal
688 : ogham
689 : runic
690 : symbol
691 : braille
692 : yi
693 : aegean-number
694 : ancient-greek-number
695 : ancient-symbol
696 : phaistos-disc
697 : lycian
698 : carian
699 : old-italic
700 : ugaritic
701 : old-persian
702 : deseret
703 : shavian
704 : osmanya
705 : cypriot-syllabary
706 : phoenician
707 : lydian
708 : kharoshthi
709 : cuneiform
710 : cuneiform-numbers-and-punctuation
711 : byzantine-musical-symbol
712 : musical-symbol
713 : ancient-greek-musical-notation
714 : tai-xuan-jing-symbol
715 : counting-rod-numeral
716 : mahjong-tile
717 : domino-tile))
718 0 : (set-fontset-font "fontset-default"
719 0 : script (font-spec :registry "iso10646-1" :script script)
720 0 : nil 'append))
721 :
722 : ;; Special settings for `MATHEMATICAL (U+1D400..U+1D7FF)'.
723 0 : (dolist (math-subgroup '((#x1D400 #x1D433 mathematical-bold)
724 : (#x1D434 #x1D467 mathematical-italic)
725 : (#x1D468 #x1D49B mathematical-bold-italic)
726 : (#x1D49C #x1D4CF mathematical-script)
727 : (#x1D4D0 #x1D503 mathematical-bold-script)
728 : (#x1D504 #x1D537 mathematical-fraktur)
729 : (#x1D538 #x1D56B mathematical-double-struck)
730 : (#x1D56C #x1D59F mathematical-bold-fraktur)
731 : (#x1D5A0 #x1D5D3 mathematical-sans-serif)
732 : (#x1D5D4 #x1D607 mathematical-sans-serif-bold)
733 : (#x1D608 #x1D63B mathematical-sans-serif-italic)
734 : (#x1D63C #x1D66F mathematical-sans-serif-bold-italic)
735 : (#x1D670 #x1D6A3 mathematical-monospace)
736 : (#x1D6A4 #x1D6A5 mathematical-italic)
737 : (#x1D6A8 #x1D6E1 mathematical-bold)
738 : (#x1D6E2 #x1D71B mathematical-italic)
739 : (#x1D71C #x1D755 mathematical-bold-italic)
740 : (#x1D756 #x1D78F mathematical-sans-serif-bold)
741 : (#x1D790 #x1D7C9 mathematical-sans-serif-bold-italic)
742 : (#x1D7CA #x1D7D7 mathematical-bold)
743 : (#x1D7D8 #x1D7E1 mathematical-double-struck)
744 : (#x1D7E2 #x1D7EB mathematical-sans-serif)
745 : (#x1D7EC #x1D7F5 mathematical-sans-serif-bold)
746 : (#x1D7F6 #x1D7FF mathematical-monospace)))
747 0 : (let ((slot (assq (nth 2 math-subgroup) script-representative-chars)))
748 0 : (if slot
749 0 : (if (vectorp (cdr slot))
750 0 : (setcdr slot (vconcat (cdr slot) (vector (car math-subgroup))))
751 0 : (setcdr slot (vector (cadr slot) (car math-subgroup))))
752 0 : (setq slot (list (nth 2 math-subgroup) (car math-subgroup)))
753 0 : (nconc script-representative-chars (list slot))))
754 0 : (set-fontset-font
755 : "fontset-default"
756 0 : (cons (car math-subgroup) (nth 1 math-subgroup))
757 0 : (font-spec :registry "iso10646-1" :script (nth 2 math-subgroup))))
758 :
759 : ;; Special setup for various symbols and punctuation characters
760 : ;; covered well by Symbola, excluding those covered well by popular
761 : ;; Unicode fonts. We exclude the latter because users don't like us
762 : ;; invading on their font setups where they have good support from
763 : ;; other fonts.
764 0 : (dolist (symbol-subgroup
765 : '((#x2000 . #x2012) ;; General Punctuation
766 : (#x2015 . #x2017)
767 : #x201F
768 : (#x2023 . #x202F)
769 : (#x2031 . #x2038)
770 : (#x203B . #x206F)
771 : (#x2070 . #x209F) ;; Superscripts and Subscripts
772 : (#x20B6 . #x20CF) ;; Currency Symbols
773 : (#x2100 . #x2121) ;; Letterlike Symbols
774 : (#x2123 . #x214F)
775 : (#x2150 . #x215A) ;; Number Forms
776 : (#x215F . #x218F)
777 : (#x2194 . #x21FF) ;; Arrows
778 : (#x2200 . #x2211) ;; Mathematical Operators
779 : (#x2213 . #x2247)
780 : (#x2249 . #x225F)
781 : (#x2261 . #x2263)
782 : (#x2266 . #x22FF)
783 : (#x2300 . #x2301) ;; Miscellaneous Technical
784 : (#x2303 . #x230F)
785 : (#x2311 . #x231F)
786 : (#x2322 . #x23FF)
787 : (#x2400 . #x243F) ;; Control Pictures
788 : (#x2440 . #x245F) ;; Optical Char Recognition
789 : (#x2460 . #x24FF) ;; Enclosed Alphanumerics
790 : (#x25A0 . #x25FF) ;; Geometric Shapes
791 : (#x2600 . #x265F) ;; Miscellaneous Symbols
792 : (#x2661 . #x2662)
793 : #x2664
794 : (#x2667 . #x2669)
795 : (#x266C . #x26FF)
796 : (#x2700 . #x27bF) ;; Dingbats
797 : (#x27C0 . #x27EF) ;; Misc Mathematical Symbols-A
798 : (#x27F0 . #x27FF) ;; Supplemental Arrows-A
799 : (#x2900 . #x297F) ;; Supplemental Arrows-B
800 : (#x2980 . #x29FF) ;; Misc Mathematical Symbols-B
801 : (#x2A00 . #x2AFF) ;; Suppl. Math Operators
802 : (#x2B00 . #x2BFF) ;; Misc Symbols and Arrows
803 : (#x2E00 . #x2E7F) ;; Supplemental Punctuation
804 : (#x4DC0 . #x4DFF) ;; Yijing Hexagram Symbols
805 : (#xFE10 . #xFE1F) ;; Vertical Forms
806 : (#x10100 . #x1013F) ;; Aegean Numbers
807 : (#x102E0 . #x102FF) ;; Coptic Epact Numbers
808 : (#x1D000 . #x1D0FF) ;; Byzantine Musical Symbols
809 : (#x1D200 . #x1D24F) ;; Ancient Greek Musical Notation
810 : (#x1F0A0 . #x1F0FF) ;; Playing Cards
811 : (#x1F100 . #x1F1FF) ;; Enclosed Alphanumeric Suppl
812 : (#x1F300 . #x1F5FF) ;; Misc Symbols and Pictographs
813 : (#x1F600 . #x1F64F) ;; Emoticons
814 : (#x1F650 . #x1F67F) ;; Ornamental Dingbats
815 : (#x1F680 . #x1F6FF) ;; Transport and Map Symbols
816 : (#x1F700 . #x1F77F) ;; Alchemical Symbols
817 : (#x1F780 . #x1F7FF) ;; Geometric Shapes Extended
818 : (#x1F800 . #x1F8FF))) ;; Supplemental Arrows-C
819 0 : (set-fontset-font "fontset-default" symbol-subgroup
820 0 : '("Symbola" . "iso10646-1") nil 'prepend))
821 : ;; Box Drawing and Block Elements
822 0 : (set-fontset-font "fontset-default" '(#x2500 . #x259F)
823 0 : '("FreeMono" . "iso10646-1") nil 'prepend)
824 :
825 : ;; Since standard-fontset-spec on X uses fixed-medium font, which
826 : ;; gets mapped to a iso8859-1 variant, we would like to prefer its
827 : ;; iso10646-1 variant for symbols, where the coverage is known to be
828 : ;; good.
829 0 : (dolist (symbol-subgroup
830 : '((#x2000 . #x206F) ;; General Punctuation
831 : (#x2070 . #x209F) ;; Superscripts and Subscripts
832 : (#x20A0 . #x20CF) ;; Currency Symbols
833 : (#x2150 . #x218F) ;; Number Forms
834 : (#x2190 . #x21FF) ;; Arrows
835 : (#x2200 . #x22FF) ;; Mathematical Operators
836 : (#x2300 . #x23FF) ;; Miscellaneous Technical
837 : (#x2400 . #x243F) ;; Control Pictures
838 : (#x2440 . #x245F) ;; Optical Char Recognition
839 : (#x2460 . #x24FF) ;; Enclosed Alphanumerics
840 : (#x2500 . #x257F) ;; Box Drawing
841 : (#x2580 . #x259F) ;; Block Elements
842 : (#x25A0 . #x25FF) ;; Geometric Shapes
843 : (#x2600 . #x2689) ;; Miscellaneous Symbols
844 : (#x2700 . #x27bF) ;; Dingbats
845 : (#x27F5 . #x27FF))) ;; Supplemental Arrows-A
846 0 : (set-fontset-font "fontset-default" symbol-subgroup
847 : "-*-fixed-medium-*-*-*-*-*-*-*-*-*-iso10646-1"
848 0 : nil 'prepend))
849 :
850 : ;; Append CJK fonts for characters other than han, kana, cjk-misc.
851 : ;; Append fonts for scripts whose name is also a charset name.
852 0 : (let* ((data (build-default-fontset-data))
853 0 : (registries (car data)))
854 0 : (dolist (target-spec (cdr data))
855 0 : (let ((target (car target-spec))
856 0 : (spec (cdr target-spec)))
857 0 : (if (integerp spec)
858 0 : (dotimes (i (length registries))
859 0 : (if (> (logand spec (lsh 1 i)) 0)
860 0 : (set-fontset-font "fontset-default" target
861 0 : (cons nil (aref registries i))
862 0 : nil 'append)))
863 0 : (dolist (args spec)
864 0 : (set-fontset-font "fontset-default" target
865 0 : (apply 'font-spec args) nil 'append))))))
866 :
867 : ;; Append Unicode fonts.
868 : ;; This may find fonts with more variants (bold, italic) but which
869 : ;; don't cover many characters.
870 0 : (set-fontset-font "fontset-default" nil
871 0 : '(nil . "iso10646-1") nil 'prepend)
872 : ;; These may find fonts that cover many characters but with fewer
873 : ;; variants.
874 0 : (set-fontset-font "fontset-default" nil
875 0 : '("gnu-unifont" . "iso10646-1") nil 'prepend)
876 0 : (set-fontset-font "fontset-default" nil
877 0 : '("mutt-clearlyu" . "iso10646-1") nil 'prepend)
878 0 : (set-fontset-font "fontset-default" '(#x20000 . #x2FFFF)
879 0 : '(nil . "unicode-sip"))
880 :
881 0 : (set-fontset-font "fontset-default" '(#xE000 . #xF8FF)
882 0 : '(nil . "iso10646-1"))
883 : ;; Don't try the fallback fonts even if no suitable font was found
884 : ;; by the above font-spec.
885 0 : (set-fontset-font "fontset-default" '(#xE000 . #xF8FF) nil nil 'append))
886 :
887 : (defun create-default-fontset ()
888 : "Create the default fontset.
889 : Internal use only. Should be called at startup time."
890 0 : (condition-case err
891 0 : (setup-default-fontset)
892 0 : (error (display-warning
893 : 'initialization
894 0 : (format "Creation of the default fontsets failed: %s" err)
895 0 : :error))))
896 :
897 : ;; These are the registered registries/encodings from
898 : ;; ftp://ftp.x.org/pub/DOCS/registry 2001/06/01
899 :
900 : ;; Name Reference
901 : ;; ---- ---------
902 : ;; "DEC" [27]
903 : ;; registry prefix
904 : ;; "DEC.CNS11643.1986-2" [53]
905 : ;; CNS11643 2-plane using the encoding
906 : ;; suggested in that standard
907 : ;; "DEC.DTSCS.1990-2" [54]
908 : ;; DEC Taiwan Supplemental Character Set
909 : ;; "fujitsu.u90x01.1991-0" [87]
910 : ;; "fujitsu.u90x03.1991-0" [87]
911 : ;; "GB2312.1980-0" [39],[12]
912 : ;; China (PRC) Hanzi, GL encoding
913 : ;; "GB2312.1980-1" [39]
914 : ;; (deprecated)
915 : ;; China (PRC) Hanzi, GR encoding
916 : ;; "HP-Arabic8" [36]
917 : ;; HPARABIC8 8-bit character set
918 : ;; "HP-East8" [36]
919 : ;; HPEAST8 8-bit character set
920 : ;; "HP-Greek8" [36]
921 : ;; HPGREEK8 8-bit character set
922 : ;; "HP-Hebrew8" [36]
923 : ;; HPHEBREW8 8-bit character set
924 : ;; "HP-Japanese15" [36]
925 : ;; HPJAPAN15 15-bit character set,
926 : ;; modified from industry de facto
927 : ;; standard Shift-JIS
928 : ;; "HP-Kana8" [36]
929 : ;; HPKANA8 8-bit character set
930 : ;; "HP-Korean15" [36]
931 : ;; HPKOREAN15 15-bit character set
932 : ;; "HP-Roman8" [36]
933 : ;; HPROMAN8 8-bit character set
934 : ;; "HP-SChinese15" [36]
935 : ;; HPSCHINA15 15-bit character set for
936 : ;; support of Simplified Chinese
937 : ;; "HP-TChinese15" [36]
938 : ;; HPTCHINA15 15-bit character set for
939 : ;; support of Traditional Chinese
940 : ;; "HP-Turkish8" [36]
941 : ;; HPTURKISH8 8-bit character set
942 : ;; "IPSYS" [59]
943 : ;; registry prefix
944 : ;; "IPSYS.IE-1" [59]
945 : ;; "ISO2022"<REG>"-"<ENC> [44]
946 : ;; "ISO646.1991-IRV" [107]
947 : ;; ISO 646 International Reference Version
948 : ;; "ISO8859-1" [15],[12]
949 : ;; ISO Latin alphabet No. 1
950 : ;; "ISO8859-2" [15],[12]
951 : ;; ISO Latin alphabet No. 2
952 : ;; "ISO8859-3" [15],[12]
953 : ;; ISO Latin alphabet No. 3
954 : ;; "ISO8859-4" [15],[12]
955 : ;; ISO Latin alphabet No. 4
956 : ;; "ISO8859-5" [15],[12]
957 : ;; ISO Latin/Cyrillic alphabet
958 : ;; "ISO8859-6" [15],[12]
959 : ;; ISO Latin/Arabic alphabet
960 : ;; "ISO8859-7" [15],[12]
961 : ;; ISO Latin/Greek alphabet
962 : ;; "ISO8859-8" [15],[12]
963 : ;; ISO Latin/Hebrew alphabet
964 : ;; "ISO8859-9" [15],[12]
965 : ;; ISO Latin alphabet No. 5
966 : ;; "ISO8859-10" [15],[12]
967 : ;; ISO Latin alphabet No. 6
968 : ;; "ISO8859-13" [15],[12]
969 : ;; ISO Latin alphabet No. 7
970 : ;; "ISO8859-14" [15],[12]
971 : ;; ISO Latin alphabet No. 8
972 : ;; "ISO8859-15" [15],[12]
973 : ;; ISO Latin alphabet No. 9
974 : ;; "FCD8859-15" [7]
975 : ;; (deprecated)
976 : ;; ISO Latin alphabet No. 9, Final Committee Draft
977 : ;; "ISO10646-1" [133]
978 : ;; Unicode Universal Multiple-Octet Coded Character Set
979 : ;; "ISO10646-MES" [133]
980 : ;; (deprecated)
981 : ;; Unicode Minimum European Subset
982 : ;; "JISX0201.1976-0" [38],[12]
983 : ;; 8-Bit Alphanumeric-Katakana Code
984 : ;; "JISX0208.1983-0" [40],[12]
985 : ;; Japanese Graphic Character Set,
986 : ;; GL encoding
987 : ;; "JISX0208.1990-0" [71]
988 : ;; Japanese Graphic Character Set,
989 : ;; GL encoding
990 : ;; "JISX0208.1983-1" [40]
991 : ;; (deprecated)
992 : ;; Japanese Graphic Character Set,
993 : ;; GR encoding
994 : ;; "JISX0212.1990-0" [72]
995 : ;; Supplementary Japanese Graphic Character Set,
996 : ;; GL encoding
997 : ;; "KOI8-R" [119]
998 : ;; Cyrillic alphabet
999 : ;; "KSC5601.1987-0" [41],[12]
1000 : ;; Korean Graphic Character Set,
1001 : ;; GL encoding
1002 : ;; "KSC5601.1987-1" [41]
1003 : ;; (deprecated)
1004 : ;; Korean Graphic Character Set,
1005 : ;; GR encoding
1006 : ;; "omron_CNS11643-0" [45]
1007 : ;; "omron_CNS11643-1" [45]
1008 : ;; "omron_BIG5-0" [45]
1009 : ;; "omron_BIG5-1" [45]
1010 : ;; "wn.tamil.1993" [103]
1011 :
1012 : (defun set-font-encoding (pattern charset)
1013 : "Set arguments in `font-encoding-alist' (which see)."
1014 0 : (let ((slot (assoc pattern font-encoding-alist)))
1015 0 : (if slot
1016 0 : (setcdr slot charset)
1017 0 : (setq font-encoding-alist
1018 0 : (cons (cons pattern charset) font-encoding-alist)))))
1019 :
1020 : (defvar x-pixel-size-width-font-regexp)
1021 : (defvar vertical-centering-font-regexp)
1022 :
1023 : ;; Setting for suppressing XLoadQueryFont on big fonts.
1024 : (setq x-pixel-size-width-font-regexp
1025 : (purecopy "gb2312\\|gbk\\|gb18030\\|jisx0208\\|ksc5601\\|cns11643\\|big5"))
1026 :
1027 : ;; These fonts require vertical centering.
1028 : (setq vertical-centering-font-regexp
1029 : (purecopy "gb2312\\|gbk\\|gb18030\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5"))
1030 : (put 'vertical-centering-font-regexp 'standard-value
1031 : (list vertical-centering-font-regexp))
1032 :
1033 : ;; CDAC fonts are actually smaller than their design sizes.
1034 : (setq face-font-rescale-alist
1035 : (list (cons (purecopy "-cdac$") 1.3)))
1036 :
1037 : (defvar x-font-name-charset-alist nil
1038 : "This variable has no meaning now. Just kept for backward compatibility.")
1039 :
1040 : ;;; XLFD (X Logical Font Description) format handler.
1041 :
1042 : ;; Define XLFD's field index numbers. ; field name
1043 : (defconst xlfd-regexp-family-subnum 0) ; FOUNDRY and FAMILY
1044 : (defconst xlfd-regexp-weight-subnum 1) ; WEIGHT_NAME
1045 : (defconst xlfd-regexp-slant-subnum 2) ; SLANT
1046 : (defconst xlfd-regexp-swidth-subnum 3) ; SETWIDTH_NAME
1047 : (defconst xlfd-regexp-adstyle-subnum 4) ; ADD_STYLE_NAME
1048 : (defconst xlfd-regexp-pixelsize-subnum 5) ; PIXEL_SIZE
1049 : (defconst xlfd-regexp-pointsize-subnum 6) ; POINT_SIZE
1050 : (defconst xlfd-regexp-resx-subnum 7) ; RESOLUTION_X
1051 : (defconst xlfd-regexp-resy-subnum 8) ; RESOLUTION_Y
1052 : (defconst xlfd-regexp-spacing-subnum 8) ; SPACING
1053 : (defconst xlfd-regexp-avgwidth-subnum 10) ; AVERAGE_WIDTH
1054 : (defconst xlfd-regexp-registry-subnum 11) ; REGISTRY and ENCODING
1055 :
1056 : ;; Regular expression matching against a fontname which conforms to
1057 : ;; XLFD (X Logical Font Description). All fields in XLFD should be
1058 : ;; not be omitted (but can be a wild card) to be matched.
1059 : (defconst xlfd-tight-regexp
1060 : "^\
1061 : -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
1062 : -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
1063 : -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*-[^-]*\\)$")
1064 :
1065 : ;; Regular expression matching against a fontname which conforms to
1066 : ;; XLFD (X Logical Font Description). All fields in XLFD from FOUNDRY
1067 : ;; to ADSTYLE, REGISTRY, and ENCODING should be not be omitted (but
1068 : ;; can be a wild card) to be matched.
1069 : (defconst xlfd-style-regexp
1070 : "^\
1071 : -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-.*\
1072 : -\\([^-]*-[^-]*\\)$")
1073 :
1074 : ;; List of field numbers of XLFD whose values are numeric.
1075 : (defconst xlfd-regexp-numeric-subnums
1076 : (list xlfd-regexp-pixelsize-subnum ;5
1077 : xlfd-regexp-pointsize-subnum ;6
1078 : xlfd-regexp-resx-subnum ;7
1079 : xlfd-regexp-resy-subnum ;8
1080 : xlfd-regexp-avgwidth-subnum ;10
1081 : ))
1082 :
1083 : (defun x-decompose-font-name (pattern)
1084 : "Decompose PATTERN into XLFD fields and return a vector of the fields.
1085 : The length of the vector is 12.
1086 : The FOUNDRY and FAMILY fields are concatenated and stored in the first
1087 : element of the vector.
1088 : The REGISTRY and ENCODING fields are concatenated and stored in the last
1089 : element of the vector.
1090 :
1091 : Return nil if PATTERN doesn't conform to XLFD."
1092 0 : (if (string-match xlfd-tight-regexp pattern)
1093 0 : (let ((xlfd-fields (make-vector 12 nil)))
1094 0 : (dotimes (i 12)
1095 0 : (aset xlfd-fields i (match-string (1+ i) pattern)))
1096 0 : (dotimes (i 12)
1097 0 : (if (string-match "^[*-]+$" (aref xlfd-fields i))
1098 0 : (aset xlfd-fields i nil)))
1099 0 : xlfd-fields)))
1100 :
1101 : (defun x-compose-font-name (fields &optional _reduce)
1102 : "Compose X fontname from FIELDS.
1103 : FIELDS is a vector of XLFD fields, of length 12.
1104 : If a field is nil, wild-card letter `*' is embedded.
1105 : Optional argument REDUCE exists just for backward compatibility,
1106 : and is always ignored."
1107 0 : (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-")))
1108 :
1109 :
1110 : (defun x-must-resolve-font-name (xlfd-fields)
1111 : "Like `x-resolve-font-name', but always return a font name.
1112 : XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
1113 : If no font matching XLFD-FIELDS is available, successively replace
1114 : parts of the font name pattern with \"*\" until some font is found.
1115 : Value is name of that font."
1116 0 : (let ((ascii-font nil) (index 0))
1117 0 : (while (and (null ascii-font) (<= index xlfd-regexp-registry-subnum))
1118 0 : (let ((pattern (x-compose-font-name xlfd-fields)))
1119 0 : (condition-case nil
1120 0 : (setq ascii-font (x-resolve-font-name pattern))
1121 : (error
1122 0 : (message "Warning: no fonts matching `%s' available" pattern)
1123 0 : (aset xlfd-fields index "*")
1124 0 : (setq index (1+ index))))))
1125 0 : (unless ascii-font
1126 0 : (error "No fonts found"))
1127 0 : ascii-font))
1128 :
1129 :
1130 : (defun x-complement-fontset-spec (default-spec fontlist)
1131 : "Complement elements of FONTLIST based on DEFAULT-SPEC.
1132 : DEFAULT-SPEC is a font-spec object providing default font properties.
1133 : FONTLIST is an alist of script names vs the corresponding font names.
1134 :
1135 : The font names are parsed and unspecified font properties are
1136 : given from DEFAULT-SPEC."
1137 0 : (let ((prop-list '(:foundry :family :weight :slant :width :adstyle :size)))
1138 0 : (dolist (elt fontlist)
1139 0 : (let ((spec (font-spec :name (cadr elt))))
1140 0 : (dolist (prop prop-list)
1141 0 : (let ((val (font-get spec prop)))
1142 0 : (or val
1143 0 : (font-put spec prop (font-get default-spec prop)))))
1144 0 : (setcar (cdr elt) spec)))
1145 0 : fontlist))
1146 :
1147 : (defun fontset-name-p (fontset)
1148 : "Return non-nil if FONTSET is valid as fontset name.
1149 : A valid fontset name should conform to XLFD (X Logical Font Description)
1150 : with \"fontset\" in `<CHARSET_REGISTRY>' field."
1151 0 : (and (string-match xlfd-tight-regexp fontset)
1152 0 : (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset)
1153 0 : "fontset")))
1154 :
1155 : (declare-function fontset-list "fontset.c" ())
1156 :
1157 : (defun generate-fontset-menu ()
1158 : "Return list to be appended to `x-fixed-font-alist'.
1159 : Done when `mouse-set-font' is called."
1160 0 : (let (l)
1161 0 : (dolist (fontset (fontset-list))
1162 0 : (or (string-match "fontset-default$" fontset)
1163 0 : (string-match "fontset-auto[0-9]+$" fontset)
1164 0 : (push (list (fontset-plain-name fontset) fontset) l)))
1165 0 : (cons "Fontset"
1166 0 : (sort l #'(lambda (x y) (string< (car x) (car y)))))))
1167 :
1168 : (declare-function query-fontset "fontset.c" (pattern &optional regexpp))
1169 :
1170 : (defun fontset-plain-name (fontset)
1171 : "Return a plain and descriptive name of FONTSET."
1172 0 : (if (not (setq fontset (query-fontset fontset)))
1173 0 : (error "Invalid fontset: %s" fontset))
1174 0 : (let ((xlfd-fields (x-decompose-font-name fontset)))
1175 0 : (if xlfd-fields
1176 0 : (let ((family (aref xlfd-fields xlfd-regexp-family-subnum))
1177 0 : (weight (aref xlfd-fields xlfd-regexp-weight-subnum))
1178 0 : (slant (aref xlfd-fields xlfd-regexp-slant-subnum))
1179 : ;(swidth (aref xlfd-fields xlfd-regexp-swidth-subnum))
1180 0 : (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum))
1181 0 : (nickname (aref xlfd-fields xlfd-regexp-registry-subnum))
1182 : name)
1183 0 : (if (not (string-match "^fontset-\\(.*\\)$" nickname))
1184 0 : (setq nickname family)
1185 0 : (setq nickname (match-string 1 nickname)))
1186 0 : (if (and size (> (string-to-number size) 0))
1187 0 : (setq name (format "%s: %s-dot" nickname size))
1188 0 : (setq name nickname))
1189 0 : (and weight
1190 0 : (cond ((string-match "^medium$" weight)
1191 0 : (setq name (concat name " " "medium")))
1192 0 : ((string-match "^bold$\\|^demibold$" weight)
1193 0 : (setq name (concat name " " weight)))))
1194 0 : (and slant
1195 0 : (cond ((string-match "^i$" slant)
1196 0 : (setq name (concat name " " "italic")))
1197 0 : ((string-match "^o$" slant)
1198 0 : (setq name (concat name " " "slant")))
1199 0 : ((string-match "^ri$" slant)
1200 0 : (setq name (concat name " " "reverse italic")))
1201 0 : ((string-match "^ro$" slant)
1202 0 : (setq name (concat name " " "reverse slant")))))
1203 0 : name)
1204 0 : fontset)))
1205 :
1206 : (defvar charset-script-alist
1207 : '((ascii . latin)
1208 : (latin-iso8859-1 . latin)
1209 : (latin-iso8859-2 . latin)
1210 : (latin-iso8859-3 . latin)
1211 : (latin-iso8859-4 . latin)
1212 : (latin-iso8859-9 . latin)
1213 : (latin-iso8859-10 . latin)
1214 : (latin-iso8859-13 . latin)
1215 : (latin-iso8859-14 . latin)
1216 : (latin-iso8859-15 . latin)
1217 : (latin-iso8859-16 . latin)
1218 : (latin-jisx0201 . latin)
1219 : (thai-tis620 . thai)
1220 : (cyrillic-iso8859-5 . cyrillic)
1221 : (arabic-iso8859-6 . arabic)
1222 : (greek-iso8859-7 . latin)
1223 : (hebrew-iso8859-8 . latin)
1224 : (katakana-jisx0201 . kana)
1225 : (chinese-gb2312 . han)
1226 : (chinese-gbk . han)
1227 : (gb18030-2-byte . han)
1228 : (gb18030-4-byte-bmp . han)
1229 : (gb18030-4-byte-ext-1 . han)
1230 : (gb18030-4-byte-ext-2 . han)
1231 : (gb18030-4-byte-smp . han)
1232 : (chinese-big5-1 . han)
1233 : (chinese-big5-2 . han)
1234 : (chinese-cns11643-1 . han)
1235 : (chinese-cns11643-2 . han)
1236 : (chinese-cns11643-3 . han)
1237 : (chinese-cns11643-4 . han)
1238 : (chinese-cns11643-5 . han)
1239 : (chinese-cns11643-6 . han)
1240 : (chinese-cns11643-7 . han)
1241 : (japanese-jisx0208 . han)
1242 : (japanese-jisx0208-1978 . han)
1243 : (japanese-jisx0212 . han)
1244 : (japanese-jisx0213-1 . han)
1245 : (japanese-jisx0213-2 . han)
1246 : (korean-ksc5601 . hangul)
1247 : (chinese-sisheng . bopomofo)
1248 : (vietnamese-viscii-lower . latin)
1249 : (vietnamese-viscii-upper . latin)
1250 : (arabic-digit . arabic)
1251 : (arabic-1-column . arabic)
1252 : (arabic-2-column . arabic)
1253 : (indian-is13194 . devanagari)
1254 : (indian-glyph . devanagari)
1255 : (indian-1-column . devanagari)
1256 : (indian-2-column . devanagari)
1257 : (tibetan-1-column . tibetan))
1258 : "Alist of charsets vs the corresponding most appropriate scripts.
1259 :
1260 : This alist is used by the function `create-fontset-from-fontset-spec'
1261 : to map charsets to scripts.")
1262 :
1263 : (defun create-fontset-from-fontset-spec (fontset-spec
1264 : &optional _style-variant _noerror)
1265 : "Create a fontset from fontset specification string FONTSET-SPEC.
1266 : FONTSET-SPEC is a string of the format:
1267 : FONTSET-NAME[,SCRIPT-NAME0:FONT-NAME0,SCRIPT-NAME1:FONT-NAME1] ...
1268 : Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
1269 :
1270 : When a frame uses the fontset as the `font' parameter, the frame's
1271 : default font name is derived from FONTSET-NAME by substituting
1272 : \"iso8859-1\" for the tail part \"fontset-XXX\". But, if SCRIPT-NAMEn
1273 : is \"ascii\", use the corresponding FONT-NAMEn as the default font
1274 : name.
1275 :
1276 : Optional 2nd and 3rd arguments exist just for backward compatibility,
1277 : and are ignored.
1278 :
1279 : It returns a name of the created fontset.
1280 :
1281 : For backward compatibility, SCRIPT-NAME may be a charset name, in
1282 : which case, the corresponding script is decided by the variable
1283 : `charset-script-alist' (which see)."
1284 0 : (or (string-match "^[^,]+" fontset-spec)
1285 0 : (error "Invalid fontset spec: %s" fontset-spec))
1286 0 : (let ((idx (match-end 0))
1287 0 : (name (match-string 0 fontset-spec))
1288 : default-spec target script fontlist)
1289 0 : (or (string-match xlfd-tight-regexp name)
1290 0 : (error "Fontset name \"%s\" not conforming to XLFD" name))
1291 0 : (setq default-spec (font-spec :name name))
1292 : ;; At first, extract pairs of charset and fontname from FONTSET-SPEC.
1293 0 : (while (string-match "[, \t\n]*\\([^:]+\\):[ \t]*\\([^,]+\\)"
1294 0 : fontset-spec idx)
1295 0 : (setq idx (match-end 0))
1296 0 : (setq target (intern (match-string 1 fontset-spec)))
1297 0 : (cond ((or (eq target 'ascii)
1298 0 : (memq target (char-table-extra-slot char-script-table 0)))
1299 0 : (push (list target (match-string 2 fontset-spec)) fontlist))
1300 0 : ((setq script (cdr (assq target charset-script-alist)))
1301 0 : (push (list script (match-string 2 fontset-spec)) fontlist))
1302 0 : ((charsetp target)
1303 0 : (push (list target (match-string 2 fontset-spec)) fontlist))))
1304 :
1305 : ;; Complement FONTLIST.
1306 0 : (setq fontlist (x-complement-fontset-spec default-spec fontlist))
1307 :
1308 : ;; Create a fontset.
1309 0 : (new-fontset name (nreverse fontlist))))
1310 :
1311 : (defun create-fontset-from-ascii-font (font &optional resolved-font
1312 : fontset-name)
1313 : "Create a fontset from an ASCII font FONT.
1314 :
1315 : Optional 2nd arg RESOLVED-FONT is a resolved name of FONT.
1316 : If omitted, `x-resolve-font-name' is called to get the resolved name.
1317 : At this time, if FONT is not available, an error is signaled.
1318 :
1319 : Optional 3rd arg FONTSET-NAME is a string to be used in
1320 : `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
1321 : an appropriate name is generated automatically.
1322 :
1323 : It returns a name of the created fontset."
1324 0 : (setq font (downcase font))
1325 0 : (setq resolved-font
1326 0 : (downcase (or resolved-font (x-resolve-font-name font))))
1327 0 : (let ((xlfd (x-decompose-font-name resolved-font))
1328 : fontset)
1329 0 : (if fontset-name
1330 0 : (setq fontset-name (downcase fontset-name))
1331 0 : (if (query-fontset "fontset-startup")
1332 0 : (setq fontset-name
1333 0 : (subst-char-in-string
1334 0 : ?- ?_ (aref xlfd xlfd-regexp-registry-subnum) t))
1335 0 : (setq fontset-name "startup")))
1336 0 : (aset xlfd xlfd-regexp-registry-subnum
1337 0 : (format "fontset-%s" fontset-name))
1338 0 : (setq fontset (x-compose-font-name xlfd))
1339 0 : (or (query-fontset fontset)
1340 0 : (create-fontset-from-fontset-spec (concat fontset ", ascii:" font)))))
1341 :
1342 :
1343 : ;; Create standard fontset from 16 dots fonts which are the most widely
1344 : ;; installed fonts. Fonts for Chinese-GB, Korean, and Chinese-CNS are
1345 : ;; specified here because FAMILY of those fonts are not "fixed" in
1346 : ;; many cases.
1347 : (defvar standard-fontset-spec
1348 : (purecopy "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard")
1349 : "String of fontset spec of the standard fontset.
1350 : You have the biggest chance to display international characters
1351 : with correct glyphs by using the standard fontset.
1352 : See the documentation of `create-fontset-from-fontset-spec' for the format.")
1353 :
1354 :
1355 : ;; Create fontsets from X resources of the name `fontset-N (class
1356 : ;; Fontset-N)' where N is integer 0, 1, ...
1357 : ;; The values of the resources the string of the same format as
1358 : ;; `standard-fontset-spec'.
1359 :
1360 : (declare-function x-get-resource "frame.c"
1361 : (attribute class &optional component subclass))
1362 :
1363 : (defun create-fontset-from-x-resource ()
1364 0 : (let ((idx 0)
1365 : fontset-spec)
1366 0 : (while (setq fontset-spec (x-get-resource (format "fontset-%d" idx)
1367 0 : (format "Fontset-%d" idx)))
1368 0 : (condition-case nil
1369 0 : (create-fontset-from-fontset-spec fontset-spec t)
1370 0 : (error (display-warning
1371 : 'initialization
1372 0 : (format "Fontset-%d: invalid specification in X resource" idx)
1373 0 : :warning)))
1374 0 : (setq idx (1+ idx)))))
1375 :
1376 : ;;
1377 : (provide 'fontset)
1378 :
1379 : ;;; fontset.el ends here
|