bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#58912: 29.0.50; set-face-attribute call in init.el has no lasting ef


From: Matt Armstrong
Subject: bug#58912: 29.0.50; set-face-attribute call in init.el has no lasting effect
Date: Mon, 31 Oct 2022 19:20:45 -0700

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]