GNU bug report logs -
#58912
29.0.50; set-face-attribute call in init.el has no lasting effect
Previous Next
Reported by: Dmitry Gutov <dgutov <at> yandex.ru>
Date: Mon, 31 Oct 2022 00:45:02 UTC
Severity: normal
Merged with 59271,
59283
Found in version 29.0.50
Done: Po Lu <luangruo <at> yahoo.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Matt Armstrong <matt <at> rfc20.org> writes:
> I see the same symptoms as Dmitry. I'm running a current Debian Testing
> system, Gnome, Wayland.
>
> Namely:
>
> 1) emacs -Q --> the 'default font family is the Gnome system monospace font.
>
> 2) emacs -Q -l test.el --> still uses the Gnome system mono font despite
> setting the 'default face otherwise early in init.
>
> I changed the .el file to this:
>
> (set-face-attribute
> 'default nil :height 110 :weight 'semi-light :family
> "Cascadia Mono")
> (debug-on-entry #'set-face-attribute)
>
> And the origin of the font change back to the system defaults is this:
>
> Debugger entered--entering a function:
> * set-face-attribute(default #<frame *scratch* - GNU Emacs at naz 0x55ad505df290> :width normal :weight normal :slant normal :font "Go Mono 11")
> font-setting-change-default-font(":0" nil)
> dynamic-setting-handle-config-changed-event((config-changed-event font-render ":0"))
> funcall-interactively(dynamic-setting-handle-config-changed-event (config-changed-event font-render ":0"))
> call-interactively(dynamic-setting-handle-config-changed-event nil [(config-changed-event font-render ":0")])
> command-execute(dynamic-setting-handle-config-changed-event nil [(config-changed-event font-render ":0")] t)
>
> It looks like `font-setting-change-default-font' is pulling the system
> font (in my case "Go Mono") from the frame, which probably wasn't
> modified by the earlier `set-face-attribute` call. To confirm I changed
> test.el to this:
>
> (set-face-attribute
> 'default nil :height 110 :weight 'semi-light :family
> "Cascadia Mono")
> (dolist (frame (frame-list))
> (let ((frame-font
> (or (font-get (face-attribute 'default :font frame 'default)
> :user-spec)
> (frame-parameter frame 'font-parameter))))
> (message "frame %S frame-font %S" frame frame-font)))
>
> And re-run "emacs -Q -l test.el" and get this in *Messages*:
>
> frame #<frame *scratch* - GNU Emacs at naz 0x55d8362ca7f0> frame-font "Go Mono 11"
>
> So I change test.el yet again to have only this:
>
> (set-frame-font "Cascadia Mono")
>
> ...and that font change sticks. `set-frame-font` is what is called by
> the Options -> Set Default Font menu item and has logic to walk through
> frames and set their parameters accordingly.
>
> And again to have only this:
>
> (set-frame-font (font-spec :height 110
> :weight 'semi-light
> :family "Cascadia Mono"))
>
>
> ...I wonder if setting the 'default face attribute in 'early-init.el'
> would be enough, too.
Doesn't it only do that if font-use-system-font is t? Here is the
relevant part of dynamic-setting.el:
;; Just redraw the existing fonts on all frames:
(dolist (f frame-list)
(let ((frame-font
(or (font-get (face-attribute 'default :font f 'default)
:user-spec) <=====
this should return "Cascadia Mono"... what does it return for you?
This bug report was last modified 2 years and 185 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.