emacs-devel
[Top][All Lists]
Advanced

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

Re: Incorrect font weight selected


From: Eli Zaretskii
Subject: Re: Incorrect font weight selected
Date: Sat, 18 Dec 2021 13:41:52 +0200

> From: Yuri D'Elia <wavexx@thregr.org>
> Cc: emacs-devel@gnu.org
> Date: Sat, 18 Dec 2021 11:43:25 +0100
> 
> 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 don't know.

I don't have access to any system where this happens, so I cannot step
through the code to see what happens there.  You (or someone else) are
welcome to do that and see what happens there.  Maybe we will then be
able to make this less surprising and confusing.

> 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?

Yes.

> 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.

You could use a simple flag variable for that.

> 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.

Welcome to the club.  The code which selects fonts in Emacs is quite
complex and notoriously under-documented.  On top of that, we don't
have any experts on board who are familiar with that code and can
readily answer questions such as this one.  The only way to
investigate is to step through the code, starting in xfaces.c (where
we process set-face-attribute), and following into font.c and
fontset.c, where the font selection actually happens.



reply via email to

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