unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
@ 2021-12-30 20:17 Dima Kogan
  2021-12-31  7:26 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Dima Kogan @ 2021-12-30 20:17 UTC (permalink / raw)
  To: 52905

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!





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
  2021-12-30 20:17 bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist" Dima Kogan
@ 2021-12-31  7:26 ` Eli Zaretskii
  2021-12-31  7:34   ` Dima Kogan
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2021-12-31  7:26 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 52905

> From: Dima Kogan <dima@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.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
  2021-12-31  7:26 ` Eli Zaretskii
@ 2021-12-31  7:34   ` Dima Kogan
  2021-12-31  8:15     ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Dima Kogan @ 2021-12-31  7:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52905

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!





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
  2021-12-31  7:34   ` Dima Kogan
@ 2021-12-31  8:15     ` Eli Zaretskii
  2021-12-31  8:24       ` Dima Kogan
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2021-12-31  8:15 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 52905

> From: Dima Kogan <dima@secretsauce.net>
> Cc: 52905@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
  2021-12-31  8:15     ` Eli Zaretskii
@ 2021-12-31  8:24       ` Dima Kogan
  2021-12-31 13:10         ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Dima Kogan @ 2021-12-31  8:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52905

Eli Zaretskii <eliz@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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
  2021-12-31  8:24       ` Dima Kogan
@ 2021-12-31 13:10         ` Eli Zaretskii
  2022-01-01 19:07           ` Dima Kogan
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2021-12-31 13:10 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 52905

> From: Dima Kogan <dima@secretsauce.net>
> Cc: 52905@debbugs.gnu.org
> Date: Fri, 31 Dec 2021 00:24:53 -0800
> 
> Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
  2021-12-31 13:10         ` Eli Zaretskii
@ 2022-01-01 19:07           ` Dima Kogan
  2022-01-01 20:28             ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Dima Kogan @ 2022-01-01 19:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52905

Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
  2022-01-01 19:07           ` Dima Kogan
@ 2022-01-01 20:28             ` Eli Zaretskii
  2022-01-01 20:32               ` Dima Kogan
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2022-01-01 20:28 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 52905

> From: Dima Kogan <dima@secretsauce.net>
> Cc: 52905@debbugs.gnu.org
> Date: Sat, 01 Jan 2022 11:07:50 -0800
> 
> Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist"
  2022-01-01 20:28             ` Eli Zaretskii
@ 2022-01-01 20:32               ` Dima Kogan
  0 siblings, 0 replies; 9+ messages in thread
From: Dima Kogan @ 2022-01-01 20:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52905-done

Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-01-01 20:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30 20:17 bug#52905: 29.0.50; "fixed-pitch" face doesn't respect the font in "default-frame-alist" Dima Kogan
2021-12-31  7:26 ` Eli Zaretskii
2021-12-31  7:34   ` Dima Kogan
2021-12-31  8:15     ` Eli Zaretskii
2021-12-31  8:24       ` Dima Kogan
2021-12-31 13:10         ` Eli Zaretskii
2022-01-01 19:07           ` Dima Kogan
2022-01-01 20:28             ` Eli Zaretskii
2022-01-01 20:32               ` Dima Kogan

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).