This is a little script I expanded upon that I found from one of my previous clients. The original script was created by Stewart Rosenberger. The WP Now website uses this script to dynamically generate testimonial signatures.
Dynamic PHP Font Generator Version 1.0
Calendar
January 2012 M T W T F S S « Jul 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Analytics Stats

Great script!
However, it appears that the text gets cut off at the bottom when it is being generated on a server running PHP version 5.2.10. All older versions of PHP run this script flawlessly. Do you know why this script may be malfunctioning on version 5.2.10? Here’s an example of what the created .png image looks like on a version 5.2.10 server:
http://cortello.com/dev/font.php?preset=testimonials&text=hello
Thank you!
Hey Tom,
Give this a try:
On line 151 where it says
“$height = ImageFontHeight(5) + 10;”
Change it to something like
“$height = ImageFontHeight(5) + 15;”
I’m not really sure why PHP 5.2.10 does this, maybe they changed something in the way it calculates the height…
Hi Ryan,
I follow your step, however, the title didn’t change anything at all.
Is there anyway that we can upgrade this program which fit PHP 5.2.10?
Thanks,
Hebee
Hi, I can’t understand how to add your site in my rss reader. Can you Help me, please
To subscribe, add this URL to your RSS reader: http://blog.ryanmaffit.com/feed
Hello! In what licence is this code distributed? I would like to add this function as an add-on for Concrete5
Well, I found the script a few years ago and had to use it for a recent project of mine but it appears the original author’s website link does not work any more so I am not sure what license it was originally released under. I did a bit of research and found http://www.artypapers.com/csshelppile/pcdtr/ but the download link appears to be inactive… I personally don’t mind what you use it for
I had the same problem: the text got cut off at the bottom. To solve this problem I modified the php file as follows.
$dip = get_dip($font_file,$font_size) ;
change to:
$dip = get_dip($font_file,$font_size)+7 ;
The addition probably depends on the font and fontsize you’re using.
Excellent script. How would you add more than one preset?
Would that be multiple arrays?
hd is arial then hd2 is helvetica.
$presets = array(
‘hd’ => array(
‘font’ => ‘arial.ttf’,
‘size’ => ’18′,
‘font_color’ => ’8e1901′,
‘bg_color’ => ‘ffffff’,
‘transparent_background’ => true,
)
);
$presets = array(
‘hd2′ => array(
‘font’ => ‘helvetica.ttf’,
‘size’ => ’18′,
‘font_color’ => ’8e1901′,
‘bg_color’ => ‘ffffff’,
‘transparent_background’ => true,
)
);
Thanks!
You would need to add the other preset as another item in the main $presets array, like this:
Thanks appreciate it, I was missing the comma.
No problem
Hey guys, im having the same croped text error as Hebee. My blog site has an example of what is happening with the text.
If I dont specifiy the font and let PHP use its default it works fine.
Editing the $dip line to +7 works in Firefox but not in IE … ??
Any suggestions ? I have tried different font files and try forcing it to draw the box bigger, but none of those changes change anything.
Your help is appreciated.
THanks
Fernando
Fernando,
It works in IE for me, but you might have to delete your temporary files, or change the text to see it work. I am in IE 8, however.
-Clint
Clint,
Thanks for that mate… i dont know what I am doing but it definitely isn’t working for me.. I may have to start from scratch again.
Fernando
Pingback: Corriger le plugin TTF Titles sous PHP 5.2.10+ « Globe Design Studio
Pingback: Correct TTF Titles plugin under PHP 5.2.10+ « Globe Design Studio
Pingback: test « Globe Design Studio
Pingback: hello world « Globe Design Studio
Pingback: Corriger le plugin TTF Titles sous PHP 5.2.10+
a really good read by you looking forward to come back more very soon.
Best you could edit the page name title Dynamic PHP Font Generator | Ryan Maffit to more suited for your webpage you create. I liked the blog post withal.
If anyone is having trouble with the image getting cut off, make sure you remember to delete the contents of the cache folder before refreshing in the browser!
PS – make the change to the $dip line…
$dip = get_dip($font_file,$font_size)+7;
Thank you for every other great post. Where else could anyone get that type of information in such a perfect way of writing? I have a presentation next week, and I’m on the look for such info.