This weekend some of the older code I worked on for Broadchoice was moved to a new server. Everything worked fine until this error began to fire:
The ARIAL,TIMES,COURIER font name is/are not supported.
Pretty much immediately I knew what this was. The template was making use of cfimage to generate a CAPTCHA and the fonts that worked on the initial system did not work on the new system.
While easy enough to fix, I started to dig a bit to see if there was a nicer way around this. I did a bit of Googling and came across: What Fonts are Available in myJVM?
The good news is that yes - you can - at runtime - figure out which fonts are available. Unfortunately, even with this list you get a set of fonts that simply won’t work with cfimage. When I tried his (I assume him - not sure who cfsearching is - but the blog has some very good entries) code I saw quite a few fonts that didn’t work.
So I think the point of all this is - I don’t think you can nicely write code that will programatically tell you which fonts you can use for CAPTCHAs. Even if you did, you would need a human opinion on which fonts are good for CAPTCHAs anyway. As much as we try to write portable code, this is probably one area where you will have to simply run a test before deploying your code. cfsearching’s demo template that shows the font styles and lists the ‘bad’ ones is an excellent tool for this.