Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

GD::Graph Fonts

by Anonymous Monk
on Apr 15, 2005 at 15:19 UTC ( [id://448214]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Platform: Windows 2000 SP3, Perl Activestate, 5.6.1

Problem: I'm using GD::Graph::Lines()to create charts. The charts are generated successfully, but the default fonts (text) are ugly. Changing font type doesn't do anything it just keeps on outputting the default GD fonts. I'm setting the graph to the correct path. Any help would be much appreciated, thank you.

$graph->set_title_font("c:/winnt/fonts/arialbd.ttf",16); $graph->set_x_label_font("c:/winnt/fonts/timesbd.ttf",8); $graph->set_y_label_font("c:/winnt/fonts/timesbd.ttf,8");

Replies are listed 'Best First'.
Re: GD::Graph Fonts
by davidrw (Prior) on Apr 15, 2005 at 15:45 UTC
    I think (from grep'ing a co-worker's code) that there are font constants. Check the GD man page for more info (look for the word 'giant'), and maybe try something like (it appears the choices are gdSmallFont, gdMediumBoldFont, gdTinyFont, gdLargeFont and gdGiantFont):
    $graph->set_title_font(GD::gdGiantFont);
    Looks like (from "man GD") for ttf, you need to use the stringFT method.
    $image->stringFT($fgcolor,$fontname,$ptsize,$angle,$x,$y,$string)
      Resolution:

      First GD::Text has to be called directly and then the path to the fonts has to be set before the font can be used. So in addition to use GD::Graph the following lines had to be added to my code:

      use GD::Text; GD::Text->font_path('c:/winnt/fonts/');

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found