emacs-devel
[Top][All Lists]
Advanced

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

Re: Incorrect font weight selected


From: Yuri D'Elia
Subject: Re: Incorrect font weight selected
Date: Sat, 18 Dec 2021 11:43:25 +0100
User-agent: mu4e 1.7.5; emacs 29.0.50

On Sat, Dec 18 2021, Eli Zaretskii wrote:
>> When I revert commit 1b2511fa2aed460120a36765ba16c14e355eef1d then the
>> 'medium weight is selected correctly in both scenarios.
>
> In a daemon session, you are supposed to put such customizations in
> the server-after-make-frame-hook.  If you do that, does it work as
> expected?  Before a GUI frame is created, customizations of faces and
> fonts doesn't work as you'd expect because the GUI system may not be
> available yet (the frame which the daemon has is basically a surrogate
> TTY frame).

I understand this, however I really fail to see how this explains the
behavior.

I would understand if it didn't resolve the font family at all,
or it didn't set the correct resolution according to the current
fontconfig settings for example, but it does both correctly.

Why would it change only the weight selection?

I assumed that when setting the default font (by calling
set-face-attribute with FRAME set to nil) the actual face selection
would be effectively delayed until frame creation time. I guess this is
incorrect - i/e font selection is done immediately?

> The commit you point to made font selection more lenient wrt medium vs
> regular, so I'd be surprised if it prevented some weight selection.  I
> believe it previously worked for you by sheer luck.

As I was adjusting the code to move my setup into an after-make-frame
hook, I noticed another subtlety:

Assuming the following skeleton:

(add-hook 'server-after-make-frame-hook
  (lambda ()
    (set-face-attribute 'default FRAME ...)))

I get different results if FRAME is t or nil.

Ideally I'd want nil (default). If I do that, it seems to work
correctly. However in such case I'd also need to ensure I call this hook
once, not for every frame (the main reason I didn't bother calling this
in a make-frame hook) and gets slower as I add frames.

If I use "t" to set the current frame only, I get a completely different
font size: smaller in fact. However, this only holds if I _never_ set
the "default frame".

If I evaluate instead:

(set-face-attribute 'default nil ...)
(set-face-attribute 'default t ...)

where "..." is the same face selection. In such case, setting the
default frame somewhat alters permanently what setting the current frame
will do. The second call to set-face-attribute doesn't give me the
smaller face, instead it gives me the same face twice.

I'm totally confused as of why this happens.



reply via email to

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