Prefer Markus Kuhn’s X11 Unicode fonts to non-existent other charset fonts

Download this file here.


(unless (get 'jit-ucs-charset-0 'last-allocated-character)
  ;; Launch the just-in-time Unicode charset allocation if that is
  ;; available.
  (decode-char 'ucs #x204a))

;; If my Unicode-handling code is in place in this XEmacs, prefer Unicode to
;; other character sets for Greek and the IPA; display those two-dimensional
;; charsets that don't have corresponding fonts on XFree86 servers using the
;; Unicode fonts.

(when (find-charset 'jit-ucs-charset-0)
  (assert (not (find-charset 'jit-ucs-charset-1)) t 
          "Haven't written this code to handle more than one JIT charset.")

  (let ((new-high-order (second (split-char 
                                 (get 'jit-ucs-charset-0
                                      'last-allocated-character))))
        ;; Greek fonts crash the server; IPA fonts are not available;
        ;; Cyrillic fonts are ugly; ditto the Hebrew available to me.
        (charsets-to-remap '(greek-iso8859-7 ipa cyrillic-iso8859-5
                             hebrew-iso8859-8))
        conv)

    (assert (> 127 (+ new-high-order (length charsets-to-remap))) t
            "If this limit is hit, we need to rewrite the code. ")

    (dolist (charset charsets-to-remap)
      (incf new-high-order)
      (loop for low-order from 32 to 127 do
        (setq conv (char-to-unicode (make-char charset low-order)))
        (if (/= -1 conv)
            (set-unicode-conversion (make-char 'jit-ucs-charset-0 
                                               new-high-order
                                               low-order)
                                    conv))))


    (put 'jit-ucs-charset-0 'last-allocated-character 
         (make-char 'jit-ucs-charset-0 new-high-order 127))

  (set-language-unicode-precedence-list  
   '(ascii latin-iso8859-1 latin-iso8859-2 jit-ucs-charset-0 latin-iso8859-4  
     thai-tis620 greek-iso8859-7 arabic-iso8859-6  
     hebrew-iso8859-8 latin-iso8859-16 
     katakana-jisx0201 latin-jisx0201 cyrillic-iso8859-5 latin-iso8859-9  
     latin-iso8859-15 composite control-1  
     japanese-jisx0208-1978 japanese-jisx0213-1 japanese-jisx0213-2 
     japanese-jisx0208 japanese-jisx0212 chinese-gb2312  
     chinese-big5-1 chinese-big5-2 korean-ksc5601 
     chinese-cns11643-1 chinese-cns11643-2  
     arabic-digit arabic-1-column arabic-2-column chinese-sisheng 
     ascii-right-to-left latin-iso8859-14 indian-is13194 lao ipa 
     vietnamese-viscii-upper vietnamese-viscii-lower latin-iso8859-16 
     chinese-cns11643-3 chinese-cns11643-4 
     chinese-cns11643-5 chinese-cns11643-6 chinese-cns11643-7 
     chinese-isoir165 ethiopic indian-2-column indian-1-column 
     thai-xtis tibetan tibetan-1-column))

  ;; With the current font architecture, this gets picked up as the face for
  ;; the esoteric character sets, and the X11 resources are checked for the
  ;; others.
  (set-face-font 'default 
                 "-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso10646-1")

  (dolist (charset 
         '(chinese-cns11643-1 chinese-cns11643-2 chinese-big5-1
           chinese-big5-2 arabic-digit arabic-1-column arabic-2-column
           chinese-sisheng ascii-right-to-left indian-is13194 lao ipa
           vietnamese-viscii-upper vietnamese-viscii-lower japanese-jisx0212
           chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5
           chinese-cns11643-6 chinese-cns11643-7 chinese-isoir165 ethiopic
           indian-2-column indian-1-column japanese-jisx0213-1
           japanese-jisx0213-2 thai-xtis tibetan tibetan-1-column))
  (when (equal (charset-dimension charset) 2)
    (set-charset-ccl-program charset 'ccl-encode-to-ucs-2)
    (set-charset-registry charset "iso10646-1")))))