2005-03-06

Java Unicode box drawing characters

In the best Unix terminal emulator, Terminator, we implement the graphical character set by using the corresponding Unicode characters. We need a shade pattern, a bunch of control pictures, a degree symbol, a plus/minus symbol, box-drawing characters, and less-than or equal and greater-than or equal symbols; all of which are available in Unicode.

Unfortunately, it doesn't look quite right. There are gaps between characters vertically, and the horizontal characters are too low. In fact, if you render them on a line with nothing beneath, you can see that they extend well into the next line down.

This, which has been annoying me for months, turns out to be bug 4896465 on the bug parade, raised against 1.4 in 2003. If you have a spare vote, please consider using it.

I don't understand (or care) whether it's the font's problem or the font rendering code's problem, but I'd really like it to not be the problem of any Java application that wants to use these characters, which it is as long as this bug continues to be ignored.

(At the same time, I realize that character-based box drawing isn't the most important thing that could be fixed, but that's what you take on when you give the world something as useful as Java: hundreds of thousands of people are all going to have a problem or two that's important to them, but unimportant to pretty much everyone else. At least for once this isn't a problem I think I could fix myself if Sun accepted patches.)

Playing with Sun's Font2DTest on Linux, I notice that there's a font called "FreeMono" that gets the box-drawing page right. Unfortunately, it gets just about everything else wrong, and is really quite ugly (unless you happen to like Courier). At small sizes, like you'd use for a terminal, it's impossible to read unless you anti-alias it. Even then, it's too dark for light-on-dark use.

If none of that puts you off, and you make a lot of use of something like whiptail(1) that uses box-drawing, you might want to try:

terminator -xrm fontName:FreeMono \
-xrm antiAlias:true \
-xrm foreground:black \
-xrm background:white

I love anti-aliased text in general, and think it's one of the reasons I'm happier using Mac OS than any other OS — I don't know what MS Windows and Linux do wrong, but there's something not right about their font rendering. But for terminals, nothing beats a well-designed font meant for use at a specific size.