[Fontconfig] Can I specify different weights for normal and bold ?

Ken Moffat zarniwhoop at ntlworld.com
Wed Nov 22 14:47:42 UTC 2023

On Wed, Nov 22, 2023 at 05:55:58PM +0900, Akira TAGOH wrote:
> On Wed, Nov 22, 2023 at 5:22 AM Ken Moffat <zarniwhoop at ntlworld.com> wrote:
> > Is it possible to change the default weights of a locally-installed
> > font ?  If not, it seems to me that installing anything other than
> > normal and bold is a waste of time unless you are creating a web
> > page using specific weights, and for that you probably want to use
> > woff fonts ?
> Some applications may rely on "style" property to lookup a font. If
> you modify it, the result may be more robust. However, It may not even
> work if a font file picked up by fontconfig contains multiple variants
> and applications do the real job with the low-level APIs, because we
> can't modify metadata in a font.


> >
> > I have noticed so far in perhaps-related things:
> >
> > 1. In libreoffice writer (7.5) Noto Serif appears as separate fonts for
> > (regular), Black, ExtraBold, Light, Medium, SemiBold (I didn't
> > install any weights less than light) which implies they are treated
> > as different fonts ?
> I'm not sure what exactly "different fonts" means here though, some
> applications have their own font management and take care of a variant
> of the font family such as Noto Sans Regular, Noto Sans Medium, Noto
> Sans Bold as one font family literally such as Noto Sans.
> Unfortunately this isn't a feature provided by fontconfig so far.
> If they don't identify them that way, they just recognize them as it is.

I was expecting to see one font name for 'Noto Serif' (and I've
always assumed, perhaps wrongly, that toggling bold in the writer
document picks up the bold font).  With multiple font files for
individual weights, each now appears in libreoffices's list of fonts
as if it is a different font.

> > 2. Attempting to force emboldening on some very faint fonts, such as
> > FreeSerif, (with attempts to also address weight "for non-cairo
> > apps") the results differ greatly:
> >
> > 2.1 In firefox, both normal and bold are now bold (the non-cairo
> > part is needed).
> >
> > 2.2 In webkitgtk (epiphany) both normal and bold become heavier on
> > *some* fonts - sometimes bold becomes Heavy and ugly, other times it
> > looks usable.  Yes, I realise that embolden is intended to cater for
> > fonts that lack a bold variant, but nothing ventured, nothing gained.
> That really depends on fonts. and is completely out of the scope for
> fontconfig. fontconfig doesn't get involved with the rendering part at
> all.

> -- 
> Akira TAGOH

True, except that it sets something up when using synthetic
embolden, and then applications take or leave that as they please.

I *think* I've now got a partial solution to making a font and the
bold weight a bit darker, or to making bold a bit lighter, or to
making normal text (together with is tmarked up as bold) lighter
than normal.  Fontconfig does a best-match search.  If I only
install two weights of the font, a weight of medium or semibold will
be used for normal text, the next bolder weight will be used for
bold text.

For detuning, if no match equal to or bolder is found, a downward
search takes the first lighter font.  So, to detune bold, install
semibold alongside normal (and no other variants of the font).

In the same way, if someone wants to use a lighter font for 'normal'
they can install only the light weight (any heavier weight would be
used for both 'normal' and 'bold' because upward searches are

So far, only minimally tested looking at what fontconfig reports, I
need to drop out of xfce each time I make a fresh test.

This is magic for grown-ups; it has to be hard because we know there's
no such thing as a free goblin.
   -- Pratchett, Stewart & Cohen - The Science of Discworld II

More information about the Fontconfig mailing list