diff options
author | sterni <sternenseemann@systemli.org> | 2024-12-20T23·09+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-12-20T23·38+0000 |
commit | 7069de785750e901e7ff8733922f4e039e333ea7 (patch) | |
tree | d587d840b13ba312567c9ed09e3614b5707c09b5 | |
parent | 756e96499c7ab747a1fb967369d661a725071f24 (diff) |
fix(sterni/emacs): get emacs to use default monospace for unicode r/9012
I've recently set JetBrains Mono to be my default monospace font because it has better Unicode coverage than Bitstream Vera Mono and should consequently include all BQN symbols. However when investigating why 𝕊 was weirdly small, I discovered that it was using GNU FreeSerif for some reason. As it turns out, Emacs uses the default font (or the system wide default monospace font if unset) for ASCII only. Beyond ASCII emacs falls back to the random assortment that is fontset-default. Using (set-fontset-font <fontset> NIL …) doesn't work – neither for preventing a fallback to fontset-default from fontset-startup nor for prepending a font to all ranges of fontset-default. Especially the former seems to contradict the Emacs documentation. The only solution I could come up with, is to set the relevant charsets explicitly in fontset-startup and to never touch the default font face. Change-Id: I640b3207e3cc3449ecd422db0e2ed93fb7d3521f Reviewed-on: https://cl.tvl.fyi/c/depot/+/12899 Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
-rw-r--r-- | users/sterni/emacs/init.el | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/users/sterni/emacs/init.el b/users/sterni/emacs/init.el index 4cb741f62d41..5eddf8af82e1 100644 --- a/users/sterni/emacs/init.el +++ b/users/sterni/emacs/init.el @@ -3,12 +3,26 @@ (require 'use-package) (package-initialize) -;; Set default font and fallback font via set-fontset-font -(let ((mono-font "Bitstream Vera Sans Mono-12") - (emoji-font "Noto Color Emoji-12")) - (setq default-frame-alist `((font . ,mono-font))) - (set-frame-font mono-font t t) - (set-fontset-font t nil emoji-font)) +;; By default, Emacs only uses the default font for ASCII and then falls back to +;; fontset-default which uses random fonts (the documentation describes this +;; accurately). Emacs would be better off if it used the fallback order defined +;; by fontconfig instead of implementing its own scheme for this… +;; In any case, I've found that after setting the default font via methods like +;; (add-to-list 'default-frame-alist …), (set-face-attribute 'default …) etc. +;; it is impossible to change the fontset this font becomes part of (for ascii). +;; Specifically, the following snippet from the Emacs manual just does not seem +;; to work (https://www.gnu.org/software/emacs/manual/html_node/emacs/Modifying-Fontsets.html): +;; +;; (set-fontset-font "fontset-startup" nil "DejaVu Sans Mono" +;; nil 'append) +;; +;; This may very well be my ignorace, but I've found that just setting the ascii +;; and unicode charsets of fontset-startup to a generic Monospace-11 (remember +;; if we use set-face-attribute to change the font height, everything breaks!) +;; works fine. +(let ((font "Monospace-11")) + (set-fontset-font "fontset-startup" 'ascii font) + (set-fontset-font "fontset-startup" 'unicode font)) (setq inhibit-startup-message t display-time-24hr-format t |