Re: generate img with fonts...
| From: | Sek-Mun Wong | Date: | Sat, 20 Sep 2003 00:22:18 +0000 |
| Subject: | Re: generate img with fonts... | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-21460@lists.php.net to get a copy of this message | ||
Yes yes, you guys are hilarious but at least try to answer his question! :)
Bobo, I assume you're using Win32 and true type fonts, try this chunk of
code:
You *will* need to install freetype (www.freetype.org) and enable gd/gd2
(depending on your version of php) extensions on your php install.
ref: http://www.php.net/manual/en/function.imagettftext.php
<?php
Header("Content-type: image/jpeg");
$outputtext = "Welcome";
$fontfilename = "BlissIf Caps BoldItalic.ttf"; // whatever the actual
filename is called
$im = ImageCreate(240, 30);
$black = ImageColorAllocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
if (strpos(strtoupper($HTTP_SERVER_VARS["SERVER_SOFTWARE"]),"WIN",0)
=== false) {
/* UNIX OS, use unix style paths and fontsize */
$fontsize = 60;
$fontpath = "/usr/local/apache/htdocs/fonts/";
} else {
/* Windows OS, use windows style paths and fontsize */
$fontsize = 8;
$fontpath = 'C:\\windows\fonts\\';
}
ImageTTFText($im, $fontsize, 0, 20, 20, $white, $fontpath. $fontfilename,
$outputtext);
ImageJpeg($im);
ImageDestroy($im);
?>