Warren.Guy.net.au

The personal web site of Warren Guy of Perth, Western Australia

Configuring Fonts in Ubuntu Linux

This document explains how to configure fonts in Ubuntu Linux to look more 'Windows'-like. There's a screenshot of the final product in my blog.

Why?

Personally, I was just frustrated with some web sites not rendering correctly using the default fonts and configuration. I also think it looks nicer, cleaner even, although I'm sure some will disagree ;).

Installing msttcorefonts

The msttcorefonts package contains the Microsoft core TrueType fonts:

To install the msttcorefonts package, you'll need to enable the universe (community maintained) and multiverse (non-free) apt repositories if you haven't done so already.

Enabling the Universe and Multiverse repositories in Ubuntu

Now, assuming you have correctly enabled the universe and multiverse respositories, we'll install the msttcorefonts package.

From a terminal, run:

sudo apt-get install msttcorefonts

Installing Tahoma

You may also want to install the Tahoma font, which is not included in msttcorefonts, although this is entirely optional. I happen to like Tahoma :). If you don't want Tahoma or you don't think it's worth the hassle, keep scrolling down to the next step, Configure X to 96 dpi.

  1. You'll need to get your hands on a copy of the Tahoma font files. You can copy them from an existing Windows installation if available. If that's not an option, you can find it on Google
  2. Create the /usr/share/fonts/truetype/custom/ directory as root
    sudo mkdir /usr/share/fonts/truetype/custom/
  3. Copy tahoma.ttf and tahomabd.ttf in to /usr/share/fonts/truetype/custom/
    sudo cp tahoma.ttf /usr/share/fonts/truetype/custom/
    sudo cp tahomabd.ttf /usr/share/fonts/truetype/custom/
    
    
  4. Create the Tahoma hints file
    sudo gedit /etc/defoma/hints/custom.hints
    and copy and paste this text in to the file:
    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <fontconfig>
    
    <match target="font">
     <test compare="more" name="pixelsize" qual="any">
      <double>12</double>
    
     </test>
     <edit name="autohint" mode="assign" >
      <bool>true</bool>
     </edit>
    
    </match>
    <match target="pattern">
                <test qual="any" name="family">
                        <string>Bitstream Vera Sans</string>
    
                </test>
                <edit name="family" mode="assign">
                        <string>Arial</string>
                </edit>
    
    </match>
        <match target="pattern">
                <test qual="any" name="family">
                        <string>Helvetica</string>
    
                </test>
                <edit name="family" mode="assign">
                        <string>Arial</string>
                </edit>
    
    </match>
    <match target="pattern">
                <test qual="any" name="family">
                        <string>Palatino</string>
    
                </test>
                <edit name="family" mode="assign">
                        <string>Georgia</string>
                </edit>
    
    </match>
    </fontconfig>
    

Configure X to 96 dpi

  1. Back up your xorg.conf
    sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
    sudo gedit /etc/X11/xorg.conf
  2. Add the following lines to the end of the Monitor section, before EndSection
    #	DisplaySize	270	203	# 1024x768 96dpi
    #	DisplaySize	338	203	# 1280x768 96dpi
    #	DisplaySize	338	254	# 1280x960 96dpi
    #	DisplaySize	338	270	# 1280x1024 96dpi
    #	DisplaySize	370	277	# 1400x1050 96dpi
    #	DisplaySize	423	370	# 1600x1400 96dpi
    #	DisplaySize	423	318	# 1600x1200 96dpi
  3. Uncomment the line which corresponds to your screen resolution. If your screen resolution isn't listed, use this formula to get the values (in millimetres): displaysize = (pixels)/96*25.4. For example, for 1280x768, 1280 / 96 * 25.4 = 338.67 = 339 would be the first number, and 768 / 96 * 25.4 = 203.2 = 203 would be the second.

Restart Gnome and X

Log out of Gnome and at the login screen, type Ctrl + Alt + Backspace to restart X. The new settings should now be applied.

Once you've logged back in, run the following command in a terminal to confirm that the resolution is 96x96dpi

xdpyinfo | grep resolution

If the resolution is not 96x96 dots per inch, the screen size you set in the last step is wrong. Check your rounding and adjust the numbers until your resolution is 96x96 dpi.

All done!

You're done! If you have anything you think I should add to this document, or if you experience any problems with these instructions, please comment on my blog.

Page modified 109 weeks ago