Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

GD::Graph Fonts

by Anonymous Monk
on Apr 15, 2005 at 15:19 UTC ( #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):
    Looks like (from "man GD") for ttf, you need to use the stringFT method.

      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?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2019-11-21 06:37 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (103 votes). Check out past polls.