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

Ken Moffat zarniwhoop at ntlworld.com
Tue Nov 21 20:14:11 UTC 2023

One of my machines has a cheap and nasty monitor. After turning down
the brightness of white backgrounds making my eyes bleed, normal
"black" text is a not-very-dark grey and playing with the contrast
setting doesn't change that.

Now that there are fonts, such as Noto Sans and Noto Serif, with a
full set of weights it would suit me on that machine to use slightly
heavier weights for default Sans, and Serif normal and bold when
rendering web pages that do not specify a font or force a (woff)

Several years ago I knew someone who wanted a less-bold bold font,
so I assume that the converse requirement (detuning normal to light,
etc) might also be useful to some people.

There are old links on google suggesting that such things might have
worked in the past, but do not work any more (it's hard to be sure,
I lack accurate terms for what I'm trying to find out).

I found the following at
which is a bit old but sounded as if it *might* do what I'm looking

 <match target="pattern">
    <test name="family"><string>Iosevka</string></test> 
    <test name="weight" compare="eq"><const>regular</const></test>
    <edit name="weight" mode="assign" binding="strong"><const>semibold</const></edit>
  <match target="pattern">
    <test name="weight" compare="eq"><const>bold</const></test>
    <edit name="weight" mode="assign" binding="strong"><const>heavy</const></edit>

and from that I've added the following to my fonts.conf:

  <!-- try to use different weights of a multiweight font for normal, bold -->
  <match target="pattern">
    <test name="family"><string>Noto Serif</string></test>
    <test name="weight" compare="eq"><const>regular</const></test>
    <edit name="weight" mode="assign" binding="strong"><const>semibold</const></edit>
  <match target="pattern">
    <test name="family"><string>Noto Serif</string></test>
    <test name="weight" compare="eq"><const>bold</const></test>
    <edit name="weight" mode="assign" binding="strong"><const>extrabold</const></edit>

But with a local page showing all installed weights of Noto Serif
the results for normal and bold text seem to be using what css docs
describe as the normal and bold weights, i.e. 400, 700.

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 ?

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 ?

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.

For both firefox and epiphany, the degree of enhanced weight seems
to differ between dark and light modes - but that might be my

2.3 In qt5webengine (falkon) no change.  I've not installed any
other kde apps, so perhaps I'm missing an app to configure it.
And it doesn't seem to accept any envvars to force dark mode.

2.4 For completeness, no change in libreoffice.

Thanks for any help.

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