refactor: doom-unicode-font -> doom-symbol-font

No font supports all of Unicode or anywhere near it. It’s not even
really possible with current font formats. Therefore, rename
`doom-unicode-font` to `doom-symbol-font`. Only set it as a fallback for
characters in the `symbol` and `mathematical` scripts.
This commit is contained in:
Liam Hupfer 2023-09-24 21:39:01 -05:00 committed by Henrik Lissner
parent 1cc7b04059
commit 4499ce7b0a
8 changed files with 30 additions and 28 deletions

View file

@ -248,8 +248,7 @@ Doom exposes a couple variables for setting fonts. They are:
- [[var:doom-variable-pitch-font]]: used for non-monospace fonts (e.g. when using - [[var:doom-variable-pitch-font]]: used for non-monospace fonts (e.g. when using
variable-pitch-mode or mixed-pitch-mode). Popular for text modes, like Org or variable-pitch-mode or mixed-pitch-mode). Popular for text modes, like Org or
Markdown. Markdown.
- [[var:doom-unicode-font]]: used for rendering unicode glyphs. Emacs defaults to - [[var:doom-symbol-font]]: used for rendering symbols.
Symbola. It is ignored if the [[doom-module::ui unicode]] module is enabled.
- [[var:doom-serif-font]]: the sans-serif font to use wherever the [[face:fixed-pitch-serif]] - [[var:doom-serif-font]]: the sans-serif font to use wherever the [[face:fixed-pitch-serif]]
face is used. face is used.
- [[var:doom-big-font]]: the large font to use when [[fn:doom-big-font-mode]] is active. - [[var:doom-big-font]]: the large font to use when [[fn:doom-big-font-mode]] is active.
@ -267,7 +266,7 @@ For example:
;; in $DOOMDIR/config.el ;; in $DOOMDIR/config.el
(setq doom-font (font-spec :family "JetBrainsMono" :size 12 :weight 'light) (setq doom-font (font-spec :family "JetBrainsMono" :size 12 :weight 'light)
doom-variable-pitch-font (font-spec :family "DejaVu Sans" :size 13) doom-variable-pitch-font (font-spec :family "DejaVu Sans" :size 13)
doom-unicode-font (font-spec :family "Symbola") doom-symbol-font (font-spec :family "JuliaMono")
doom-big-font (font-spec :family "JetBrainsMono" :size 24)) doom-big-font (font-spec :family "JetBrainsMono" :size 24))
#+end_src #+end_src
@ -524,7 +523,7 @@ Here are a few common causes for random crashes:
- Some fonts cause Emacs to crash when they lack support for a particular glyph - Some fonts cause Emacs to crash when they lack support for a particular glyph
(typically symbols). Try changing your font by changing ~doom-font~ or (typically symbols). Try changing your font by changing ~doom-font~ or
~doom-unicode-font~. ~doom-symbol-font~.
- Ligatures can cause Emacs to crash. Try a different [[doom-module::ui ligatures +fira][ligature font]] or disable - Ligatures can cause Emacs to crash. Try a different [[doom-module::ui ligatures +fira][ligature font]] or disable
the [[doom-module::ui ligatures]] module altogether. the [[doom-module::ui ligatures]] module altogether.

View file

