Wednesday, February 28, 2007

Ubuntu and the Search for a Better Font

There are a few things about Ubuntu that I found lacking from the start. One of them was the lack of good fonts. Since I have to stare at the form I choose all day, I would like one that looks nice. In addition, there are some fonts that are well suited to normal application use, but that do not work on the CLI at all.

On the last point, this is a great guide on available monospace/fixed width fonts suitable for programmer's use, viz. in the CLI. It is OS independent and has links to download all the fonts mentioned, and samples of text in each one along with descriptions.

Regarding good looking fonts for GUI use, I will keep my preferences to myself. But, on how to get a variety of fonts to try:
sudo apt-get install gsfonts-x11 msttcorefonts
will give you lots of Microsoft fonts. Many look great. You have to give it to them, Microsoft does put millions of dollars into font design, and it shows. There are also lots of international options available, such as
sudo apt-get install xfonts-intl-arabic

You need to run this when you are done:
sudo fc-cache -f -v
Alternatively, you can restart X (usually mapped to CTRL+ALT+BACKSPACE).

Another good source in the repos:
deb edgy fonts
deb-src edgy fonts

Just add those 2 to the end of your /etc/apt/sources.list, then do sudo apt-get dist-upgrade. After that, run dpkg-reconfigure fontconfig-config again. Of course, update "edgy" to whatever release you are using.

This guide
does a great job explaining how to install fonts in Ubuntu by hand and with a handy program called kfontview, which lets you find and install fonts in the GUI.

Aside from these sources and methods, you can put any new TrueType fonts you get in /usr/share/fonts/truetype, and restart X.

Another way to increase your eye candy variable is:
sudo dpkg-reconfigure fontconfig-config
Once this runs, select Autohinter, Always, No to the questions.
This turns on neat features to emulate Mac OSX font rendering. It will make you eyes happy. Highly recommended. When you finish running the reconfigure, be sure to restart X. One note: When I made this change, everything else worked fine, except for my System Monitor applet on the Gnome Panel. I had to change its width to 35 pixels to display full height. I found this rather odd, and you may not experience the problem.

Thanks to Master Ian for mad tips.

Monday, February 26, 2007

Handy *nix Commands, Part 1: Finding Processes

On countless occasions, I have needed to find the PID of a process, in order to watch it or, more often, to kill it. For quite some time, I would simply run "ps ax | grep" followed by part of the process' name that I wanted to find. (Side note: it helps to also add " | grep -v grep" to this to eliminate the grep itself from the results.)

This works, but it is slow to use. I had to read through the results of ps to get the PID, when that is often all I wanted. One could use awk to grab just the PID column, but there are faster solutions:
  • pgrep (man) - Looks up processes based on options and displays matching PID. Helpful options are -f, finds text match of process name, -o finds oldest matching process.
  • pidof (man) - finds PID of a matching program name.
In both cases, you just pass the command the name (or part of it) of the process you want to find, and you get all matches. You can use pkill, or pipe to kill, to initiate the demise of the process once you find it.