Forum Moderators: coopster

Message Too Old, No Replies

using fonts and gd

         

bleak26

3:54 pm on Oct 14, 2004 (gmt 0)

10+ Year Member



HI i would like to use gd to edit an image and add some text,i am using PHP Version 4.3.8 and i am using the following code.

<?php
$im = imagecreatefrompng('bars/title_test.png');
putenv('GDFONTPATH=usr/www/users/mimi7818/fonts/');
$fontname="HIROSHT";
$texttobeadded = "test text for button";
$x = 10;
$y = 100;
$color = imagecolorallocate ($im, 249,255,0);
imagettftext ($im,50,0,$x,$y,$color,arial,$texttobeadded);
header ('content-type: image/png');
imagepng ($im);
?>

i get this error
Warning:# imagettftext(): Could not find/open font in /usr/www/users/mimi7818/add_text_to_bar_image.php on line 10

1.please could you tell me what is wrong?
2.is the gdfontpath absolute or relative? if so how do i find out the correct path?
3.do i need to include .ttf in my font name?
4.can i include a path in my font name?

mincklerstraat

5:50 pm on Oct 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



why don't you try, instead of putenv,
$fontpath = 'usr/www/users/mimi7818/fonts/';
and then replace the other line with:
imagettftext ($im,50,0,$x,$y,$color, $fontpath.'arial.ttf', $texttobeadded);
I've always used my fonts with the .ttf extension.