trouble with loading ttf to be used in GD
Posted: Thu Sep 18, 2008 4:10 am
elloo,
i'm using php4.3.10 and freebsd4.8-stable however i have troubles with loading ttf fonts in the right color. the php coding works fine with other OS such as "Debian linux", "mac OS" and dare i say "Windows." basically php coding generates an text image using GD and here is the code.
any how the trouble is, it loads the font however it appears yellow?! i have tried to blame it on my coding however after trying the same coding under different OS, it make me wonder if it is an issue with freebsd4.8. any ideas are highly welcomed.
many thanks.
i'm using php4.3.10 and freebsd4.8-stable however i have troubles with loading ttf fonts in the right color. the php coding works fine with other OS such as "Debian linux", "mac OS" and dare i say "Windows." basically php coding generates an text image using GD and here is the code.
Code: Select all
<?php
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'fonts/arialblack.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
many thanks.