Pages

July 03, 2010

Fixing ugly fonts in Sabayon Firefox

I've been taking the Gentoo-based Sabayon rolling release distribution for a spin. One of the things that you'll notice is that some fonts in Firefox look ghastly horrible. Luckily, there's an easy fix. The problem involves the rendering of Helvetica, Lucida, and Times fonts and is discussed (and solved) on the Gentoo mailing list.

Instead of editing /etc/fonts/local.conf, I changed my ~/.fonts.conf file. I got better results using "Sans" than "DejaVu Sans" and in a similar spirit I used "Serif" instead of "DejaVu Serif". My entire .fonts.config looks like:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

<!-- see http://www.mail-archive.com/gentoo-user@lists.gentoo.org/msg83300.html -->
<!-- Replace Helvetica with DejaVu Sans -->
<match target="pattern" name="family">
        <test name="family" qual="any"><string>Helvetica</string></test>
        <edit name="family" mode="assign">
                <string>Sans</string>
        </edit>
</match>

<!-- Replace Lucida with DejaVu Sans -->
<match target="pattern" name="family">
        <test name="family" qual="any"><string>Lucida</string></test>
        <edit name="family" mode="assign">
                <string>Sans</string>
        </edit>
</match>

<!-- Replace Times with DejaVu Serif -->
<match target="pattern" name="family">
        <test name="family" qual="any"><string>Times</string></test>
        <edit name="family" mode="assign">
                <string>Serif</string>
        </edit>
</match>
<!-- -->

<match target="font" >
  <edit mode="assign" name="hinting" >
   <bool>true</bool>
  </edit>
</match>
<match target="font" >
  <edit mode="assign" name="hintstyle" >
<!--
   <const>hintmedium</const>
-->
   <const>hintslight</const>
  </edit>
</match>
<match target="font" >
  <edit mode="assign" name="rgba" >
   <const>rgb</const>
  </edit>
</match>
<match target="font" >
  <edit mode="assign" name="antialias" >
   <bool>true</bool>
  </edit>
</match>

</fontconfig>

Speaking of font rendering, Sabayon has default font rendering that's almost as nice as Ubuntu's. IMHO the only thing that gives Ubuntu the edge is a bit more contrast. If I find a fix for this, I will post this as well.

2 comments:

Unknown said...

Thanks! Wonderful tip! Now my fonts in Firefox look stunning :-)

/Nicke

Jonathan said...

Woohoo! This was the only thing bugging me about Sabayon. This fixed my Firefox fonts.