Getting a Warning: imagettftext() [function.imagettftext]: Could not read font error message? Let’s fix it!
If you have a form on a your WordPress website and are trying to prevent spammers from flooding your site with deals on – well, you know the kinds of deals they promote, get yourself a “Completely Automated Public Turing Test To Tell Computers and Humans Apart” or a CAPTCHA. You are undoubtedly familiar with CAPTCHA codes. They look like this:
Personally I’m a big fan of MM Forms so I’ll use that plug-in as my example but the theory is the same no matter what you use.
Easy enough to set-up: download it and FTP into your WordPress PLUGINS directory just like you have done for other plugins. I’ll use Filezilla in my examples. Its a great, FREE FTP program.
But do you do if you load your webpage and you get the dreaded “Warning: imagettftext() [function.imagettftext]: Could not read font…” error message? Well you could Google it – but the results are uglyyyyyy. Hopefully I can save you some gray hairs. Here we go:
The directions for MM Forms read:
- Upload whole
mm-forms-communityfolder to the
- Activate the plugin through the ‘Plugins’ menu in WordPress
- Make following directories writable (chmod 777) /exports/ and /captcha/tmp /upload
Ok Wait . . CHMOD???
Its simple: “The
chmod command (abbreviated from change mode) is a Unix command that lets a programmer tell the system how much (or little) access it should permit to a file. It changes the file system modes of files and directories.” Basically, you don’t want people visiting your website to just drill into any folder on your server and be able to run commands, upload files etc.
- FTP into your website
- Go to the folder you need to change (or check) permissions on.
- Right Click on it.
- In Filezilla the command to select is “FILE PERMISSIONS” – If you are using a different FTP program look for similar message.
And Ta-Da! Changing from the default of 755 to 777 is as easy as checking two boxes!
OK Done! Everything works, right? Oh wait a minute . .. you load the webpage and get Warning: imagettftext() [function.imagettftext]: Could not read font in . . . error?
Usually this is caused by the permissions being wrong, the font files not being uploaded all the way or the font files being corrupted. Not OK. Let’s fix it!
Try this . .
- Find the folder inside the the plugin you are setting up what has the actual font files in it. In our case, its in wp-content/plugins/mm-forms/captcha/gentium
- Delete the .TTF and .VFB files. You’ll notice they are quite large compared to the other files in that directory:
And now for Trick #1.
99.9% of the time your FTP program is set to automatically decide how to transfer the files from your computer to the the server. 99.9% of the time you never have to change this setting. Welcome to the .1% of the time when you do.
In Filezilla, Select TRANSFER –> TRANSFER TYPE –> BINARY
Don’t worry about why for, or who what – Just select BINARY.
Trick #2 – upload the TTF and VFB files one at a time. Trust me.
Upload one, wait for it to finish (it will take longer than normal) and then check the filesize to make sure the whole file got to the server.
I repeat: check the filesize to make sure the whole file got to the server.
Repeat for your remaining files.
Cross your fingers.
Reload your webpage.
Sigh in relief. The dreaded Warning: imagettftext() [function.imagettftext]: Could not read font in . . . beast is no more!
And don’t forget to change your transfer mode back to AUTOMATIC!