How to Fix Default Fonts Problem on Firefox
Most of the websites are using Helvetica as an alternative font, and Ubuntu is trying to set Nimbus Sans as a similar font even you have Helvetica font. Also, the default font on Firefox is DejaVu Sans, but the default fonts are working just if the styles don’t specify a font family in a website.
Nimbus Sans comes with fonts-urw-base35 package, and it’s ubuntu-desktop‘s dependency, direct or indirect. I need ubuntu-desktop to use GNOME, so the best solution here is to disable the font altogether and refresh the fonts cache.
Let’s go step by step. First of all, if you don’t have it yet, start with installing ttf-mscorefonts-installer package, Arial is the best alternative font for Helvetica, and it comes with that package. Then, confirm if the system finds Nimbus Sans as an alternative font for Helvetica:
$ fc-match "Helvetica" NimbusSans-Regular.otf: "Nimbus Sans" "Regular"
Ok, so we’re sure that we understood the problem correctly. We will try to
reject that weird font and recheck the output until it finds Arial. To do that,
we need to create a
fonts.conf file and keep it on the correct path. On my
Ubuntu (20.04), the path will be
~/.config/fontconfig/fonts.conf, but if
you’re using a different distribution, learn the correct path from Google.
After you created the file, fill it with these lines:
<selectfont> <rejectfont> <patelt name="family"> <string>Nimbus Sans</string> </patelt> </rejectfont> </selectfont>
Then, let’s clear the fonts cache and recheck the fc-match output:
$ fc-cache -rv $ fc-match "Helvetica" n019003l.pfb: "Nimbus Sans L" "Regular"
Okay, yet another weird font. Let’s ignore this font too and try again:
<selectfont> <rejectfont> <patelt name="family"> <string>Nimbus Sans</string> </patelt> </rejectfont> <rejectfont> <patelt name="family"> <string>Nimbus Sans L</string> </patelt> </rejectfont> </selectfont>
$ fc-cache -rv $ fc-match "Helvetica" Arial.ttf: "Arial" "Regular"
Finally! Now we can restart the Firefox and check the fonts on the browser: