Help with simple script

I have a script… it’s a simple script, that generates text on an image. I had someone help me center the text on the image. But it took out the font properties. Now it doesn’t show the font it’s supposed to. And I’m not too advanced with php, in fact I’m merely a beginner. And I’ll be the first to admit I’m not sure what to do. Can anyone tell me how to set a specific font on this?

Here’s the code, with the disabled lines that were originally on there.

[code]<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
header(“Content-type: image/png”);
if ($_SESSION[“message”]){
$message = $_SESSION[“message”];
}else{
$message = $_GET[‘message’];}
$im = imagecreatefrompng(“Heart1.png”);
//$message_width = imagettfbbox(10, 0, “visitor.ttf”, $message);
//$message_start = (350 - ($message_width[2] + 123));
//$color = imagecolorallocate($im, 0, 0, 0);
//imagettftext($im, 10, 0, $message_start, 14, $color, “visitor.ttf”, $message);

$text_color = imagecolorallocate($im, 0, 0, 0);
$imgx = (imagesx($im) - 6.5 * strlen($message)) / 2;
$imgy = (imagesy($im)/6) ;
imagestring($im, 2, $imgx, $imgy, $message, $text_color);

imagepng($im);
imagedestroy($im);
?>

//Userbar Generator Script By Max Evans[/code]

The new method does not include any reference to the font. The code you used before is commented out, meaning it will never run (the double slashes at the start of each line indicate this).

Try replacing this line:

imagestring($im, 2, $imgx, $imgy, $message, $text_color);

with these two lines:

$intFont = imageloadfont("visitor.ttf");
imagestring($im, $intFont, $imgx, $imgy, $message, $text_color);

You might find the following references useful:
http://au2.php.net/imagestring
http://au2.php.net/manual/en/function.imageloadfont.php

Sponsor our Newsletter | Privacy Policy | Terms of Service