It is currently Thu Mar 28, 2024 11:33 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Imagettftext can't find my font. Why not?
PostPosted: Wed May 14, 2008 1:48 am 
Noobie
Noobie

Joined: Wed May 14, 2008 12:49 am
Posts: 2
My script functions fine if I use Arial as the font, but when I try to use a font that's not in the current directory (setting the GD path with putenv) it tells me it can't find the font.

If it helps, this is my script:

Code:
<?php

header("Content-type: image/png");

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

$homedir = "http://www.mtaonline.net/~dburton/";
putenv("GDFONTPATH=$homedir");

//These entities should output the hanzi numerals for one, two, and three
$text = '&#x4e00;&#x4e8c;&#x4e09;';
$font = 'HDZB_35.TTF';

imagettftext($im, 12, 0, 10, 20, $black, $font, $text);

imagepng($im);
imagedestroy($im);

?>


I only called the font from an outside URL due to the fact that it's more than 500KB (most fonts are). Yes, I have opened the full URL to the font in my browser, and it works.

This works (albeit the fact it outputs the entities instead of the corresponding characters):

Code:
<?php

header("Content-type: image/png");

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

$text = "&#x4e00;&#x4e8c;&#x4e09;";
$font = "Arial";

imagettftext($im, 12, 0, 10, 20, $black, $font, $text);

imagepng($im);
imagedestroy($im);

?>


How should I direct GD to my font?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ]  Moderators: fhmagic, KJ, Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011