22

My font rendering in Firefox looks terrible on pages such as facebook.com and twitter.com:

enter image description here

I'm running Debian 8 and fiddling with hardware acceleration, and it doesn't seem to work.

tshepang
  • 64,472
  • 86
  • 223
  • 290
user241948
  • 323
  • 1
  • 2
  • 4

5 Answers5

38

I've had this issue for ages, maybe it's time to do something about it!

It comes done to ClearType, Microsoft and patents from what I read. Most *nix distro's disable any patent protected font rendering by default.

Read about Debian and fonts here, you want Subpixel-hinting and Font-smoothing section.

There's a config file on that page but I will add here for future reference. Create a file called .fonts.conf in your home directory, and add the following:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
  <match target="font">
  <edit mode="assign" name="lcdfilter">
    <const>lcddefault</const>
  </edit>
  </match>
</fontconfig>
tshepang
  • 64,472
  • 86
  • 223
  • 290
gwillie
  • 1,141
  • 10
  • 8
  • 3
    If I could, I would have upvoted this 50 times. Thanks for such an elegant solution (still usable in 2016 using Debian Jessie and GNOME)!!! – maulinglawns Dec 23 '16 at 16:48
  • 1
    Still working by 2017, Debian Jessie and KDE. Thanks! – kR105 Apr 27 '17 at 20:19
  • 2
    Still working in 2017 on Stretch too! – natebc Jun 05 '17 at 13:27
  • 1
    I can confirm this in 2019. Thank you! – Dexter Jul 01 '19 at 19:55
  • A more "modern" location for the file would be `${XDG_CONFIG_HOME}/fontconfig/fonts.conf` or `${XDG_CONFIG_HOME}/fontconfig/conf.d/99-improved-rendering.conf`. Most of the time [`${XDG_CONFIG_HOME}`](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) is the `.config` subdirectory under the home directory, e.g. `/home/gwillie/.config`. – Cristian Ciupitu Nov 08 '19 at 20:51
  • Still working in 2020. On Manjaro 20.2 KDE. Put it in `/etc/fonts/conf.d/99-improved-rendering.conf`. – nharrer Nov 15 '20 at 18:10
  • I think that most of this should be set by default in Arch (through symlinks in /etc/fonts/conf.d) or should be the default and thus not changed. But, for some reason, this has helped in my case too. I run arch in a vmware workstation VM. – JSamir Dec 17 '20 at 21:16
  • Works in 2021 on Fedora 34! – Sergii Bogomolov Apr 02 '21 at 22:43
  • Still working in 2021 (especially for Firefox) – Bastian Voigt Apr 15 '21 at 07:32
9

These sites use Helvetica as their font. On most Debian systems it's not an outline font, but raster one. You can disable bitmapped fonts as the last stage of font configuration dialog:

$ dpkg-reconfigure fontconfig-config
Perlence
  • 91
  • 1
  • 2
  • 2
    I just ran this without changing any of the answers, and it improved fonts instantly! (maybe dist upgrade caused some problems) – Jürgen Strobel Jul 05 '17 at 04:23
1

I've improved mine these days using fontconfig-infinality. Looks great!

The first topic of this forum shows how to do it. Do not use the first method of the link(compilation), use the deb files below it. Install with

dpkg -i *.deb

and then

bash /etc/fonts/infinality/infctl.sh setstyle 

choose option 2 (infinality)

DONE!

Pierre.Vriens
  • 1,088
  • 21
  • 13
  • 16
0

I have tried the suggestions above with Firefox 75 and KDE 5.6 (Arch based Antergos linux) with no success or only slight improvement. Only after changing the Firefox font settings to Fira Sans and the fonts in Firefox gui (tabs, menus, etc) finally started to look sharp, almost as good as in Chromium based browsers. I could not replicate this with any other font no matter how I've set hinting and aliasing.

Menu -> Preferences -> Language and Appearance section, and there I changed teh Default font to Fira Sans. You can play a bit more with the Advance section. You can try Fira Mono as monotype font etc.

msam
  • 318
  • 2
  • 10
0

This won't help many people, but ...

For me it was some ancient Adobe.pfb files in my .fonts directory. Specifically Helvetica.pfb .

If you have Adobe Postscript files from the 90's laying about, have a look with:

fc-match -s Helvetica | grep -i Helvetica

and see if anything lurks. I 100% would have expected @Perlence 's answer to fix this, but apparently .PFB is an exception. I don't see this problem in Chromium-based browsers, so maybe Firefox is handling it?

Anyway, the good news is as soon as I removed it, I was able to switch back to my test tab (archive.org) and as soon as Firefox reloaded the DOM it was perfect. In previous iterations I quit Firefox, logged out of my X11 session, rebuilt the font cache, etc. but none of that was ultimately needed.

See here for a before and after for identification/comparison:

archive.org before and after removing PostScript bitmap