Watch those fonts

This post is more than 2 years old.

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.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by David McGuigan posted on 12/23/2008 at 11:52 AM

Couldn't you just include the general type names? Like serif, sans-serif, etc?

Comment 2 by Raymond Camden posted on 12/23/2008 at 5:29 PM

Maybe - but serif, at least on my Mac, results in unreadable text. sans-serif doesn't work at all.