OS X-quality font rendering in Ubuntu

If you’re dissatisfied with the ghastly appearance of Japanese text in a stock install of Ubuntu, this guide might help. You’ll end up with unhinted, sub-pixel anti-aliased fonts like those used in OS X.

If you are in the camp that believes OS X’s fonts to be ‘blurry’ or ‘hard to read’, I can’t help you. However, if you like OS X’s font rendering, read on!

In the following, > indicates a line to be typed in the terminal. Some long lines are split over two or more lines below, with continuation lines being indented. Type it all as a single line in the terminal.

These instructions have been tried on Ubuntu 5.04 (Hoary); I’d especially appreciate feedback on whether it works in 5.10 (Breezy).

Getting the fonts

First, you need to get some decent Japanese fonts: the Kochi ones supplied with Ubuntu are horrible. You can get some good ones from Windows. I won’t address the legal issues—frankly, I don’t care—but if your computer came with Windows 2000 or XP, it shouldn’t be a problem.

Some of this needs to be done in a terminal:

> sudo apt-get install cabextract
> sudo mkdir -p /usr/local/share/fonts/truetype

Either:

Insert a Windows 2000 or XP installation CD. If your CD/DVD drive is not mounted at /media/cdrom, you’ll have to change that in the lines below, but I think it will almost always be the case.

> cd /usr/local/share/fonts/truetype
> find /media/cdrom/ |
  grep -Ei 'MS(MINCHO|GOTHIC).TT_' | 
  sudo xargs cabextract

Or:

Alternatively—if you don’t have a CD drive for example—you can just copy the files from an existing Windows installation: in that case, find MSGOTHIC.TTC and MSMINCHO.TTC in Windows’ font directory and manually copy them to /usr/local/share/fonts/truetype :

> sudo cp /source/location/* 
  /usr/local/share/fonts/truetype/

Whichever choice you made, now check that you see both msgothic.ttc and msmincho.ttc (the capitalisation shouldn’t matter):

> ls /usr/local/share/fonts/truetype

I also suggest that you install the Microsoft Core Fonts as described in the unofficial Ubuntu Guide.

Configuring fallback

Now we can set the fonts that will be used automatically for each script. The system checks each font in turn to find the glyphs it needs.

> cd /etc/fonts
> cp local.conf local.conf.default
> sudo gedit local.conf

Replace the contents of local.conf with my version.

Save and exit.

> sudo fc-cache -f -v 
  /usr/local/share/fonts

Tweaking Gnome

Go to the system menu at the top of the screen, System, then Font.

Under Font Rendering, click on “Details…”.

Set Smoothing to “Subpixel (LCDs)”.

Set Hinting to “None”.

Click Close.

You can choose some different fonts for the system, if you prefer. I use Arial 10, Arial 10, Arial 10 Bold, Monospace 9.

Click Close again.

Tweaking KDE

I haven’t covered KDE here; if you have any KDE apps, you can configure their fonts using kcontrol in a similar way to Gnome, and choosing the same settings.

Restart

You can either restart the computer or just X11 (make sure that you’ve saved everything and hit Alt+Backspace).

Test it

Go to a Japanese website in Firefox, and see if the kanji and kana are now more normal shapes. Check the title bar of the browser as well. Please give feedback below!

Comments

Skip to the comment form

  1. Dmitry Nikolaev

    Wrote at 2007-04-13 22:17 UTC using Firefox 1.5.0.11 on Linux:

    Thanks for post. I’m not set everything You’ve write, but You help me make pages for my web-browser more beautiful!
  2. JC

    Wrote at 2008-03-26 05:58 UTC using Firefox 2.0.0.12 on Linux:

    Can we see samples of the fonts?

    Thanks, Po-ru-San.
  3. sam

    Wrote at 2008-06-17 13:54 UTC using Firefox 3.0 on Linux:

    You dont have to disable hinting for all fonts. Some fonts look wrong hinted, but hinting can be disabled for individual fonts eg. Japanese fonts using local.conf
  4. chris

    Wrote at 2009-05-29 20:04 UTC using Firefox 3.0.10 on Linux:

    Hi po-ru

    Thanks for this simple guide on fonts configuration.
    I’ve been using mnemosyne to memorise Japanese and Chinese vocabulary and after a fresh install of Ubuntu 9.04 marbled characters in the flash cards have been driving me crazy (they are a mix of Japanese kanji, Chinese hanzi, pinyin and latin fonts). I tried a couple of different guides but never was really able to put it all together…
    Atm, mnemosyne seems to behave, so big cheers to you
    Chris

Leave a comment

Please read the comment guidelines before posting. Comments are Gravatar-enabled. Your email address will not be published.

To prove that you’re human, type human in the Bot check field.

Trying to post some program output or a long code sample? Please use a paste service and link to it instead.