Fc-match does not match bold correctly

fontconfig

For some reason fc-match does not like to match bold fonts:

$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
$ fc-match monospace:bold
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
$ fc-match monospace:weight=200
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"

According to the documentation (https://www.freedesktop.org/software/fontconfig/fontconfig-user.html) bold and weight=200 should be the same, but apparently they are not.

Some applications (especially Java) are using monospace:bold to find the bold monospace font, but they get the normal one which is then artificially emboldened, which looks very ugly.

Edit:
This only happens with fontconfig 2.13.0, which is used by Ubuntu 18.10. Earlier and later version used by 18.04 and 19.04 are fine.

Best Answer

Answer from the questioner in a comment to the question:

After some deep research I found that this is a bug in fontconfig 2.13.0 which is used by Ubuntu 18.10. Neither 2.12.6 used by 18.04 nor 2.13.1 which is apparently used in the upcoming 19.04 have that bug.