A library to configure Unicode fonts for Emacs.
(require 'unicode-fonts) (unicode-fonts-setup)
C-h h ; M-x view-hello-file
M-x list-charset-chars RET unicode-bmp RET ; search for eg 210x
M-x list-charset-chars RET unicode-smp RET ; if your backend supports astral chars
M-x unicode-fonts-debug-insert-block RET Mathematical_Operators RET
Emacs maintains font mappings on a per-glyph basis, meaning that multiple fonts are used at the same time (transparently) to display any character for which you have a font. Furthermore, Emacs does this out of the box.
However, font mappings via fontsets are a bit difficult to configure. Furthermore, the default setup does not always pick the most legible fonts. As the manual warns, the choice of font actually displayed for a non-ASCII character is “somewhat random”.
Unicode provides a way to organize font mappings: it divides character ranges into logical groups called “blocks”. This library configures Emacs in a Unicode-friendly way by providing mappings from
each Unicode block ---to---> a font with good coverage
and makes the settings available via the customization interface.
To use unicode-fonts, place the unicode-fonts.el file somewhere Emacs can find it, and add the following to your ~/.emacs file:
(require 'unicode-fonts) (unicode-fonts-setup)
See important notes about startup speed below.
To gain any benefit from the library, you must have fonts with good Unicode support installed on your system. If you are running a recent version of OS X or Microsoft Windows, you already own some good multi-lingual fonts, though you would do very well to download and install the four items below:
DejaVu Sans, DejaVu Sans Mono
It is also recommended to remove GNU Unifont from your system. Unifont is very useful for debugging, but not useful for reading.
The default options favor correctness and completeness over speed, and can add many seconds to startup time in GUI mode. Note that when possible a font cache is kept between sessions, so try starting Emacs a second time to see the true startup cost. To further increase startup speed, enter the customization interface and
1. Remove fonts from
‘unicode-fonts-block-font-mapping’ which are not present on your system.
2. Disable blocks in
‘unicode-fonts-block-font-mapping’ which you are not interested in displaying.
On the assumption that an extended Latin font such as Monaco, Consolas, or DejaVu Sans Mono is already being used for the default face, no separate mappings are provided for the following Unicode blocks:
Latin Extended Additional Latin Extended-A Latin-1 Supplement Spacing Modifier Letters
‘set-fontset-font’ can easily crash Emacs. There is a workaround, but it may not be sufficient on all platforms. Tested on Cocoa Emacs, Native Mac Emacs, X11/XQuartz, MS Windows XP.
Widths of alternate fonts do not behave as expected on MS Windows. For example, DejaVu Sans Mono box-drawing characters may use a different width than the default font.
Free fonts recognized by this package may be downloaded from the following locations:
Doulos SIL ; Extended European and diacritics
Gentium Plus ; Greek
Aegean, Aegyptus, Akkadian ; Ancient languages Analecta ; Ancient languages, Deseret Musica ; Musical Symbols
MPH 2B Damase ; Arabic, Armenian, Buginese, Cherokee, Georgian, ; Glagolitic, Hanunoo, Kharoshthi, Limbu, Osmanya, ; Shavian, Syloti Nagri, Tai Le, Thaana
WenQuanYi Zen Hei ; CJK (Simplified Chinese)
BabelStone Han ; CJK (Simplified Chinese) BabelStone Phags-pa Book ; Phags-pa
Un Batang ; CJK (Hangul)
Hana Min A, Hana Min B ; CJK (Japanese)
Nuosu SIL ; CJK (Yi)
Daicing Xiaokai ; Mongolian
Jomolhari ; Tibetan
Padauk ; Myanmar
Samyak ; Devanagari, Gujarati, Malayalam, Oriya, Tamil
AnmolUni ; Gurmukhi
Kedage ; Kannada
Mukti Narrow ; Bengali
Akshar Unicode ; Sinhala
Eeyek Unicode ; Meetei Mayek
Khmer Mondulkiri ; Khmer
Saysettha MX ; Lao
Lanna Alif ; Tai Tham
Dai Banna SIL ; New Tai Lue
Tai Heritage Pro ; Tai Viet
Sundanese Unicode ; Sundanese
Scheherazade ; Arabic
Koodak ; Arabic (Farsi)
Ahuramzda ; Avestan
Abyssinica SIL ; Ethiopic
Estrangelo Nisibin ; Syriac
Conakry ; N'ko
Many non-free fonts are referenced by the default settings. However, free alternatives are also given wherever possible, and patches are of course accepted to improve every case.
If you are using a language written in Chinese or Arabic script, try customizing
‘unicode-fonts-skip-font-groups’ to control which script you see, and send a friendly bug report.
unicode-fonts.el is available at github:
and via EmacsWiki:
The following setup just tries to get the Emoticons to display correctly:
;; I have all the packages installed in subdirectories of ~/elisp (dolist (lib '("font-utils" "unicode-fonts" "ucs-utils" "list-utils")) (add-to-list 'load-path (expand-file-name lib (concat (getenv "HOME") "/elisp")))) ;; keep only the Emoticons block, change only the default fontset (require 'unicode-fonts) (setq unicode-fonts-block-font-mapping '(("Emoticons" ("Apple Color Emoji" "Symbola" "Quivira"))) unicode-fonts-fontset-names '("fontset-default")) (unicode-fonts-setup)