@ -36,14 +36,16 @@ Must be a `font-spec', a font object, an XFT font string, or an XLFD string. See
An omitted font size means to inherit `doom-font''s size.") An omitted font size means to inherit `doom-font''s size.")
(defvar doom-unicode-font nil (defvar doom-symbol-font nil
"Fallback font for Unicode glyphs. "Fallback font for symbols.
Must be a `font-spec', a font object, an XFT font string, or an XLFD string. See Must be a `font-spec', a font object, an XFT font string, or an XLFD string. See
`doom-font' for examples. Emacs defaults to Symbola. `doom-font' for examples. Emacs defaults to Symbola.
WARNING: if you specify a size for this font it will hard-lock any usage of this WARNING: if you specify a size for this font it will hard-lock any usage of this
font to that size. It's rarely a good idea to do so!") font to that size. It's rarely a good idea to do so!")
(define-obsolete-variable-alias 'doom-unicode-font 'doom-symbol-font "3.0.0")
(defvar doom-emoji-fallback-font-families (defvar doom-emoji-fallback-font-families
'("Apple Color Emoji" '("Apple Color Emoji"
"Segoe UI Emoji" "Segoe UI Emoji"
@ -525,11 +527,13 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(when (fboundp 'set-fontset-font) (when (fboundp 'set-fontset-font)
(let ((fn (doom-rpartial #'member (font-family-list)))) (let ((fn (doom-rpartial #'member (font-family-list))))
(when-let (font (cl-find-if fn doom-symbol-fallback-font-families)) (when-let (font (cl-find-if fn doom-symbol-fallback-font-families))
(set-fontset-font t 'symbol font)) (dolist (script '(symbol mathematical))
(set-fontset-font t script font)))
(when-let (font (cl-find-if fn doom-emoji-fallback-font-families)) (when-let (font (cl-find-if fn doom-emoji-fallback-font-families))
(set-fontset-font t 'emoji font)) (set-fontset-font t 'emoji font)))
(when doom-unicode-font (when doom-symbol-font
(set-fontset-font t 'unicode doom-unicode-font))) (dolist (script '(symbol mathematical))
(set-fontset-font t script doom-symbol-font)))
;; Nerd Fonts use these Private Use Areas ;; Nerd Fonts use these Private Use Areas
(dolist (range '((#xe000 . #xf8ff) (#xf0000 . #xfffff))) (dolist (range '((#xe000 . #xf8ff) (#xf0000 . #xfffff)))
(set-fontset-font t range "Symbols Nerd Font Mono"))) (set-fontset-font t range "Symbols Nerd Font Mono")))

View file

@ -1417,12 +1417,12 @@ emacs fontset to cover as many unicode glyphs as possible by scanning all
available glyphs from all available fonts. available glyphs from all available fonts.
When this module is enabled: When this module is enabled:
- Emacs will prefer to use the ~doom-unicode-font~ font to display non-latin - Emacs will prefer to use the ~doom-symbol-font~ font to display non-latin
glyphs if it provides coverage for them. glyphs if it provides coverage for them.
- The first time you run Emacs a unicode cache will be generated -- this will - The first time you run Emacs a unicode cache will be generated -- this will
take a while! take a while!
- The cache will be regenerated every time Emacs is made aware of new fonts or - 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-unicode-font~. 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 - The cache will be stored and should not be regenerated unless font-related
configuration or the versions of relevant packages changes. configuration or the versions of relevant packages changes.

View file

@ -71,13 +71,13 @@ core/core-ui.el has four relevant variables:
- ~doom-big-font~ :: the font to use when ~doom-big-font-mode~ is enabled. - ~doom-big-font~ :: the font to use when ~doom-big-font-mode~ is enabled.
- ~doom-variable-pitch-font~ :: the font to use when ~variable-pitch-mode~ is active - ~doom-variable-pitch-font~ :: the font to use when ~variable-pitch-mode~ is active
(or where the ~variable-pitch~ face is used). (or where the ~variable-pitch~ face is used).
- ~doom-unicode-font~ :: the font used to display unicode symbols. This is - ~doom-symbol-font~ :: the font used to display unicode symbols. This is
ignored if the [[doom-module::ui unicode]] module is enabled. ignored if the [[doom-module::ui unicode]] module is enabled.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq doom-font (font-spec :family "Fira Mono" :size 12) (setq doom-font (font-spec :family "Fira Mono" :size 12)
doom-variable-pitch-font (font-spec :family "Fira Sans") doom-variable-pitch-font (font-spec :family "Fira Sans")
doom-unicode-font (font-spec :family "DejaVu Sans Mono") doom-symbol-font (font-spec :family "JuliaMono")
doom-big-font (font-spec :family "Fira Mono" :size 19)) doom-big-font (font-spec :family "Fira Mono" :size 19))
#+end_src #+end_src

View file

@ -247,10 +247,9 @@ happen in all modes, you can use
** Some symbols are not rendering correctly ** Some symbols are not rendering correctly
This can usually be fixed by doing one of the following: This can usually be fixed by doing one of the following:
- Make sure Symbola (the font) is installed on your system. - Set [[var:doom-symbol-font]].
- Otherwise, change [[var:doom-unicode-font]] (set to Symbola by default). - Disable the [[doom-module::ui unicode]] module. It overrides [[var:doom-symbol-font]]
- Disable the [[doom-module::ui unicode]] module. It not only overrides [[var:doom-unicode-font]], but and should only be used as a last resort.
should only be used as a last resort.
* Frequently asked questions * Frequently asked questions
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] /This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]

View file

@ -13,12 +13,12 @@ emacs fontset to cover as many unicode glyphs as possible by scanning all
available glyphs from all available fonts. available glyphs from all available fonts.
When this module is enabled: When this module is enabled:
- Emacs will prefer to use the ~doom-unicode-font~ font to display non-latin - Emacs will prefer to use the ~doom-symbol-font~ font to display non-latin
glyphs if it provides coverage for them. glyphs if it provides coverage for them.
- The first time you run Emacs a unicode cache will be generated -- this will - The first time you run Emacs a unicode cache will be generated -- this will
take a while! take a while!
- The cache will be regenerated every time Emacs is made aware of new fonts or - 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-unicode-font~. 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 - The cache will be stored and should not be regenerated unless font-related
configuration or the versions of relevant packages changes. configuration or the versions of relevant packages changes.
@ -54,16 +54,16 @@ When this module is enabled:
#+end_quote #+end_quote
The first font that will be analyzed to see if it contains the glyphs of The first font that will be analyzed to see if it contains the glyphs of
non-latin characters will be ~doom-unicode-font~: non-latin characters will be ~doom-symbol-font~:
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; in $DOOMDIR/config.el ;; in $DOOMDIR/config.el
(setq doom-unicode-font (font-spec :family "Fira Mono")) (setq doom-symbol-font (font-spec :family "JuliaMono"))
#+end_src #+end_src
If your ~doom-font~ provides good unicode coverage use: If your ~doom-font~ provides good unicode coverage use:
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; in $DOOMDIR/config.el ;; in $DOOMDIR/config.el
(setq doom-unicode-font doom-font) (setq doom-symbol-font doom-font)
#+end_src #+end_src
If your font does not provide some glyphs, this package will try its best to If your font does not provide some glyphs, this package will try its best to

View file

@ -12,14 +12,14 @@ necessary."
(defun +unicode-setup-fonts-h (&optional frame) (defun +unicode-setup-fonts-h (&optional frame)
"Initialize `unicode-fonts', if in a GUI session. "Initialize `unicode-fonts', if in a GUI session.
If doom-unicode-font is set, add it as preferred font for all unicode blocks." If doom-symbol-font is set, add it as a preferred font for all Unicode blocks."
(when (and frame (display-multi-font-p frame)) (when (and frame (display-multi-font-p frame))
(with-selected-frame frame (with-selected-frame frame
(require 'unicode-fonts) (require 'unicode-fonts)
(when doom-unicode-font (when doom-symbol-font
(let ((doom-unicode-font-family (plist-get (font-face-attributes doom-unicode-font) :family))) (let ((doom-symbol-font-family (plist-get (font-face-attributes doom-symbol-font) :family)))
(dolist (unicode-block unicode-fonts-block-font-mapping) (dolist (unicode-block unicode-fonts-block-font-mapping)
(push doom-unicode-font-family (cadr unicode-block))))) (push doom-symbol-font-family (cadr unicode-block)))))
;; NOTE: will impact startup time on first run ;; NOTE: will impact startup time on first run
(let (inhibit-redisplay inhibit-message) (let (inhibit-redisplay inhibit-message)
(unicode-fonts-setup))))) (unicode-fonts-setup)))))

View file

@ -15,7 +15,7 @@
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable) ;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for ;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming. ;; presentations or streaming.
;; - `doom-unicode-font' -- for unicode glyphs ;; - `doom-symbol-font' -- for symbols
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face ;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
;; ;;
;; See 'C-h v doom-font' for documentation and more examples of what they ;; See 'C-h v doom-font' for documentation and more examples of what they