Jump to content

Change Font Style Script


dzhax

Recommended Posts

I am making a dynamic image script. It works but I want to make it look better.

<?phpheader("Content-type: image/png");$dip = $_GET['ip'];$sigName='dsig1';$dport='43594';$fp = @fsockopen($dip, $dport, $errno, $errstr, 1);if (!$fp) {$string='Offline';} else {$string='Online';}$im     = imagecreatefrompng("images/".$sigName.".png");$orange = imagecolorallocate($im, 220, 210, 60);imagestring($im, 3, 60, 47,$string, $orange);imagestring($im,3, 60, 29, $dport, $orange);imagestring($im,3, 60, 11, $dip, $orange);imagepng($im);imagedestroy($im);?>

This is what I have.I want to change the dynamic text font to comic sans.Anyone know how to do this?

Link to comment
Share on other sites

That's a reference page that describes how to use TrueType fonts in an image. There is another page for PostScript fonts if you want to use those instead.
I know its a reference page. I was talking about the code it refrences.Do I replace a line from my script with the line described on the link or do I just add it to my existing script.
Link to comment
Share on other sites

this is weird i have a true type font and its not working.

<?phpheader("Content-type: image/png");$dip = 'dzhax.com';$dport = '43594';$sigNum = '0';$im = imagecreatefrompng("http://www.dzhax.com/images/dsig".$sigNum.".png");$font = 'data/comic.ttf';$orange = imagecolorallocate($im, 220, 210, 60);$fp = @fsockopen($dip, $dport, $errno, $errstr, 0);if (!$fp) {$string='Server Currently: Offline';} else {$string='Server Currently: Online';}imagettftext($im,5,0,100,100,$orange,$font,$string);imagepng($im);imagedestroy($im);?>

Link to comment
Share on other sites

It might also be looking for the wrong file:

Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.
Try removing .ttf from the filename. Also, have errors go to an error log, you probably won't see errors since you're sending the image headers.error_reporting(E_ALL);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('log_errors', 1);ini_set('display_errors', 0);That will set up a file called error.log in the same folder with any error messages.
Link to comment
Share on other sites

Sry for being a pain on this. I just really don't understand what is wrong. It is probably something stupid too. I provided an image so if you want to you can test it.www.dzhax.com/images/dsig0.pngI also imported the config file from my other post.I am guessing it dosent like the im$ variable, but it works with imagestring... i dunno.

<?phpheader("Content-type: image/png");$dname = @$_GET['name'];$font = 'data/comic';include('server/hiscore/'.$dname."/config1.php");$fp = @fsockopen($dip, $dport, $errno, $errstr, 0);if (!$fp) {$string='Offline';} else {$string='Online';}$im = imagecreatefrompng("images/dsig".$sigNum.".png");$orange = imagecolorallocate($im, 220, 210, 60);imagettftext($im,5,0,100,100,$orange,$font,$string);error_reporting(E_ALL);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('log_errors', 1);ini_set('display_errors', 0);imagepng($im);imagedestroy($im);?>

Error Log:[25-Feb-2009 01:03:31] PHP Warning: imagepng(): supplied argument is not a valid Image resource in C:\www\vhosts\localhost\dynamic1.php on line 16[25-Feb-2009 01:03:31] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\www\vhosts\localhost\dynamic1.php on line 17

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...