Subject: Re: bug#59347: 29.0.50; `:family` face setting ignored

From: Eli Zaretskii <[email-masked]>
Date: Sat, 19 Nov 2022 17:31:55 +0200

> From: Stefan Monnier <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 19 Nov 2022 09:55:29 -0500
> 
> > Then Emacs does here what we intended it to do: it tries to match the
> > variable-pitch font to the attributes of the default font.  And DejaVu
> > Sans fails that test on your system, because DejaVu Sans doesn't have
> > a variant with the font attributes that are present in misc-fixed font
> > you use as the default face's font.
> 
> Then maybe the problem is the following: I do not consider
> `-misc-fixed-*-r-semicondensed-*-13-*-*-*-*-*-*-*` to include "please
> use non-anti-aliased fonts", contrary to the `-fn monospace:antialias=0`
> of bug#37473?

Antialias attribute is just one of the attributes.  The problem is
much larger and more general than just that single attribute.

> Oh wait... I can recover the behavior I want by selecting
> 
>     :family "DejaVu Sans" :foundry "PfEd"
> 
> so the problem is the foundry info.  Changing the recipe to use
> 
>     -*-fixed-*-r-semicondensed-*-13-*-*-*-*-*-*-*
> 
> doesn't help, OTOH (IOW Emacs insists on preserving the foundry even if
> I did not explicitly request any particular foundry).
> 
> Does it make sense to preserve the `:foundry` attribute when the
> `:family` is different?

I don't know; it might be.

> Is there some way to say `:foundry any` in order to override the
> default's foundry but without having to choose a particular foundry?

We will need to set it to nil where the font spec is passed to
font-selection functions, I guess.

But I'd be happier if you could step through the code and verified
that indeed the foundry mismatch is what causes us to reject DejaVu
Sans, and that after we reject it, we never try it with foundry set to
nil in the font-spec.  Perhaps we first set family to nil and only
after that set foundry to nil?

If this is indeed what happens, I'm okay with adding a variable that
could control whether we try to adhere to foundry in font selection,
and letting people try with it on and off.

Alternatively, why not document that including foundry in the font
spec is the solution to such problems?

> PS: Things become really weird with:
> 
>     src/emacs -Q --eval '(progn (custom-set-faces `(variable-pitch ((t (:family "DejaVu Sans" :foundry "*"))))) (add-to-list `default-frame-alist `(font . "-*-fixed-*-*-semicondensed-*-13-*-*-*-*-*-*-*")) (font-lock-mode -1) (insert (propertize "hello" `face `variable-pitch) " world"))'
> 
> where "hello" ends up with the following font:
> 
>     ftcrhb:-urw-Century Schoolbook L-medium-normal-normal-*-13-*-*-*-*-0-iso10646-1

Why is this weird?