Subject: Re: bug#67810: 29.1; fonts use synthetic bold on Linux / pgtk

From: Tim Ruffing <[email-masked]>
Date: Wed, 13 Dec 2023 14:28:58 +0100

On Wed, 2023-12-13 at 14:39 +0200, Eli Zaretskii wrote:  
> I don't think Emacs creates such "synthesized" fonts; are you sure it
> does? I think Emacs just asks fontconfig for a bold font; it has no
> knowledge whether it gets a real or a synthetic font.

Well, *something* in the Emacs font rendering stack creates this bold
variant. font-config can't create it, it's just a config layer but
doesn't handle rendering. I'm really not an expert here with so many
pieces in the stack but AFAIU Cairo can be asked to do so, and will
just delegate to freetype. (Harfbuzz can also do it, see
https://github.com/harfbuzz/harfbuzz/pull/4097 , but I see the bold in
emacs when I configure --without-harfbuzz). 

The thing is: If I query font-config manually, it tells me to use the
regular font and not to embolden it (see below) .Emacs doesn't respect
this. 

So what we should have is a way to disable the emboldening. When I set
my font-config settings such that emboldening is disabled, pango
apparently respects this (as apparent from the font selection dialog)
but emacs doesn't.

A simple font for testing is this one here:
https://www.dafont.com/elronet-monospace.font

$ fc-match "ElroNet Monospace"
Elronmonospace.ttf: "ElroNet Monospace" "Normal"

But even when I ask for bold, there's no difference:

$ fc-match "ElroNet Monospace:bold"
Elronmonospace.ttf: "ElroNet Monospace" "Normal" 

When I have configured font-config to create bold:

$ fc-match "ElroNet Monospace:bold" --verbose | grep bold
	embolden: True(w)

When I haven't:
$ fc-match "ElroNet Monospace:bold" --verbose | grep bold

(no match)