unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Gregory Heytings <gregory@heytings.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: monnier@iro.umontreal.ca, 59347@debbugs.gnu.org
Subject: bug#59347: 29.0.50; `:family` face setting ignored
Date: Mon, 05 Dec 2022 23:30:48 +0000	[thread overview]
Message-ID: <d0f72095672e1865beb5@heytings.org> (raw)
In-Reply-To: <83tu2b9rlx.fsf@gnu.org>


I did not deserve such a public reprimand.  I do not care at all about 
being right or wrong personally, the only thing I care about here is 
improving Emacs.  I try to be as careful as possible, both in the code I 
write and in the messages I post.  In particular, I avoid posting anything 
that is intentionally insulting, ironical, or even simply humorous.

I already spent an unreasonable amount of time on this bug (I'd say easily 
around 30 hours), although I have no personal interest in seeing it 
resolved: I did not report it (or any of the bugs to which it is related), 
and it does not and cannot affect me (I use the same fixed-pitch font 
everywhere).

Nonetheless, I'll try to answer your questions:

>
> why do you think Emacs must return only variable-pitch fonts for a spec 
> that includes family = Sans Serif?
>

In emacs -Q, the only attribute specified in the variable-pitch face is 
its family: "Sans Serif".  There are three canonical, cross-platform, 
generic font families: "Sans Serif" and "Serif", whose names do not 
contain the word "proportional" or "variable pitch" but which contain only 
variable pitch fonts, and "Monospace", which (as its name implies, and as 
opposed to the Sans Serif and Serif families) contains only fixed pitch 
fonts.  Emacs (by default) only uses the Sans Serif and Monospace generic 
font families.

There is no standard way to make a distiction between monospace fonts with 
and without serifs.  For its fixed-pitch-serif face, which is inherited by 
Info-quoted and tex-verbatim, Emacs 25 invented another generic font 
family: "Monospace Serif".

>
> where and how should Emacs get the indication that only variable-pitch 
> fonts are acceptable in that case?
>

It is not Emacs that decides which fonts correspond to a "family = Sans 
Serif" specification, it is the font driver.  In font_list_entities, Emacs 
passes a font specification to a font driver, which returns a list of 
fonts matching that specification.  When Emacs passes the specification 
"family = Sans Serif" (or "family = Monospace") to the font driver, it 
receives a list of all available fonts in that family back.  If the 
specification passed to font_list_entities contains a non-nil width, 
weight or slant, that list is immediately filtered and all fonts that do 
not match these width, weight or slant exactly are removed from the list.

>
> why do you consider the family attribute of a face be more important 
> than other attributes?  if not all the attributes of a spec are "equal" 
> in their importance, which attributes are more important, and why?
>

Indeed, the attributes are not equal, in fact none of the attributes are 
ever equal in their importance.  The family is the most important one, 
followed by the foundry, the registry, the additional style (in that 
order, see the loop at the end of font_find_for_lface in which Emacs tries 
to make each of these attributes less specific in turn, starting with the 
least important one, namely the additional style), followed by the width, 
height (or size), weight, slant (in the order specified by the variable 
face-font-selection-order).

It is also in that loop (at the end of font_find_for_lface) that 
face-font-family-alternatives are used.  If the generic "Sans Serif", 
"Monospace" and "Monospace Serif" families that Emacs uses are not a 
recognized by the font driver (IOW, if font_list_entities returns an empty 
result for these families), Emacs falls back to some hard-coded, less 
generic, family names.  For example, if "family = Monospace" isn't 
recognized, Emacs tries "family = courier", and if "family = courier" 
isn't recongized either, Emacs tries "family = fixed".  As noted above, 
the "Monospace Serif" family is specific to Emacs, so for that generic 
family name Emacs will always fall back to the less generic family names 
corresponding to that generic family name in that variable.

>
> and if bold is fine when semi-bold was requested, what about other 
> weights, like ultra-light -- are they also okay? if not, why not?
>

Yes, ultra-light is also okay.  If a program requests a font in the Sans 
Serif family with a semi-bold weight, and the only available font on a 
given system in that family is a ultra-light one, it's the best possible 
match for that font specification.  It's up to the user to install a font 
in the Sans Serif family which has a semi-bold variant on their system, if 
they need a font in the Sans Serif family with a semi-bold variant (or to 
install another font that is closer to semi-bold than ultra-light, e.g. 
one with a bold variant).

