GNU bug report logs - #52905
29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Thu, 30 Dec 2021 20:18:02 UTC

Severity: normal

Found in version 29.0.50

Done: Dima Kogan <dima <at> secretsauce.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 52905 in the body.
You can then email your comments to 52905 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#52905; Package emacs. (Thu, 30 Dec 2021 20:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dima Kogan <dima <at> secretsauce.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 30 Dec 2021 20:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; "fixed-pitch" face doesn't respect the font in
 "default-frame-alist"
Date: Thu, 30 Dec 2021 12:17:44 -0800
Hi. I'm running a very recent emacs snapshot from 2021/12/19:
0bc2900bbcb. I'm on Debian GNU/Linux, using the GTK-based build on X.

In the last few months I've been observing some font handling updates in
emacs that cause an inconsistency with the way things are displayed. As
suggested by the emacs documentation, I set the font I want by touching
default-frame-alist. The docs are here:

  https://www.gnu.org/software/emacs/manual/html_node/emacs/Fonts.html

I've had this setting in my .emacs for many years. Today this isn't
respected everywhere. A recipe:

  emacs -Q --eval \
  "(progn
     (setf (alist-get 'font default-frame-alist)
       \"-adobe-courier-medium-r-*-*-14-*-*-*-*-*-iso8859-*\")
   (org-mode)
   (insert \"abc\\n#+begin_\"))"

Here I start up emacs without .emacs, but with some default-frame-alist
setting. I enter org-mode and insert some text.

Invoking C-u C-x = on any of "abc" tells me that no particular face is
active there, and that my default font is being used.

Invoking C-u C-x = on any of "#+begin_" tells me that the org-meta-line
face is active there. This face ultimately derives from the fixed-pitch
face, which uses a different monospace font: ftcrhb:-Bits-Bitstream Vera
Sans Mono-regular-normal-normal-*-14-*-*-*-m-0-iso10646-1.

But I already selected a monospaced font in default-frame-alist, so I
expect to get the same font here, which was the case for many years. The
fixed-pitch face is defined like this in faces.el:

  (defface fixed-pitch
    '((t :family "Monospace"))
    "The basic fixed-pitch face."
    :group 'basic-faces)

I can "fix" this by resetting the fixed-pitch face to use the default:

  (defface fixed-pitch
    '((t))
    "The basic fixed-pitch face."
    :group 'basic-faces)


So is this a "bug"? Is this a documentation problem? Setting the default
font to a monospace font, as described by the emacs docs should end up
being picked up by the fixed-pitch face.

Thanks!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52905; Package emacs. (Fri, 31 Dec 2021 07:27:01 GMT) Full text and rfc822 format available.

Message #8 received at 52905 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 52905 <at> debbugs.gnu.org
Subject: Re: bug#52905: 29.0.50;
 "fixed-pitch" face doesn't respect the font in "default-frame-alist"
Date: Fri, 31 Dec 2021 09:26:44 +0200
> From: Dima Kogan <dima <at> secretsauce.net>
> Date: Thu, 30 Dec 2021 12:17:44 -0800
> 
> In the last few months I've been observing some font handling updates in
> emacs that cause an inconsistency with the way things are displayed. As
> suggested by the emacs documentation, I set the font I want by touching
> default-frame-alist. The docs are here:
> 
>   https://www.gnu.org/software/emacs/manual/html_node/emacs/Fonts.html
> 
> I've had this setting in my .emacs for many years. Today this isn't
> respected everywhere. A recipe:
> 
>   emacs -Q --eval \
>   "(progn
>      (setf (alist-get 'font default-frame-alist)
>        \"-adobe-courier-medium-r-*-*-14-*-*-*-*-*-iso8859-*\")
>    (org-mode)
>    (insert \"abc\\n#+begin_\"))"
> 
> Here I start up emacs without .emacs, but with some default-frame-alist
> setting. I enter org-mode and insert some text.
> 
> Invoking C-u C-x = on any of "abc" tells me that no particular face is
> active there, and that my default font is being used.
> 
> Invoking C-u C-x = on any of "#+begin_" tells me that the org-meta-line
> face is active there. This face ultimately derives from the fixed-pitch
> face, which uses a different monospace font: ftcrhb:-Bits-Bitstream Vera
> Sans Mono-regular-normal-normal-*-14-*-*-*-m-0-iso10646-1.
> 
> But I already selected a monospaced font in default-frame-alist, so I
> expect to get the same font here, which was the case for many years. The
> fixed-pitch face is defined like this in faces.el:
> 
>   (defface fixed-pitch
>     '((t :family "Monospace"))
>     "The basic fixed-pitch face."
>     :group 'basic-faces)
> 
> I can "fix" this by resetting the fixed-pitch face to use the default:
> 
>   (defface fixed-pitch
>     '((t))
>     "The basic fixed-pitch face."
>     :group 'basic-faces)
> 
> 
> So is this a "bug"? Is this a documentation problem? Setting the default
> font to a monospace font, as described by the emacs docs should end up
> being picked up by the fixed-pitch face.

You seem to assume that the default face's font is also the font
used by the fixed-pitch face?  There's no basis for this assumption:
as long as a face defines :font or :family attributes, the font for
that face is selected independently.  The "Monospace" family
doesn't stand for "the monospace font selected fro thedefault face",
it stands for some font that belongs to the "Monospace" family.  What
exactly does that family include depends on your font back-end and the
fonts installed on your system, but Vera Sans Mono doesn't sound like
it shouldn't be in that family, it sounds right to me.

So, given the data you presented, I don't yet see any bug, but a
well-documented and expected behavior.  If you want the same font for
the fixed-pitch face, you should customize that face as well, e.g. by
using set-face-attribute, to set its font attribute, or by using
set-face-font directly.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52905; Package emacs. (Fri, 31 Dec 2021 07:54:02 GMT) Full text and rfc822 format available.

Message #11 received at 52905 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 52905 <at> debbugs.gnu.org
Subject: Re: bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font
 in "default-frame-alist"
Date: Thu, 30 Dec 2021 23:34:58 -0800
Hi Eli.

Broadly-speaking the complaint is:

  I've been doing what the docs tell me to do for many years, and it has
  been looking nice for many years, and now it doesn't look nice
  anymore

I just looked at version control, and the thing that actually made
things weird in THIS case is the update to org 9.5:

  https://github.com/emacs-mirror/emacs/commit/bf9ec3d91a79414deac039f7bf83352a9b0a9a85

It made the org-meta-line face inherit from "fixed-pitch", which is
fine. More notes follow...


> You seem to assume that the default face's font is also the font
> used by the fixed-pitch face?  There's no basis for this assumption:
> as long as a face defines :font or :family attributes, the font for
> that face is selected independently.  The "Monospace" family
> doesn't stand for "the monospace font selected fro thedefault face",
> it stands for some font that belongs to the "Monospace" family.  What
> exactly does that family include depends on your font back-end and the
> fonts installed on your system, but Vera Sans Mono doesn't sound like
> it shouldn't be in that family, it sounds right to me.

Yes. That is exactly what it's doing today. But it isn't nice. If emacs
has a "default" font, and that font happens to be a fixed-pitch font,
then the "fixed-pitch" face should use that default font. Otherwise, the
"default" font choice is ignored in arbitrary places, creating a poor
user experience. I think the ways to fix this are:

1. Not having a default font at all

2. Some logic that vaguely does (in pseudo-code):

   (set-font-for-face
     fixed-pitch
     (if (font-is-fixed-p default-font)
       default-font
       (get-some-fixed-pitch-font)))

   (set-font-for-face
     variable-pitch
     (if (font-is-variable-p default-font)
       default-font
       (get-some-variable-pitch-font)))

   Is there an easy, reliable way to tell if a given font is fixed or
   not? If so, this would be a good way to honor the user's choice of
   default font.

Thanks!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52905; Package emacs. (Fri, 31 Dec 2021 08:16:01 GMT) Full text and rfc822 format available.

Message #14 received at 52905 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 52905 <at> debbugs.gnu.org
Subject: Re: bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font
 in "default-frame-alist"
Date: Fri, 31 Dec 2021 10:15:40 +0200
> From: Dima Kogan <dima <at> secretsauce.net>
> Cc: 52905 <at> debbugs.gnu.org
> Date: Thu, 30 Dec 2021 23:34:58 -0800
> 
> I just looked at version control, and the thing that actually made
> things weird in THIS case is the update to org 9.5:
> 
>   https://github.com/emacs-mirror/emacs/commit/bf9ec3d91a79414deac039f7bf83352a9b0a9a85
> 
> It made the org-meta-line face inherit from "fixed-pitch", which is
> fine.

So this is why it stopped to work for you: Org now uses a different
parent face for its faces.  This has nothing to do with how Emacs
selects fonts for faces.

> Yes. That is exactly what it's doing today. But it isn't nice. If emacs
> has a "default" font, and that font happens to be a fixed-pitch font,
> then the "fixed-pitch" face should use that default font.

I respectively disagree.  The fixed-pitch face exists to be able to
specify a different fixed-pitch font for text that needs to have a
distinctly different appearance.  It makes little sense to me to
make it use the same font as the default face.

> Otherwise, the "default" font choice is ignored in arbitrary places,
> creating a poor user experience.

Lisp programs that want to avoid that should not use a different face,
or should tell users to customize the respective faces if they want
the same font as for the default face.

> I think the ways to fix this are:

Thanks, but I don't think we should fix this.  I see no problem to
fix.  The fixed-pitch face is designed to have a distinct font.

>    Is there an easy, reliable way to tell if a given font is fixed or
>    not?

You could apply heuristics based on SPACE-WIDTH and AVERAGE-WIDTH
values returned by font-info.  But basically, I don't think you can
know for sure.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52905; Package emacs. (Fri, 31 Dec 2021 08:34:01 GMT) Full text and rfc822 format available.

Message #17 received at 52905 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 52905 <at> debbugs.gnu.org
Subject: Re: bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font
 in "default-frame-alist"
Date: Fri, 31 Dec 2021 00:24:53 -0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> Thanks, but I don't think we should fix this.  I see no problem to
> fix.  The fixed-pitch face is designed to have a distinct font.

OK. Can we then at least update the docs? This page:

  https://www.gnu.org/software/emacs/manual/html_node/emacs/Fonts.html

That page tells the user how to change the font, but don't say anything
about when that setting will be respected. The current behavior of emacs
completely ignoring this setting when picking the "fixed-pitch" and
"variable-pitch" fonts feels like it should be noted on that page.

Is using the default-frame-alist to set the default font still our
recommended best practice? Is that what you do?

Thanks




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52905; Package emacs. (Fri, 31 Dec 2021 13:11:02 GMT) Full text and rfc822 format available.

Message #20 received at 52905 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 52905 <at> debbugs.gnu.org
Subject: Re: bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font
 in "default-frame-alist"
Date: Fri, 31 Dec 2021 15:10:05 +0200
> From: Dima Kogan <dima <at> secretsauce.net>
> Cc: 52905 <at> debbugs.gnu.org
> Date: Fri, 31 Dec 2021 00:24:53 -0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Thanks, but I don't think we should fix this.  I see no problem to
> > fix.  The fixed-pitch face is designed to have a distinct font.
> 
> OK. Can we then at least update the docs? This page:
> 
>   https://www.gnu.org/software/emacs/manual/html_node/emacs/Fonts.html
> 
> That page tells the user how to change the font, but don't say anything
> about when that setting will be respected.

You mean, to say explicitly that "the default font" in that node means
"the font of the default face"?

> The current behavior of emacs
> completely ignoring this setting when picking the "fixed-pitch" and
> "variable-pitch" fonts feels like it should be noted on that page.

That behavior is not specific to these faces, it happens with any face
which specifies a font.

> Is using the default-frame-alist to set the default font still our
> recommended best practice? Is that what you do?

Yes and yes.  It's just that you seem to interpret "the default font"
differently from what it was supposed to mean.  It means the font of
the default face.  Any face that doesn't specify a font or some font
attribute will use the same font, but faces that do specify those
attributes can (and usually do) select other fonts.  To affect the
font of the faces which specify font attributes, you need to customize
those faces separately from the default face and default-frame-alist.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52905; Package emacs. (Sat, 01 Jan 2022 20:22:02 GMT) Full text and rfc822 format available.

Message #23 received at 52905 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 52905 <at> debbugs.gnu.org
Subject: Re: bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font
 in "default-frame-alist"
Date: Sat, 01 Jan 2022 11:07:50 -0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Is using the default-frame-alist to set the default font still our
>> recommended best practice? Is that what you do?
>
> Yes and yes.  It's just that you seem to interpret "the default font"
> differently from what it was supposed to mean.  It means the font of
> the default face.  Any face that doesn't specify a font or some font
> attribute will use the same font, but faces that do specify those
> attributes can (and usually do) select other fonts.  To affect the
> font of the faces which specify font attributes, you need to customize
> those faces separately from the default face and default-frame-alist.

Hi. Let's talk about this part first. Clearly the manual says what you
describe, and I clearly see how it came to be this way. It makes perfect
sense from the viewpoint of the dev that wrote the logic and the docs.

As a user, this doesn't feel right to me, though. Can we talk about
that? Then we can agree on what, if anything, needs fixing.

Do you use org? Are you seeing a different fonts in the body of the
document compared to the #+begin_... lines? If so, does this bug you?
The org devs said

  #+begin_... lines should be rendered with the fixed-pitch face font

I suspect that what they MEANT was

  #+begin_... lines should be rendered with a fixed pitch font

I suspect this because that's what I would have meant if I wrote it. IF
this is what was intended and IF the default font had a fixed pitch,
then I think it makes sense for emacs to use the default font here.

If you're seeing the two different fonts, and you think that's fine,
then I'll just fix this in my .emacs, and we can be done.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52905; Package emacs. (Sat, 01 Jan 2022 20:29:01 GMT) Full text and rfc822 format available.

Message #26 received at 52905 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 52905 <at> debbugs.gnu.org
Subject: Re: bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font
 in "default-frame-alist"
Date: Sat, 01 Jan 2022 22:28:34 +0200
> From: Dima Kogan <dima <at> secretsauce.net>
> Cc: 52905 <at> debbugs.gnu.org
> Date: Sat, 01 Jan 2022 11:07:50 -0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> Is using the default-frame-alist to set the default font still our
> >> recommended best practice? Is that what you do?
> >
> > Yes and yes.  It's just that you seem to interpret "the default font"
> > differently from what it was supposed to mean.  It means the font of
> > the default face.  Any face that doesn't specify a font or some font
> > attribute will use the same font, but faces that do specify those
> > attributes can (and usually do) select other fonts.  To affect the
> > font of the faces which specify font attributes, you need to customize
> > those faces separately from the default face and default-frame-alist.
> 
> Hi. Let's talk about this part first. Clearly the manual says what you
> describe, and I clearly see how it came to be this way. It makes perfect
> sense from the viewpoint of the dev that wrote the logic and the docs.
> 
> As a user, this doesn't feel right to me, though. Can we talk about
> that? Then we can agree on what, if anything, needs fixing.
> 
> Do you use org? Are you seeing a different fonts in the body of the
> document compared to the #+begin_... lines? If so, does this bug you?
> The org devs said
> 
>   #+begin_... lines should be rendered with the fixed-pitch face font
> 
> I suspect that what they MEANT was
> 
>   #+begin_... lines should be rendered with a fixed pitch font

No, I think they meant what they said.

> I suspect this because that's what I would have meant if I wrote it. IF
> this is what was intended and IF the default font had a fixed pitch,
> then I think it makes sense for emacs to use the default font here.
> 
> If you're seeing the two different fonts, and you think that's fine,
> then I'll just fix this in my .emacs, and we can be done.

Yes, I think it is fine to see 2 different fonts in this case.  Once
again, the reason is that the fixed-pitch face specifies its own font.




Reply sent to Dima Kogan <dima <at> secretsauce.net>:
You have taken responsibility. (Sat, 01 Jan 2022 20:34:01 GMT) Full text and rfc822 format available.

Notification sent to Dima Kogan <dima <at> secretsauce.net>:
bug acknowledged by developer. (Sat, 01 Jan 2022 20:34:01 GMT) Full text and rfc822 format available.

Message #31 received at 52905-done <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 52905-done <at> debbugs.gnu.org
Subject: Re: bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font
 in "default-frame-alist"
Date: Sat, 01 Jan 2022 12:32:53 -0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> Yes, I think it is fine to see 2 different fonts in this case. Once
> again, the reason is that the fixed-pitch face specifies its own font.

Alright. I'll fix this on my end. I'm closing the issue. Thanks for
discussing it.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 30 Jan 2022 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.