emacs init: set font for rare languages

By Xah Lee. Date: .
xtodo

view-hello-file

emacs view-hello-file 2026-06-18 2247e
emacs view-hello-file 2026-06-18 2247e

2026-06-18 Alt+x view-hello-file. to show a file with over a hundred human languages

Emacs on Microsoft Windows, it take 35 seconds to show this file, if run for the first time in session. ( both Microsoft Windows 10 and 11. On a 2020 desktop gaming machine. CPU AMD Ryzen 5 3600 Processor 6C/12T 3.6-4.2 GHz 32MB Cache. GPU: NVIDIA GeForce GTX 1660 Ti 6G GDDR6. )

on Microsoft Windows, set font for languages

You should set a font for emoji and other unicode symbols or human languages. Especially on Mac and Microsoft Windows.

If you do not, whenever you open a file with lots characters that is not in current font, emacs will search a font for those characters, and may take 5 seconds.

script-representative-chars
  • Variable.
  • Alist of scripts vs the representative characters.
  • Each element is a cons (SCRIPT . CHARS).
  • SCRIPT is a symbol representing a script or a subgroup of a script.
  • CHARS is a list or a vector of characters.

Find a script supported in emacs by the variable script-representative-chars, then find out what's the font name in your operating system that supports that script. Then you can setup a font for the script in emacs, like this:

;; set font for cuneiform
(set-fontset-font
 t
 'cuneiform
 (cond
  ((eq system-type 'windows-nt)
   (cond
    ((member "Segoe UI Historic" (font-family-list)) "Segoe UI Historic")))
  ((eq system-type 'darwin)
   (cond
    ((member "Noto Sans Cuneiform Regular" (font-family-list)) "Noto Sans Cuneiform Regular")))
  ((eq system-type 'gnu/linux)
   (cond
    ((member "Noto Sans Cuneiform Regular" (font-family-list)) "Noto Sans Cuneiform Regular")))))

(set-fontset-font
 t
 'phoenician
 (cond
  ((eq system-type 'windows-nt)
   (cond
    ((member "Segoe UI Historic" (font-family-list)) "Segoe UI Historic")))
  ((eq system-type 'darwin)
   (cond
    ((member "Noto Sans Phoenician Regular" (font-family-list)) "Noto Sans Phoenician Regular")))
  ((eq system-type 'gnu/linux)
   (cond
    ((member "Noto Sans Phoenician Regular" (font-family-list)) "Noto Sans Phoenician Regular")))))

(set-fontset-font
 t
 'deseret
 (cond
  ((eq system-type 'windows-nt)
   (cond
    ((member "Segoe UI Symbol" (font-family-list)) "Segoe UI Symbol")))
  ((eq system-type 'darwin)
   (cond
    ((member "Apple Symbols" (font-family-list)) "Apple Symbols")))
  ((eq system-type 'gnu/linux)
   (cond
    ((member "Noto Sans Deseret" (font-family-list)) "Noto Sans Deseret")))))

(set-fontset-font
 t
 'shavian
 (cond
  ((eq system-type 'windows-nt)
   (cond
    ((member "Segoe UI Historic" (font-family-list)) "Segoe UI Historic")))
  ((eq system-type 'darwin)
   (cond
    ((member "Apple Symbols" (font-family-list)) "Apple Symbols")))
  ((eq system-type 'gnu/linux)
   (cond
    ((member "Noto Sans Shavian Regular" (font-family-list)) "Noto Sans Shavian Regular")))))

(set-fontset-font
 t
 'egyptian
 (cond
  ((eq system-type 'windows-nt)
   (cond
    ((member "Segoe UI Historic" (font-family-list)) "Segoe UI Historic")))
  ((eq system-type 'darwin)
   (cond
    ((member "Noto Sans Egyptian Hieroglyphs" (font-family-list)) "Noto Sans Egyptian Hieroglyphs")))
  ((eq system-type 'gnu/linux)
   (cond
    ((member "Aegyptus" (font-family-list)) "Aegyptus")))))