Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

GD::Graph for Pie

by rpike (Scribe)
on Apr 27, 2012 at 16:06 UTC ( #967674=perlquestion: print w/ replies, xml ) Need Help??
rpike has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to change the font used for the labels inside a pie chart I created using GD::Graph but the font isn't changing. What I want to do is increase the font size to something that people can see. Also I would prefer it to be generic as possible, no full path to the font file since this may change from client to client. Any help would be appreciated. Thanks.

Comment on GD::Graph for Pie
Re: GD::Graph for Pie
by zentara (Archbishop) on Apr 27, 2012 at 18:10 UTC
    Copy the ttf font file you wish to use, to your script's working directory, and rename it Generic.ttf. You can even base64 encode the font, and write it out at the beginning of the script run. Also see IBM Developer's Work GD pie chart
    #!/usr/bin/perl use GD; use strict; use warnings; my ($w, $h) = (200, 200); my $img = GD::Image->new($w, $h); my $white = $img->colorAllocate(255,255,255); my $black = $img->colorAllocate(0,0,0); $img->rectangle(10,10,20,20,$black); $img->stringFT($black,"./Generic.ttf",72,0,100,100,'A'); open (IMG, ">$0.png"); print IMG $img->png; close IMG;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://967674]
Approved by herveus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2014-08-31 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls