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

From: Eli Zaretskii <[email-masked]>
Date: Sun, 20 Nov 2022 16:59:01 +0200

> Date: Sun, 20 Nov 2022 13:57:48 +0000
> From: Gregory Heytings <[email-masked]>
> cc: Eli Zaretskii <[email-masked]>, [email-masked]
> 
> Stefan, could you please try the attached patch and see if it fixes your 
> problem?  (It does here, with your recipe.)
> 
> Eli, could you please review that patch?

I'd prefer to delay the discussion of this until after Stefan has time to
see why DejaVu Sans is rejected in his cases and describe his findings.

If you already did that, please describe your findings.  AFAIU, Stefan
discovered that the problematic attribute was foundry, and your patch does
nothing about foundry.  It sounds like your patch is for another problem
altogether.

A quick comment wrt the patch itself:

> +  /* If weight is "medium" in SPEC, also try "normal".  Fonts with an
> +     explicit "medium" weight are much less common than fonts with an
> +     explicit "normal" weight, and for a long time "medium" and
> +     "normal" (a.k.a. "regular" a.k.a. "book") were synonymous in
> +     Emacs.  See e.g. bug#59347 and bug#57555.  */
> +  weight[0] = AREF (spec, FONT_WEIGHT_INDEX);
> +  if (EQ (weight[0], Qmedium))
> +    weight[1] = Qnormal, weight[2] = zero_vector;
> +  else
> +    weight[1] = zero_vector;

This is not enough, IMO: you need to make sure the scoring of candidates is
still correct.  For example, if the weights of two candidates differ (normal
vs medium), but sizes are the same or close, how will that compare with
candidates whose weights are identical, but sizes differ?  IOW, we need to
reconsider how font_score scores the candidates.

Thanks.