aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2009-08-27 06:26:43 +0000
committerKenichi Handa2009-08-27 06:26:43 +0000
commit726e3f1d5e05eebd0b347b72643743e1c07c641e (patch)
tree6be684a89c5eb5ceed6d8b34dab4f09e017c20e0
parentef73e7be7be86d7fed6b2c990fc278622162668d (diff)
downloademacs-726e3f1d5e05eebd0b347b72643743e1c07c641e.tar.gz
emacs-726e3f1d5e05eebd0b347b72643743e1c07c641e.zip
(build-default-fontset-data): New macro.
(setup-default-fontset): Use build-default-fontset-data for CJK, tibetan, ethiopic, and ipa
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/international/fontset.el110
2 files changed, 89 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 466d5da5c92..c8ac40269f4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12009-08-27 Kenichi Handa <handa@m17n.org>
2
3 * international/fontset.el (build-default-fontset-data): New macro.
4 (setup-default-fontset): Use build-default-fontset-data for CJK,
5 tibetan, ethiopic, and ipa
6
12009-08-27 Stefan Monnier <monnier@iro.umontreal.ca> 72009-08-27 Stefan Monnier <monnier@iro.umontreal.ca>
2 8
3 * cus-start.el (default-major-mode): Customize `major-mode' instead. 9 * cus-start.el (default-major-mode): Customize `major-mode' instead.
diff --git a/lisp/international/fontset.el b/lisp/international/fontset.el
index e2c6491d4af..f9d3c85125a 100644
--- a/lisp/international/fontset.el
+++ b/lisp/international/fontset.el
@@ -308,6 +308,74 @@
308(declare-function set-fontset-font "fontset.c" 308(declare-function set-fontset-font "fontset.c"
309 (name target font-spec &optional frame add)) 309 (name target font-spec &optional frame add))
310 310
311(eval-when-compile
312
313;; Build a data to initialize the default fontset at compile time to
314;; avoid loading charsets that won't be necessary at runtime.
315
316;; The value is (CJK-REGISTRY-VECTOR TARGET-SPEC ...), where
317;; CJK-REGISTRY-VECTOR is ["JISX0208.1983-0" "GB2312.1980-0" ...],
318;; TARGET-SPEC is (TARGET . BITMASK) or (TARGET SPEC ...),
319;; TARGET is CHAR or (FROM-CHAR . TO-CHAR),
320;; BITMASK is a bitmask of indices to CJK-REGISTRY-VECTOR,
321;; SPEC is a list of arguments to font-spec.
322
323(defmacro build-default-fontset-data ()
324 (let* (;; CHARSET-REGISTRY CHARSET FROM-CODE TO-CODE
325 (cjk '(("JISX0208.1983-0" japanese-jisx0208 #x2121 #x287E)
326 ("GB2312.1980-0" chinese-gb2312 #x2121 #x297E)
327 ("BIG5-0" big5 #xA140 #xA3FE)
328 ("CNS11643.1992-1" chinese-cns11643-1 #x2121 #x427E)
329 ("KSC5601.1987-0" korean-ksc5601 #x2121 #x2C7E)))
330 (scripts '((tibetan
331 (:registry "iso10646-1" :otf (tibt nil (ccmp blws abvs)))
332 (:family "mtib" :registry "iso10646-1")
333 (:registry "muletibetan-2"))
334 (ethiopic
335 (:registry "iso10646-1" :script ethiopic)
336 (:registry "ethiopic-unicode"))
337 (phonetic
338 (:registry "iso10646-1" :script phonetic)
339 (:registry "MuleIPA-1")
340 (:registry "iso10646-1"))))
341 (cjk-table (make-char-table nil))
342 (script-coverage
343 #'(lambda (script)
344 (let ((coverage))
345 (map-char-table
346 #'(lambda (range val)
347 (when (eq val script)
348 (if (consp range)
349 (setq range (cons (car range) (cdr range))))
350 (push range coverage)))
351 char-script-table)
352 coverage)))
353 (data (list (vconcat (mapcar 'car cjk))))
354 (i 0))
355 (dolist (elt cjk)
356 (let ((mask (lsh 1 i)))
357 (map-charset-chars
358 #'(lambda (range arg)
359 (let ((from (car range)) (to (cdr range)))
360 (if (< to #x110000)
361 (while (<= from to)
362 (aset cjk-table from
363 (logior (or (aref cjk-table from) 0) mask))
364 (setq from (1+ from))))))
365 (nth 1 elt) nil (nth 2 elt) (nth 3 elt)))
366 (setq i (1+ i)))
367 (map-char-table
368 #'(lambda (range val)
369 (if (consp range)
370 (setq range (cons (car range) (cdr range))))
371 (push (cons range val) data))
372 cjk-table)
373 (dolist (script scripts)
374 (dolist (range (funcall script-coverage (car script)))
375 (push (cons range (cdr script)) data)))
376 `(quote ,(nreverse data))))
377)
378
311(defun setup-default-fontset () 379(defun setup-default-fontset ()
312 "Setup the default fontset." 380 "Setup the default fontset."
313 (new-fontset 381 (new-fontset
@@ -349,16 +417,6 @@
349 417
350 (tai-viet ("TaiViet" . "iso10646-1")) 418 (tai-viet ("TaiViet" . "iso10646-1"))
351 419
352 ;; both for script and charset.
353 (tibetan ,(font-spec :registry "iso10646-1"
354 :otf '(tibt nil (ccmp blws abvs)))
355 ,(font-spec :family "mtib" :registry "iso10646-1")
356 (nil . "muletibetan-2"))
357
358 ;; both for script and charset.
359 (ethiopic ,(font-spec :registry "iso10646-1" :script 'ethiopic)
360 (nil . "ethiopic-unicode"))
361
362 (greek ,(font-spec :registry "iso10646-1" :script 'greek) 420 (greek ,(font-spec :registry "iso10646-1" :script 'greek)
363 (nil . "ISO8859-7")) 421 (nil . "ISO8859-7"))
364 422
@@ -461,11 +519,6 @@
461 (telugu-akruti (nil . "Telugu-Akruti")) 519 (telugu-akruti (nil . "Telugu-Akruti"))
462 (kannada-akruti (nil . "Kannada-Akruti")) 520 (kannada-akruti (nil . "Kannada-Akruti"))
463 (malayalam-akruti (nil . "Malayalam-Akruti")) 521 (malayalam-akruti (nil . "Malayalam-Akruti"))
464 ;;(devanagari-glyph ("altsys-dv_ttsurekh" . "devanagari-cdac"))
465 ;;(malayalam-glyph ("altsys-ml_ttkarthika" . "malayalam-cdac"))
466 (ipa ,(font-spec :registry "iso10646-1" :script 'phonetic)
467 (nil . "MuleIPA-1")
468 (nil . "iso10646-1"))
469 522
470 ;; Fallback fonts 523 ;; Fallback fonts
471 (nil (nil . "gb2312.1980") 524 (nil (nil . "gb2312.1980")
@@ -567,18 +620,21 @@
567 (font-spec :registry "iso10646-1" :script (nth 2 math-subgroup)))) 620 (font-spec :registry "iso10646-1" :script (nth 2 math-subgroup))))
568 621
569 ;; Append CJK fonts for characters other than han, kana, cjk-misc. 622 ;; Append CJK fonts for characters other than han, kana, cjk-misc.
570 ;; CHARSET-REGISTRY CHARSET FROM-CODE TO-CODE 623 ;; Append fonts for scripts whose name is also a charset name.
571 (let ((list '(("JISX0208.1983-0" japanese-jisx0208 #x2121 #x287E) 624 (let* ((data (build-default-fontset-data))
572 ("GB2312.1980-0" chinese-gb2312 #x2121 #x297E) 625 (registries (car data)))
573 ("BIG5-0" big5 #xA140 #xA3FE) 626 (dolist (target-spec (cdr data))
574 ("CNS11643.1992-1" chinese-cns11643-1 #x2121 #x427E) 627 (let ((target (car target-spec))
575 ("KSC5601.1987-0" korean-ksc5601 #x2121 #x2C7E)))) 628 (spec (cdr target-spec)))
576 (dolist (elt list) 629 (if (integerp spec)
577 (map-charset-chars 630 (dotimes (i (length registries))
578 #'(lambda (range arg) 631 (if (> (logand spec (lsh 1 i)) 0)
579 (set-fontset-font "fontset-default" range 632 (set-fontset-font "fontset-default" target
580 (cons nil (car elt)) nil 'append)) 633 (cons nil (aref registries i))
581 (nth 1 elt) nil (nth 2 elt) (nth 3 elt)))) 634 nil 'append)))
635 (dolist (args spec)
636 (set-fontset-font "fontset-default" target
637 (apply 'font-spec args) nil 'append))))))
582 638
583 ;; Append Unicode fonts. 639 ;; Append Unicode fonts.
584 ;; This may find fonts with more variants (bold, italic) but which 640 ;; This may find fonts with more variants (bold, italic) but which