>
> what are the criteria here and with other similar attributes?
>

The family, foundry, registry and additional style attributes are passed 
"as is" to the font driver, which returns a list of fonts matching these 
attributes.  The width, weight and/or slant are converted to numerical 
values (with font-{width,weight,slant}-table), and font_score, called by 
font_sort_entities, called by font_select_entity, which is applied on the 
list of fonts returned by font_list_entities, selects the best match in 
that list (according the the preferences in face-font-selection-order). 
If the width, weight and/or slant were already passed to 
font_list_entities, the list of fonts passed to font_select_entity 
contains only fonts that match these width, weight and/or slant, and that 
mechanism is bypassed.

In the worst case, the one which is the cause of this bug, when 
font_list_entities is called for example with "family = Sans Serif, weight 
= medium", font_list_entities returns an empty list, even when there are 
plenty of fonts in the Sans Serif families that would be good candidates 
according to the scoring mechanism, and therefore Emacs falls back to 
using face-font-family-alternatives, which is only meant to be used on 
systems in which the generic font families are not recognized.  And in the 
worst of the worst cases, even using face-font-family-alternatives does 
not help (IOW, font_list_entities keeps returning an empty list), in which 
case Emacs falls back to using the default face.





  reply	other threads:[~2022-12-05 23:30 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18  4:57 bug#59347: 29.0.50; `:family` face setting ignored Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 12:37 ` Eli Zaretskii
2022-11-18 14:59   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 15:13     ` Eli Zaretskii
2022-11-18 15:25       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 16:54         ` Eli Zaretskii
2022-11-18 17:21           ` Eli Zaretskii
2022-11-18 20:00             ` Yuan Fu
2022-11-18 20:12               ` Yuan Fu
2022-11-18 21:09                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-19  7:21                   ` Eli Zaretskii
2022-11-18 19:46           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 19:58             ` Eli Zaretskii
2022-11-18 20:55             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-19  7:15               ` Eli Zaretskii
2022-11-19 14:55                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-19 15:31                   ` Eli Zaretskii
2022-11-19 16:01                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-19 16:16                       ` Eli Zaretskii
2022-11-20 13:57                         ` Gregory Heytings
2022-11-20 14:59                           ` Eli Zaretskii
2022-11-20 15:35                             ` Gregory Heytings
2022-11-20 15:54                               ` Eli Zaretskii
2022-11-20 16:59                                 ` Gregory Heytings
2022-11-20 17:29                                   ` Eli Zaretskii
2022-11-20 17:43                                     ` Gregory Heytings
2022-11-20 17:58                                       ` Eli Zaretskii
2022-11-20 18:11                                         ` Gregory Heytings
2022-11-20 18:19                                           ` Eli Zaretskii
2022-11-20 19:45                                             ` Gregory Heytings
2022-11-20 20:01                                               ` Eli Zaretskii
2022-11-20 20:08                                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-20 20:45                                           ` Gregory Heytings
2022-11-21 12:27                                             ` Eli Zaretskii
2022-11-20 18:30                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-20 18:53                                           ` Eli Zaretskii
2022-11-20 18:31                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-20 18:54                                           ` Eli Zaretskii
2022-11-20 21:49                                         ` Gregory Heytings
2022-11-21 12:51                                           ` Eli Zaretskii
2022-11-21 14:48                                             ` Gregory Heytings
2022-11-21 15:08                                               ` Eli Zaretskii
2022-11-21 23:34                                                 ` Gregory Heytings
2022-11-22  0:34                                                   ` Gregory Heytings
2022-11-22  3:05                                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-22  7:59                                                       ` Gregory Heytings
2022-11-22 13:38                                                         ` Eli Zaretskii
2022-11-22 13:46                                                           ` Gregory Heytings
2022-11-22 13:16                                                       ` Eli Zaretskii
2022-11-22 13:38                                                         ` Gregory Heytings
2022-11-22 14:38                                                           ` Eli Zaretskii
2022-11-22 14:45                                                             ` Gregory Heytings
2022-11-22 14:53                                                               ` Eli Zaretskii
2022-11-22 15:41                                                                 ` Gregory Heytings
2022-11-22 17:44                                                                   ` Eli Zaretskii
2022-11-22 20:52                                                                     ` Gregory Heytings
2022-11-22 20:47                                                             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-23  8:13                                                               ` Gregory Heytings
2022-11-30 10:03                                                                 ` Gregory Heytings
2022-11-30 14:00                                                                   ` Eli Zaretskii
2022-11-30 15:38                                                                     ` Gregory Heytings
2022-12-04 14:21                                                                       ` Eli Zaretskii
2022-12-05 23:30                                                                         ` Gregory Heytings [this message]
2022-12-06 14:22                                                                           ` Eli Zaretskii
2022-12-07 11:00                                                                             ` Gregory Heytings
     [not found]                                                                             ` <d99c6016-3b32-1116-9ef1-43fe40a71a4@heytings.org>
2022-12-07 11:02                                                                               ` Gregory Heytings
2022-12-07 23:19                                                                             ` Gregory Heytings
2022-12-08  0:27                                                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-08  1:07                                                                                 ` Gregory Heytings
2022-12-08  8:16                                                                                   ` Eli Zaretskii
2022-12-08 14:59                                                                                     ` Gregory Heytings
2022-12-08 15:13                                                                                       ` Eli Zaretskii
     [not found]                                                                                     ` <e1b79bb2-a3c5-2677-57d8-fb6db43dfd9@heytings.org>
2022-12-08 16:27                                                                                       ` Gregory Heytings
2022-12-08 14:12                                                                                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-08 15:33                                                                                     ` Gregory Heytings
2022-12-08 17:29                                                                                     ` Drew Adams
2022-12-08 17:44                                                                                       ` Eli Zaretskii
2022-12-08  5:32                                                                                 ` Yuan Fu
2022-12-08  8:09                                                                                 ` Eli Zaretskii
2022-12-08 14:17                                                                                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-08 14:49                                                                                     ` Eli Zaretskii
2022-12-08 15:24                                                                                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-08 15:45                                                                                         ` Eli Zaretskii
2022-12-08  8:03                                                                               ` Eli Zaretskii
2022-12-08 12:53                                                                                 ` Gregory Heytings
2022-12-08 14:16                                                                                   ` Eli Zaretskii
2022-12-08 15:17                                                                                     ` Gregory Heytings
2022-12-08 15:42                                                                                       ` Eli Zaretskii
2022-12-10 22:51                                                                                         ` Gregory Heytings
2022-12-12  0:57                                                                                           ` Gregory Heytings
2022-12-12  1:49                                                                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-12  8:54                                                                                               ` Gregory Heytings
2022-12-12 10:33                                                                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-12 10:51                                                                                                   ` Gregory Heytings
2022-12-12 11:18                                                                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-12 11:38                                                                                                       ` Gregory Heytings
2022-12-12 12:47                                                                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-12 15:30                                                                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-12 15:45                                                                                                 ` Eli Zaretskii
2022-12-12 15:07                                                                                             ` Eli Zaretskii
2022-12-12 16:12                                                                                               ` Gregory Heytings
2022-12-12 17:10                                                                                                 ` Eli Zaretskii
2022-12-12 21:28                                                                                                   ` Gregory Heytings
2022-12-13 11:58                                                                                                     ` Eli Zaretskii
2022-12-13  1:16                                                                                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-13 15:40                                                                                                 ` Eli Zaretskii
2022-12-04 14:23                                                                 ` Eli Zaretskii
2022-11-22  6:42                                                     ` Gregory Heytings
2022-11-22  8:01                                                       ` Gregory Heytings
2022-11-22 13:27                                                       ` Eli Zaretskii
2022-11-22 12:38                                                   ` Eli Zaretskii
2022-11-22 12:43                                                     ` Gregory Heytings
2022-11-22 14:29                                                   ` Eli Zaretskii
2022-11-22 14:39                                                     ` Gregory Heytings
2022-11-22 14:52                                                       ` Eli Zaretskii
2022-11-22 15:17                                                         ` Gregory Heytings
2022-11-20 18:16                           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-20 19:46                             ` Gregory Heytings
2022-11-19  0:20 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-19  0:28   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-19  4:37     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-19  6:01       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-19 14:17         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d0f72095672e1865beb5@heytings.org \
    --to=gregory@heytings.org \
    --cc=59347@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).