imagettftext: Could not find open font

Published in Web Development on Thursday, October 21st, 2004

Dealing with a common problem when using php, gd and imagettftext.

In a 'zig when they zag' sort of way, I enabled image style post headings on this blog a while ago, back when siFR was catching on. Rather than use 'siffer', I went with the GD library, PHP and imagettftext. I may write a bit more about implementation at a later date, but for now this is one of those "maybe this helps someone" posts...

Frustration

Well monkeying around with PHP's imagettftext, I found myself running into a imagettftext(): Could not find/open font error anytime that I tried to use a simple text-image generating script on some of the live servers that our clients use.

I wasn't alone

I read up some other peoples problems and solutions, but nothing seemed to work it out.

Then it hit me.

A simple answer...

The font I was using had a hyphen in it's name. I changed it to an underscore and voila, magic.

Comments and Feedback

Totally cool. Post an example?

Maybe in the future, if I stick with it...

Totally. I have used this before. Good job!

Home » Blog » Web Development

Check out the blog categories for older content

The latest from my personal website,
Mike Papageorge.com

SiteUptime Web Site Monitoring Service

Sitepoint's web devlopment books have helped me out on many occasions both for finding a quick solution to a problem but also to level out my knowlegde in weaker areas (JavaScript, I'm looking at you!). I am recommending the following titles from my bookshelf:

The Principles Of Successful Freelancing

I started freelancing by diving in head first and getting on with it. Many years and a lot of experience later I was still able to take away some gems from this book, and there are plenty I wish I had thought of beforehand. If you are new to freelancing and have a lot of questions (or maybe don't know what questions to ask!) do yourself a favor and at least check out the sample chapters.

The Art & Science Of JavaScript

The author line-up for this book says it all. 7 excellent developers show you how to get your JavaScript coding up to speed with 7 chapters of great theory, code and examples. Metaprogramming with JavaScript (chapter 5 from Dan Webb) really helped me iron out some things I was missing about JavaScript. That said each chapter really helped me to develop my JavaScript skills beyond simple Ajax calls and html insertion with libs like JQuery.

The PHP Anthology: 101 Essential Tips, Tricks & Hacks

Like the other books listed here, this provides a great reference for the PHP developer looking to have the right answers from the right people at their fingertips. I tend to pull this off the shelf when I need to delve into new territory and usually find a workable solution to keep development moving. This only needs to happen once and you recoup the price of the book in time saved from having to develop the solution or find the right pattern for getting the job done..