Tuesday, June 30, 2009

Solution to CFIMAGE distorting text.

CFIMAGE, CFPDF and CFDOCUMENT all rely on the Fonts installed on the server where Coldfusion is installed.

You may find as I did that these tags sometimes render fonts strangly. In my case it was CFIMAGE that was drawing out strange characters for letters. I googled the issue and found NO good answer. Adobe's forums didn't help either.

So here is the solution! For FREE!

The CFIMAGE tag contains an attribute called "fonts". To stop having CF pull random fonts, you must open up your CFADMIN console (if you have access to it) and look in the Font Management section or TRUE TYPE fonts.

On my server I have several fonts listes but only few are TRUE TYPE.

ONLY True type will work (in my experience).

Copy and paste one of the font names in the CFADMIN into the "fonts" attribute. This will restrict CFIMAGE to just that font. If you want more than one font type to display, you can list out the fonts in comma delimited format.

So here's an example:

<cfimage overwrite="Yes"
action = "captcha"
height = "60"
text = "rEadMe"
width = "200"
fonts = "lucida sans,lucida sans typewriter"
fontsize = "30"
destination = "assets/images/captcha.jpg"
difficulty = "medium">

That's it! Good luck!