Using Liberation fonts as a substitute for Arial

For people who care about how their fonts look on Linux, Arial has always been a difficult font to have rendered correctly. This tip allows you to use the free Liberation Sans font (which has the exact same metrics as Arial) in all places where Arial would be used. I first refer the reader to my other tip concerning the optimal font configuration settings for Feisty and Gutsy. This tip requires these settings to be used, because a usable rendering of the Redhat Liberation fonts requires that the autohinter and subpixel rendering be used. (Liberation fonts do not come with any hinting information at the moment) First, grab the tar archive of the Liberation fonts from Redhat's site. Look for the plain tarball instead of an RPM. Untar this tarball into a temporary location, then copy the *.ttf files to your ~/.fonts directory. Finally, refresh your font cache.
% mkdir -p /tmp/fonts
% cd /tmp/fonts
% tar xvzf ~/path/to/liberation-fonts-download.tar.gz
% cd liberation-fonts-0.2
% cp *.ttf ~/.fonts
% fc-cache -f
After these steps, the Liberation fonts should now be installed on your system. You should be able to verify this by using a small program such as gedit, and attempting to change the font to one of the liberation fonts. The second part of this tip is to configure fontconfig such that Liberation Sans gets used in place of Arial. This requires the inclusion of the following snippet in your ~/.fonts.conf file.

 <selectfont>
   <rejectfont>
     <pattern><patelt name="family"><string>Arial</string></patelt></pattern>
   </rejectfont>
 </selectfont>

 <alias>
   <family>Arial</family>
   <prefer>
      <family>Liberation Sans</family>
   </prefer>
 </alias>
The first section causes fontconfig to reject the Arial font even if it's explicitly selected by a program. The second <alias> block tells fontconfig to use Liberation Sans as a replacement when Arial is requested. After saving this to your .fonts.conf file, reload all your apps, and you should see the effect. My main test case is to make sure the various google pages look better, since they all use Arial in their stylesheets.