Getting nice fonts in gitk

Author: Peter McCurdy
Date: Monday, May 12th, 2008
url:http://navarra.ca/?p=44

A comparison of gitk's fonts using Tk 8.4 and 8.5

If you use git (and you should), you may have noticed that gitk’s fonts generally look bad. Some of them aren’t too terrible, but a few, such as the menu bar font on my machine, are really bad. Stupendously awful. Like they’ve been run through a blender. You get the idea. None of them are all that great, anyway. Newer versions of gitk at least let you pick larger fonts, to save you from the default squint-o-vision settings, but that just makes them large and ugly instead of small and ugly.

The sad thing is, it's not even gitk's fault. gitk is written in Tcl/Tk, which, despite being somewhat underrated as a language, has some very questionable font handling in the toolkit. However, there is hope: the recently-released Tk 8.5 finally brings some antialiased fonts to the table. To my eyes, the antialiasing is actually somewhat overdone, but that’s nitpicking; the overall improvement is staggering. So just get yourself a copy of Tk 8.5, and you’re off to the races.

Ah. Unless you’re using Ubuntu. While the new Ubuntu 8.04 has Tk 8.5 available for installation, they’ve restricted gitk to explicitly ask for Tk 8.4. So, to get yourself nice fonts in gitk on Ubuntu 8.04:

  • Install Tk 8.5: sudo aptitude install tk8.5
  • Open /usr/bin/gitk in a text editor.
  • On the third line, change “wish8.4″ to “wish8.5″

Presto, nicer-looking fonts. You can see the difference in the image up top, where I superimposed the old and new toolkit versions. Needless to say, Tk 8.5 is on the left.

Update, 2009-11-21: According to the (very helpful – thanks guys!) comments, in more recent versions of Ubuntu, and presumably Debian as well, the solution is a bit easier. Once you install tk8.5, just run sudo update-alternatives –config wish and pick /usr/bin/wish8.5 from the list.