Why do Fonts suck in Java?

When it comes to fonts in Java, there seems to be a few holes. Two major ones that I just come across today:

  • No ‘font chooser’ dialog to let users graphically select a font.
  • No easy way to serialise a font to a properties/preferences text stream, despite the fact there is an easy way to read them in using Font.decode().

For the first issue, I simply made use of a component library we have (Jide), but it would be ideal if this component become a normal component in Swing. It isn’t that difficult – I remember writing a font chooser back at university in an HCI paper using Java which was trivial (and actually focused more on the creation of custom UI components by overriding paint methods).

For the second issue, I seem to have some luck with the following method I just flicked together:

Leave a Reply