Skip to content

Commit

Permalink
core-fonts-support: Don't fiddle with user's face Customization
Browse files Browse the repository at this point in the history
Fixes syl20bnr#5353.

Related:
emacs-mirror/emacs@eae23d6
https://emacs.stackexchange.com/questions/33403/customize-creates-custom-set-faces-unintentionally

An alternative strategy is to call `(set-frame-font fontspec nil nil)`.
This will work on any emacs version, and this will also inhibit
fiddling with the Customization. But this will apply the font setting
only to the current frame. While this *should* be okay (because when this
code runs, only the current frame should be graphical and thus relevant
when it comes to font changes), I'm not convinced that this analysis is
correct, and that it's a good idea to rely on this fact.
  • Loading branch information
real-or-random committed Aug 25, 2023
1 parent dffa67a commit 4583904
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/core-fonts-support.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ The return value is nil if no font was found, truthy otherwise."
:powerline-offset))
(fontspec (apply 'font-spec :name font font-props)))
(spacemacs-buffer/message "Setting font \"%s\"..." font)
(set-frame-font fontspec nil t)
;; We set the INHIBIT-CUSTOMIZE parameter to t to tell set-frame-font
;; not to fiddle with the default face in the user's Customization
;; settings. We don't need Customization because our way of ensuring
;; that the font is applied to future frames is to modify
;; default-frame-alist, and Customization causes issues, see
;; https://github.com/syl20bnr/spacemacs/issues/5353.
;; INHIBIT-CUSTOMIZE is only present in recent emacs versions.
(if (version< emacs-version "28.0.90")
(set-frame-font fontspec nil t)
(set-frame-font fontspec nil t t))
(push `(font . ,(frame-parameter nil 'font)) default-frame-alist)
;; fallback font for unicode characters used in spacemacs
(pcase system-type
Expand Down

0 comments on commit 4583904

Please sign in to comment.