* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: freetype.php,v 1.2 2005/02/21 20:49:58 nosey Exp $ * @link http://pear.php.net/package/Image_Graph */ // SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND $testFont = 'c:/windows/fonts/Arial.ttf'; if (!file_exists($testFont)) { die('The font specified cannot be found (' . $testFont .')! Please specify an existing font'); } // create a true color image (requires GD2) $image = ImageCreateTrueColor(600, 200); ImageAlphaBlending($image, true); // allocate some colors $black = ImageColorAllocate($image, 0, 0, 0); $red = ImageColorAllocate($image, 0xff, 0, 0); $green = ImageColorAllocate($image, 0, 0xff, 0); $blue = ImageColorAllocate($image, 0, 0, 0xff); $white = ImageColorAllocate($image, 0xff, 0xff, 0xff); // create a frame ImageFilledRectangle($image, 0, 0, 599, 199, $white); ImageRectangle($image, 0, 0, 599, 199, $black); // output some text using the specified font $y = 20; $text = 'Your Freetype installation with GD works'; for ($i = 12; $i <= 20; $i++) { $box = ImageTTFBbox($i, 0, $testFont, $text); $x = 300 - (max($box[0], $box[2], $box[4], $box[6]) - min($box[0], $box[2], $box[4], $box[6])) / 2; ImageTTFText($image, $i, 0, $x, $y, $black, $testFont, $text); $y += max($box[1], $box[3], $box[5], $box[7]) - min($box[1], $box[3], $box[5], $box[7]); } // output the test image header('Content-Type: image/png'); ImagePNG($image); ?>