Posted on 2008-06-02 05:46:25-07 by ivanwills
Fonts

Hi,

I'm trying to use GD::SecurityImage but I'm having troble with getting fonts to work. If I set up the object as:

my $image = GD::SecurityImage->new( width => 400, height => 200, ptsize => 90, lines => 5, thickness => 1, font => '/my/path/to/fonts/StayPuft.ttf', #font => 'StayPuft.ttf', ); my $random_string = 'Blah'; $image->random($random_string); $image->create( qw/ ttf ec #000000 #66CC00 / );

I get the image with out any text on it. I have tried setting GD::Text->font_path() and using a relative path but nothing seems to work also I have check that Apache has permissions to read the font file.

Any suggestions would be appreciated.

Ivan Wills

Direct Responses: 8017 | Write a response
Posted on 2008-06-04 08:30:52-07 by burak in response to 7995
Re: Fonts
Hi, You can check the error like this:
$image->create( qw/ ttf ec #000000 #66CC00 / ); die "Error loading ttf font for GD: $@" if $image->gdbox_empty;
It can either be a path issue or you may have a broken libgd. Also, GD::Text is not used inside GD::SecurityImage...
Direct Responses: 8021 | Write a response
Posted on 2008-06-05 02:28:23-07 by ivanwills in response to 8017
Re: Fonts

I tried that and got the message:

Error loading ttf font for GD: libgd was not built with FreeType font support

So I guess I'll have to fix the libgd library.

Thanks for the help.
Ivan

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.