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

From: Eli Zaretskii <[email-masked]>
Date: Wed, 13 Dec 2023 14:39:36 +0200

> From: Tim Ruffing <[email-masked]>
> Date: Wed, 13 Dec 2023 13:03:47 +0100
> 
> To reproduce:
>    1. `emacs` -Q on Linux with pgtk enabled
>    2. `M-x select-frame-font` and select a font that doesn't have a
>       bold weight
>    3. Observe that the buffer indicator (`*scratch*`) in the status
>       line is in bold (using synthetic bold glyphs)
> 
> This is annoying in combination with symbol fonts such as Nerd fonts.
> The bold versions of some symbols look strange, and worse, they may be
> too wide to fit two glyphs and are clipped then.
> 
> What I have tried:
>  * I thought this is a font-config thing. /etc/fonts/conf.d by default
>    has a symlink 90-synthetic.conf that sets the "embolden" attribute
>    for font queries that ask for a bold font but only regular is
>    available. Removing that symlink does make a difference when I try
>    `fc-match "MY-FONT:weight=bold" --verbose | grep bold`. With the
>    symlink, fc sets the embolden attribute, and without the symlink, it
>    doesn't. I can even see the difference in emacs' (Pango) font
>    selection dialog. But emacs itself doesn't seem to care about this
>    and still creates a synthesized bold font. 
>  * Cairo is supposed to pick this attribute up [1] and act accordingly,
>    but that doesn't work. I tried to add a printf("synthesize: %d\n",
>    cairo_ft_font_face_get_synthesize(font_face)); to the current emacs
>    git (75fd7550ed6cede6c9e8224f1f2d62637c43fdd4) in ftcrfont_open, and
>    this always prints "0" (even with the symlink in place!). AFAIU this
>    means that Cairo should never embolden fonts, but some reason
>    there's something in emacs that does it.  
>  * describe-font only shows the medium/regular variant.  

Thanks, but why do you think this is an issue for Emacs to solve?  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.