Page 1 of 1

Fonts with GDLIB

Posted: Mon Feb 18, 2008 10:57 pm
by pickey
Hello All,


Am using below code :

header("Content-type: image/png");
$string = $_GET['text'];
$im = imagecreatefrompng("images/button1.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);

Given above code I can not change Font Face what I can do is to change font size from 1 to 5 only.
How to go about it if I want to use different Font Face i.e. Verdana, Arial Rounded or it could be anything. I am using PNG images.

Re: Fonts with GDLIB

Posted: Fri Mar 07, 2008 3:37 pm
by onion2k
imagestring() is pretty awful for switching fonts. Try imagettftext() instead, that will let you use TTF fonts (any Windows font basically). You do need to have Postscript compiled into GD but most hosts have it, as does the standard PHP installer if you're working locally.