I am trying to print some text to a png file. I have tried everything, but no luck.
Here is my code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="image/jpeg" />
</head>
<body>
<?php
// Create the image
$im = imagecreatetruecolor(100, 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/FRE3OF9X.TTF'; //HAVE CHECKED THIS AND FILE EXISTS
// 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()
imagejpeg($im);
imagedestroy($im);
?>
</body>
</html>
I have tried various font files and checked that the file is being found by changing the filename to see if I get an error. Is there any additional stuff I need to install on the server to make this work?
The output is garbled text (e.g. tuvwxyz������).