doomemacs/modules/ui/unicode
Kisaragi Hiu 44d7c8bf37 perf(unicode): drastically reduce initial startup time
font-utils.el disable its cache on X and Windows so every check for the
existence of a font recomputes the font list, which takes a
non-negligible amount of time, at least on X. This default is reasonable
as stated in the docstring of font-utils-use-memory-cache:

> Disabled on X11 and MS Windows by default, because font-family-list
> often gives truncated results before Emacs is fully initialized.

This is, however, unreasonable from unicode-fonts, where calls to check
the existence of fonts happens in a loop; during the loop, Emacs is not
going to suddenly become fully initialized, , so each call is
actually recomputing the same font list over and over again.

Enabling the font-utils memory cache, at least for the duration of
unicode-fonts-setup, thus drastically reduces the initial startup time,
or the startup time when the pcache store is reset for some reason.
2025-12-01 00:44:00 -05:00
..
.doommodule feat: add .doommodule files 2024-09-14 20:47:39 -04:00
autoload.el perf(unicode): drastically reduce initial startup time 2025-12-01 00:44:00 -05:00
packages.el bump: :ui 2024-02-04 18:58:53 -05:00
README.org refactor: doom-unicode-font -> doom-symbol-font 2023-10-07 02:33:45 +02:00

:ui unicode

Description   unfold

This module extends Doom's ability to display non-English unicode. It is primarily useful for non-English Emacs users, for whom Doom's built-in unicode support in insufficient.

This module relies on the unicode-fonts package. It tries to setup the default emacs fontset to cover as many unicode glyphs as possible by scanning all available glyphs from all available fonts.

When this module is enabled:

  • Emacs will prefer to use the doom-symbol-font font to display non-latin glyphs if it provides coverage for them.
  • The first time you run Emacs a unicode cache will be generated this will take a while!
  • The cache will be regenerated every time Emacs is made aware of new fonts or you change the font configuration e.g. by modifying doom-symbol-font.
  • The cache will be stored and should not be regenerated unless font-related configuration or the versions of relevant packages changes.

Maintainers

This module needs a maintainer. Become a maintainer?

Module flags

This module has no flags.

Hacks

No hacks documented for this module.

TODO Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module has no external requirements.

TODO Usage

󱌣 This module has no usage documentation yet. Write some?

TODO Configuration

󱌣 This module's configuration documentation is incomplete. Complete it?

The first font that will be analyzed to see if it contains the glyphs of non-latin characters will be doom-symbol-font:

;; in $DOOMDIR/config.el
(setq doom-symbol-font (font-spec :family "JuliaMono"))

If your doom-font provides good unicode coverage use:

;; in $DOOMDIR/config.el
(setq doom-symbol-font doom-font)

If your font does not provide some glyphs, this package will try its best to find another font that does.

Getting fonts with good coverage

A list of fonts with good unicode coverage can be found on the page of the unicode-fonts package.

Advanced configuration

Consult the unicode-fonts package documentation for a description of more advanced configuration. The configuration should be placed, as usual, in $DOOMDIR/config.el wrapped in an (after! unicode-fonts) block. The variable unicode-fonts-blocks contains a list of all unicode block names and their character ranges. The default fonts to search for glyphs are in the variable unicode-fonts-block-font-mapping.

If you want to use the font Symbola for Miscellaneous Symbols by default use:

;; in $DOOMDIR/config.el
(after! unicode-fonts
  (push "Symbola" (cadr (assoc "Miscellaneous Symbols" unicode-fonts-block-font-mapping))))

If you want to redefine several blocks an efficient way would be:

(after! unicode-fonts
  (dolist (unicode-block '("Mathematical Alphanumeric Symbols"
                           "Mathematical Operators"
                           "Miscellaneous Mathematical Symbols-A"
                           "Miscellaneous Mathematical Symbols-B"
                           "Miscellaneous Symbols"
                           "Miscellaneous Symbols and Arrows"
                           "Miscellaneous Symbols and Pictographs"))
      (push "DejaVu Math TeX Gyre" (cadr (assoc unicode-block unicode-fonts-block-font-mapping)))))

You can find a list of fonts available to emacs using M-x counsel-fonts.

Troubleshooting

Report an issue?

TODO Emacs daemon mode (#3328)

This module may fail to setup fonts when emacs is run in a daemon session.

Common error: void-variable \.\.\. (#7164)

Users for this module may see the error similar to:

Debugger entered--Lisp error: (void-variable \.\.\.)
  (progn (set-fontset-font "fontset-default" '(64256 . 64335) (font-spec :name "Arial Unicode MS:" :registry "iso10646-1")) (set-fontset-font "fontset-default" '(65856 . 65935) (font-spec :name "Apple Symbols:" :registry "iso10646-1")) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Courier New:" :registry "iso10646-1")) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Geeza Pro:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Baghdad:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Damascus:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Al Bayan:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Arial Unicode MS:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Nadeem:" :registry "iso10646-1") nil 'append) \.\.\.)
  eval((progn (set-fontset-font "fontset-default" '(64256 . 64335) (font-spec :name "Arial Unicode MS:" :registry "iso10646-1")) (set-fontset-font "fontset-default" '(65856 . 65935) (font-spec :name "Apple Symbols:" :registry "iso10646-1")) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Courier New:" :registry "iso10646-1")) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Geeza Pro:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Baghdad:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Damascus:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Al Bayan:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Arial Unicode MS:" :registry "iso10646-1") nil 'append) (set-fontset-font "fontset-default" '(1536 . 1791) (font-spec :name "Nadeem:" :registry "iso10646-1") nil 'append) \.\.\.))
  unicode-fonts--setup-1("fontset-default" nil)
  unicode-fonts-setup()

This is a known issue with an unidentified cause. See rolandwalker/unicode-fonts#36. A workaround is to delete your unicode-fonts cache and restart Emacs:

# $EMACSDIR == where you cloned Doom Emacs
rm -f $EMACSDIR/.local/cache/pcache/unicode-fonts

Frequently asked questions

This module has no FAQs yet. Ask one?

TODO Appendix

󱌣 This module has no appendix yet. Write one?