Function: setup-default-fontset

setup-default-fontset is a byte-compiled function defined in fontset.el.gz.

Signature

(setup-default-fontset)

Documentation

Setup the default fontset.

Source Code

;; Defined in /usr/src/emacs/lisp/international/fontset.el.gz
(defun setup-default-fontset ()
  "Setup the default fontset."
  (new-fontset
   "fontset-default"
   `(;; for each script
     (latin (nil . "ISO8859-1")
	    (nil . "ISO8859-2")
	    (nil . "ISO8859-3")
	    (nil . "ISO8859-4")
	    (nil . "ISO8859-9")
	    (nil . "ISO8859-10")
	    (nil . "ISO8859-13")
	    (nil . "ISO8859-14")
	    (nil . "ISO8859-15")
	    (nil . "ISO8859-16")
	    (nil . "VISCII1.1-1")
	    ,(font-spec :registry "iso10646-1" :script 'latin))

     (thai  ,(font-spec :registry "iso10646-1" :otf '(thai nil nil (mark)))
	    ,(font-spec :registry "iso10646-1" :script 'thai)
	    (nil . "TIS620*")
	    (nil . "ISO8859-11"))

     (devanagari ,(font-spec :registry "iso10646-1" :otf '(dev2 nil (rphf)))
                 ,(font-spec :registry "iso10646-1" :otf '(deva nil (rphf)))
		 (nil . "iso10646.indian-1"))
     (bengali ,(font-spec :registry "iso10646-1" :otf '(bng2 nil (rphf)))
              ,(font-spec :registry "iso10646-1" :otf '(beng nil (rphf))))
     (gurmukhi ,(font-spec :registry "iso10646-1" :otf '(gur2 nil (blwf)))
               ,(font-spec :registry "iso10646-1" :otf '(guru nil (blwf))))
     (gujarati ,(font-spec :registry "iso10646-1" :otf '(gjr2 nil (rphf)))
               ,(font-spec :registry "iso10646-1" :otf '(gujr nil (rphf))))
     (oriya ,(font-spec :registry "iso10646-1" :otf '(ory2 nil (rphf)))
            ,(font-spec :registry "iso10646-1" :otf '(orya nil (rphf))))
     (tamil ,(font-spec :registry "iso10646-1" :otf '(tml2 nil (akhn)))
            ,(font-spec :registry "iso10646-1" :otf '(taml nil (akhn))))
     (telugu ,(font-spec :registry "iso10646-1" :otf '(tel2 nil (blwf)))
             ,(font-spec :registry "iso10646-1" :otf '(telu nil (blwf))))
     (kannada ,(font-spec :registry "iso10646-1" :otf '(knd2 nil (rphf)))
              ,(font-spec :registry "iso10646-1" :otf '(knda nil (rphf))))
     (sinhala ,(font-spec :registry "iso10646-1" :otf '(sinh nil (akhn))))
     (malayalam ,(font-spec :registry "iso10646-1" :otf '(mlm2 nil (akhn)))
                ,(font-spec :registry "iso10646-1" :otf '(mlym nil (akhn))))

     (burmese ,(font-spec :registry "iso10646-1" :otf '(mym2 nil nil))
              ,(font-spec :registry "iso10646-1" :otf '(mymr nil nil))
	      ,(font-spec :registry "iso10646-1" :script 'burmese))

     (lao ,(font-spec :registry "iso10646-1" :otf '(lao\  nil nil (mark)))
	  ,(font-spec :registry "iso10646-1" :script 'lao)
	  (nil . "MuleLao-1"))

     (tai-viet ("TaiViet" . "iso10646-1"))

     (greek ,(font-spec :registry "iso10646-1" :script 'greek)
	    (nil . "ISO8859-7"))

     (cyrillic ,(font-spec :registry "iso10646-1" :script 'cyrillic)
	       (nil . "ISO8859-5")
	       (nil . "microsoft-cp1251")
	       (nil . "koi8-r"))

     (arabic ,(if (featurep 'android)
                  ;; The Android font driver does not support the
                  ;; detection of OTF tags but all fonts installed on
                  ;; Android with Arabic characters provide shaping
                  ;; information required for displaying Arabic text.
                  (font-spec :registry "iso10646-1" :script 'arabic)
                (font-spec :registry "iso10646-1"
			   :otf '(arab nil (init medi fina liga))))
	     (nil . "MuleArabic-0")
	     (nil . "MuleArabic-1")
	     (nil . "MuleArabic-2")
	     (nil . "ISO8859-6"))
     (mongolian ,(font-spec :registry "iso10646-1"
			    :otf '(mong nil (init medi fina isol))))

     (hebrew ,(font-spec :registry "iso10646-1" :script 'hebrew)
	     (nil . "ISO8859-8"))

     (khmer ,(if (featurep 'android)
                 (font-spec :registry "iso10646-1" :script 'khmer)
               (font-spec :registry "iso10646-1" :otf '(khmr nil (pres)))))

     (kana (nil . "JISX0208*")
	   (nil . "GB2312.1980-0")
	   (nil . "KSC5601.1987*")
	   (nil . "JISX0201*")
	   (nil . "JISX0213.2000-1")
	   (nil . "JISX0213.2004-1")
	   ,(font-spec :registry "iso10646-1" :script 'kana))

     (bopomofo ,(font-spec :registry "iso10646-1" :script 'bopomofo)
	       (nil . "sisheng_cwnn-0"))

     (han (nil . "GB2312.1980-0")
	  (nil . "JISX0208*")
	  (nil . "JISX0212*")
	  (nil . "big5*")
	  (nil . "KSC5601.1987*")
	  (nil . "CNS11643.1992-1")
	  (nil . "CNS11643.1992-2")
	  (nil . "CNS11643.1992-3")
	  (nil . "CNS11643.1992-4")
	  (nil . "CNS11643.1992-5")
	  (nil . "CNS11643.1992-6")
	  (nil . "CNS11643.1992-7")
	  (nil . "gbk-0")
	  (nil . "gb18030")
	  (nil . "JISX0213.2000-1")
	  (nil . "JISX0213.2000-2")
	  (nil . "JISX0213.2004-1")
	  ,(font-spec :registry "iso10646-1" :lang 'ja)
	  ,(font-spec :registry "iso10646-1" :lang 'zh)
          ;; This is required on Android, as otherwise many TrueType
          ;; fonts with CJK characters but no corresponding ``design
          ;; language'' declaration can't be found.
          ,@(and (featurep 'android)
                 (list (font-spec :registry "iso10646-1" :script 'han))))

     (cjk-misc (nil . "GB2312.1980-0")
	       (nil . "JISX0208*")
	       (nil . "JISX0212*")
	       (nil . "big5*")
	       (nil . "KSC5601.1987*")
	       (nil . "CNS11643.1992-1")
	       (nil . "CNS11643.1992-2")
	       (nil . "CNS11643.1992-3")
	       (nil . "CNS11643.1992-4")
	       (nil . "CNS11643.1992-5")
	       (nil . "CNS11643.1992-6")
	       (nil . "CNS11643.1992-7")
	       (nil . "gbk-0")
	       (nil . "gb18030")
	       (nil . "JISX0213.2000-1")
	       (nil . "JISX0213.2000-2")
	       ,(font-spec :registry "iso10646-1" :lang 'ja)
	       ,(font-spec :registry "iso10646-1" :lang 'zh)
               ;; This is required, as otherwise many TrueType fonts
               ;; with CJK characters but no corresponding ``design
               ;; language'' declaration can't be found.
               ,@(and (featurep 'android)
                      (list (font-spec :registry "iso10646-1"
                                       :script 'cjk-misc))))

     (hangul (nil . "KSC5601.1987-0")
	     ,(font-spec :registry "iso10646-1" :lang 'ko))

     ;; for each charset
     (ascii (nil . "ISO8859-1"))
     (arabic-digit ("*" . "MuleArabic-0"))
     (arabic-1-column ("*" . "MuleArabic-1"))
     (arabic-2-column ("*" . "MuleArabic-2"))
     (indian-is13194 (nil . "is13194-devanagari"))
     (indian-1-column ("*" . "muleindian-2"))
     ;; Indian CDAC
     (devanagari-cdac (nil . "Devanagari-CDAC"))
     (sanskrit-cdac (nil . "Sanskrit-CDAC"))
     (bengali-cdac (nil . "Bengali-CDAC"))
     (assamese-cdac (nil . "Assamese-CDAC"))
     (punjabi-cdac (nil . "Punjabi-CDAC"))
     (gujarati-cdac (nil . "Gujarati-CDAC"))
     (oriya-cdac (nil . "Oriya-CDAC"))
     (tamil-cdac (nil . "Tamil-CDAC"))
     (telugu-cdac (nil . "Telugu-CDAC"))
     (kannada-cdac (nil . "Kannada-CDAC"))
     (malayalam-cdac (nil . "Malayalam-CDAC"))
     ;; Indian AKRUTI
     (devanagari-akruti (nil . "Devanagari-Akruti"))
     (bengali-akruti (nil . "Bengali-Akruti"))
     (punjabi-akruti (nil . "Punjabi-Akruti"))
     (gujarati-akruti (nil . "Gujarati-Akruti"))
     (oriya-akruti (nil . "Oriya-Akruti"))
     (tamil-akruti (nil . "Tamil-Akruti"))
     (telugu-akruti (nil . "Telugu-Akruti"))
     (kannada-akruti (nil . "Kannada-Akruti"))
     (malayalam-akruti (nil . "Malayalam-Akruti"))

     ;; Fallback fonts
     (nil (nil . "gb2312.1980")
	  (nil . "gbk-0")
	  (nil . "gb18030")
	  (nil . "jisx0208")
	  (nil . "ksc5601.1987")
	  (nil . "CNS11643.1992-1")
	  (nil . "CNS11643.1992-2")
	  (nil . "CNS11643.1992-3")
	  (nil . "CNS11643.1992-4")
	  (nil . "CNS11643.1992-5")
	  (nil . "CNS11643.1992-6")
	  (nil . "CNS11643.1992-7")
	  (nil . "big5")
	  (nil . "jisx0213.2000-1")
	  (nil . "jisx0213.2004-1")
	  (nil . "jisx0212"))
     ))

  ;; For simple scripts
  (dolist (script '(phonetic
		    armenian
		    thaana
		    syriac
		    georgian
		    cherokee
		    canadian-aboriginal
                    cham
		    ogham
		    runic
                    tagalog
                    hanunoo
                    buhid
                    tagbanwa
                    limbu
                    buginese
                    balinese
                    sundanese
                    batak
                    lepcha
		    symbol
		    braille
                    coptic
		    yi
                    syloti-nagri
                    rejang
                    javanese
		    tai-viet
                    meetei-mayek
		    aegean-number
		    ancient-greek-number
		    ancient-symbol
		    phaistos-disc
		    lycian
		    carian
		    old-italic
                    gothic
		    ugaritic
		    old-persian
		    deseret
		    shavian
		    osmanya
		    osage
                    vithkuqi
		    cypriot-syllabary
		    phoenician
		    lydian
                    hanifi-rohingya
                    yezidi
		    kharoshthi
		    manichaean
		    avestan
                    chorasmian
		    elymaic
                    old-uyghur
                    brahmi
                    kaithi
                    chakma
                    sharada
                    grantha
                    tirhuta
                    siddham
                    modi
		    makasar
                    kawi
                    dives-akuru
		    cuneiform
		    egyptian
                    tangsa
		    bassa-vah
		    pahawh-hmong
		    medefaidrin
                    znamenny-musical-notation
                    old-turkic
		    byzantine-musical-symbol
		    musical-symbol
		    ancient-greek-musical-notation
                    kaktovik-numeral
		    tai-xuan-jing-symbol
		    counting-rod-numeral
                    toto
                    wancho
                    nag-mundari
                    mende-kikakui
		    adlam
                    tai-tham
                    indic-siyaq-number
                    ottoman-siyaq-number
		    mahjong-tile
		    domino-tile
                    emoji
                    chess-symbol))
    (set-fontset-font "fontset-default"
		      script (font-spec :registry "iso10646-1" :script script)
		      nil 'append))

  ;; Special settings for `MATHEMATICAL (U+1D400..U+1D7FF)'.
  (dolist (math-subgroup '((#x1D400 #x1D433 mathematical-bold)
			   (#x1D434 #x1D467 mathematical-italic)
			   (#x1D468 #x1D49B mathematical-bold-italic)
			   (#x1D49C #x1D4CF mathematical-script)
			   (#x1D4D0 #x1D503 mathematical-bold-script)
			   (#x1D504 #x1D537 mathematical-fraktur)
			   (#x1D538 #x1D56B mathematical-double-struck)
			   (#x1D56C #x1D59F mathematical-bold-fraktur)
			   (#x1D5A0 #x1D5D3 mathematical-sans-serif)
			   (#x1D5D4 #x1D607 mathematical-sans-serif-bold)
			   (#x1D608 #x1D63B mathematical-sans-serif-italic)
			   (#x1D63C #x1D66F mathematical-sans-serif-bold-italic)
			   (#x1D670 #x1D6A3 mathematical-monospace)
			   (#x1D6A4 #x1D6A5 mathematical-italic)
			   (#x1D6A8 #x1D6E1 mathematical-bold)
			   (#x1D6E2 #x1D71B mathematical-italic)
			   (#x1D71C #x1D755 mathematical-bold-italic)
			   (#x1D756 #x1D78F mathematical-sans-serif-bold)
			   (#x1D790 #x1D7C9 mathematical-sans-serif-bold-italic)
			   (#x1D7CA #x1D7D7 mathematical-bold)
			   (#x1D7D8 #x1D7E1 mathematical-double-struck)
			   (#x1D7E2 #x1D7EB mathematical-sans-serif)
			   (#x1D7EC #x1D7F5 mathematical-sans-serif-bold)
			   (#x1D7F6 #x1D7FF mathematical-monospace)))
    (let ((slot (assq (nth 2 math-subgroup) script-representative-chars)))
      ;; Add both ends of each subgroup to help filter out some
      ;; incomplete fonts, e.g. those that cover MATHEMATICAL SCRIPT
      ;; CAPITAL glyphs but not MATHEMATICAL SCRIPT SMALL ones.
      (if slot
          (setcdr slot (append (list (nth 0 math-subgroup)
                                     (nth 1 math-subgroup))
                               (cdr slot)))
        (setq slot (list (nth 2 math-subgroup)
                         (nth 0 math-subgroup)
                         (nth 1 math-subgroup)))
	(nconc script-representative-chars (list slot))))
    (set-fontset-font
     "fontset-default"
     (cons (car math-subgroup) (nth 1 math-subgroup))
     (font-spec :registry "iso10646-1" :script (nth 2 math-subgroup))))

  ;; Special setup for various symbols and punctuation characters
  ;; covered well by Symbola, excluding those covered well by popular
  ;; Unicode fonts.  We exclude the latter because users don't like us
  ;; invading on their font setups where they have good support from
  ;; other fonts.
  (dolist (symbol-subgroup
           '((#x2000 . #x2012)	;; General Punctuation
             (#x2015 . #x2017)
             #x201F
             (#x2023 . #x202F)
             (#x2031 . #x2038)
             (#x203B . #x206F)
             (#x2070 . #x209F)	;; Superscripts and Subscripts
             (#x20B6 . #x20CF)	;; Currency Symbols
             (#x2100 . #x2121)	;; Letterlike Symbols
             (#x2123 . #x214F)
             (#x2150 . #x215A)	;; Number Forms
             (#x215F . #x218F)
             (#x2194 . #x21FF)	;; Arrows
             (#x2200 . #x2211)	;; Mathematical Operators
             (#x2213 . #x2247)
             (#x2249 . #x225F)
             (#x2261 . #x2263)
             (#x2266 . #x22FF)
             (#x2300 . #x2301)	;; Miscellaneous Technical
             (#x2303 . #x230F)
             (#x2311 . #x231F)
             (#x2322 . #x23FF)
             (#x2400 . #x243F)	;; Control Pictures
             (#x2440 . #x245F)	;; Optical Char Recognition
             (#x2460 . #x24FF)	;; Enclosed Alphanumerics
             (#x25A0 . #x25FF)	;; Geometric Shapes
             (#x2600 . #x265F)	;; Miscellaneous Symbols
             (#x2661 . #x2662)
             #x2664
             (#x2667 . #x2669)
             (#x266C . #x26FF)
             (#x2700 . #x27bF)	;; Dingbats
             (#x27C0 . #x27EF)	;; Misc Mathematical Symbols-A
             (#x27F0 . #x27FF)	;; Supplemental Arrows-A
             (#x2900 . #x297F)	;; Supplemental Arrows-B
             (#x2980 . #x29FF)	;; Misc Mathematical Symbols-B
             (#x2A00 . #x2AFF)	;; Suppl. Math Operators
             (#x2B00 . #x2BFF)	;; Misc Symbols and Arrows
             (#x2E00 . #x2E7F)	;; Supplemental Punctuation
             (#x4DC0 . #x4DFF)	;; Yijing Hexagram Symbols
             (#xFE10 . #xFE1F)	;; Vertical Forms
             (#x10100 . #x1013F)	;; Aegean Numbers
             (#x10190 . #x101CF)	;; Ancient Symbols
             (#x101D0 . #x101FF)	;; Phaistos Disc
             (#x102E0 . #x102FF)	;; Coptic Epact Numbers
             (#x1D000 . #x1D0FF)	;; Byzantine Musical Symbols
             (#x1D200 . #x1D24F)	;; Ancient Greek Musical Notation
             (#x1D2E0 . #x1D2FF)	;; Mayan Numerals
             (#x1D300 . #x1D35F)	;; Tai Xuan Jing Symbols
             (#x1D360 . #x1D37F)	;; Counting Rod Numerals
             (#x1F000 . #x1F02F)	;; Mahjong Tiles
             (#x1F030 . #x1F09F)	;; Domino Tiles
             (#x1F0A0 . #x1F0FF)	;; Playing Cards
             (#x1F100 . #x1F1FF)	;; Enclosed Alphanumeric Suppl
             (#x1F300 . #x1F5FF)	;; Misc Symbols and Pictographs
             (#x1F600 . #x1F64F)	;; Emoticons
             (#x1F650 . #x1F67F)	;; Ornamental Dingbats
             (#x1F680 . #x1F6FF)	;; Transport and Map Symbols
             (#x1F700 . #x1F77F)	;; Alchemical Symbols
             (#x1F780 . #x1F7FF)	;; Geometric Shapes Extended
             (#x1F800 . #x1F8FF)	;; Supplemental Arrows-C
             (#x1F900 . #x1F9FF)	;; Supplemental Symbols and Pictographs
             (#x1FA00 . #x1FA6F)))	;; Chess Symbols
    (set-fontset-font "fontset-default" symbol-subgroup
                      '("Symbola" . "iso10646-1") nil 'prepend))
  ;; Box Drawing and Block Elements
  (set-fontset-font "fontset-default" '(#x2500 . #x259F)
                    '("FreeMono" . "iso10646-1") nil 'prepend)

  ;; Since standard-fontset-spec on X uses fixed-medium font, which
  ;; gets mapped to an iso8859-1 variant, we would like to prefer its
  ;; iso10646-1 variant for symbols, where the coverage is known to be
  ;; good.
  (dolist (symbol-subgroup
			 '((#x2000 . #x206F)   ;; General Punctuation
			   (#x2070 . #x209F)   ;; Superscripts and Subscripts
			   (#x20A0 . #x20CF)   ;; Currency Symbols
			   (#x2150 . #x218F)   ;; Number Forms
			   (#x2190 . #x21FF)   ;; Arrows
			   (#x2200 . #x22FF)   ;; Mathematical Operators
			   (#x2300 . #x23FF)   ;; Miscellaneous Technical
			   (#x2400 . #x243F)   ;; Control Pictures
			   (#x2440 . #x245F)   ;; Optical Char Recognition
			   (#x2460 . #x24FF)   ;; Enclosed Alphanumerics
                           (#x2500 . #x257F)   ;; Box Drawing
                           (#x2580 . #x259F)   ;; Block Elements
			   (#x25A0 . #x25FF)   ;; Geometric Shapes
			   (#x2600 . #x2689)   ;; Miscellaneous Symbols
			   (#x2700 . #x27bF)   ;; Dingbats
			   (#x27F5 . #x27FF))) ;; Supplemental Arrows-A
    (set-fontset-font "fontset-default" symbol-subgroup
                      "-*-fixed-medium-*-*-*-*-*-*-*-*-*-iso10646-1"
                      nil 'prepend))
  ;; This sets up the Emoji codepoints to use prettier fonts:
  ;;  this is fallback, if they don't have color Emoji capabilities...
  (set-fontset-font "fontset-default" 'emoji
                    '("Noto Emoji" . "iso10646-1") nil 'prepend)
  ;;  ...and this is if they do
  (set-fontset-font "fontset-default" 'emoji
                    '("Noto Color Emoji" . "iso10646-1") nil 'prepend)

  ;; This supports the display of Tamil Supplement characters.  As
  ;; these characters are pretty simple and do not need reordering,
  ;; ligatures, vowel signs, virama etc., neither tml2 nor other OTF
  ;; features are needed here.
  (set-fontset-font "fontset-default" '(#x11FC0 . #x11FFF)
                    '("Noto Sans Tamil Supplement" . "iso10646-1") nil 'append)

  ;; Append CJK fonts for characters other than han, kana, cjk-misc.
  ;; Append fonts for scripts whose name is also a charset name.
  (let* ((data (build-default-fontset-data))
	 (registries (car data)))
    (dolist (target-spec (cdr data))
      (let ((target (car target-spec))
	    (spec (cdr target-spec)))
	(if (integerp spec)
	    (dotimes (i (length registries))
	      (if (> (logand spec (ash 1 i)) 0)
		  (set-fontset-font "fontset-default" target
				    (cons nil (aref registries i))
				    nil 'append)))
	(dolist (args spec)
	  (set-fontset-font "fontset-default" target
			    (apply 'font-spec args) nil 'append))))))

  ;; Append Unicode fonts.
  ;; This may find fonts with more variants (bold, italic) but which
  ;; don't cover many characters.
  (set-fontset-font "fontset-default" nil
		    '(nil . "iso10646-1") nil 'prepend)
  ;; These may find fonts that cover many characters but with fewer
  ;; variants.
  (set-fontset-font "fontset-default" nil
		    '("gnu-unifont" . "iso10646-1") nil 'prepend)
  (set-fontset-font "fontset-default" nil
		    '("mutt-clearlyu" . "iso10646-1") nil 'prepend)
  (set-fontset-font "fontset-default" '(#x20000 . #x2FFFF)
		    '(nil . "unicode-sip"))

  (set-fontset-font "fontset-default" '(#xE000 . #xF8FF)
		    '(nil . "iso10646-1"))
  ;; Don't try the fallback fonts even if no suitable font was found
  ;; by the above font-spec.
  (set-fontset-font "fontset-default" '(#xE000 . #xF8FF) nil nil 'append))