If you use FontMetrics to layout your GUI, you may have noticed some peculiarities on some platforms .... or maybe your users have! To different extents in different versions of Netscape Navigator, primarily on SunOS and SGI workstations, I've observed FontMetrics giving unreasonable values for Font height, baseline and ascent. This can make what should be a very nice arrangement into an almost unreadable one.

I've developed a somewhat ugly, but functional workaround; a `wrapper' for a font metric. To use it, you'd replace something like:

    FontMetrics metrics = getFontMetrics(font);
    FontMetrics metrics = PatchFontMetrics.patch(getFontMetrics(font));
(or the reverse if you want to remove the Patch from other GUI widgets in my library)

Under the assumption that a pixel is essentially a point (!), if the various height values returned by the `real' font metrics are doubted, the wrapper computes its own, based on the font size.

Note that this is not really a correct thing to do: a very finely pitched display may have multiple pixels per point. However, 1) I've yet to see a common platform using this, 2) Java already forces us to specify sizes of things in pixels (eg the applet tag), and 3) Hopefully Netscape will fix this before the difference would matter.

This applet will show you the various measures stored in a FontMetrics and draw a box around a test string based on these values. The box should fit reasonably close around the string without touching it. You can do this with and without the patch to see which is best.

If you have one of the affected platforms, the patched version should be better. Otherwise both should be reasonable. If the patched version is worse, I'd like to hear about it!

Created by Bruce Miller @ NIST (bruce.miller@nist.gov) Disclaimer.