Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

GD::Graph cannot change font

by kp2a (Sexton)
on Apr 24, 2011 at 15:15 UTC ( #901050=perlquestion: print w/ replies, xml ) Need Help??
kp2a has asked for the wisdom of the Perl Monks concerning the following question:

I cannot change font or size for labels etc.
For example from GD::Graph (modified)
(It is included in the build directory of the distribution.)
my $font_spec = "Dustismo_Sans"; $my_graph->set_y_label_font($font_spec, 12); $my_graph->set_x_label_font($font_spec, 12); $my_graph->set_y_axis_font($font_spec, 10); $my_graph->set_x_axis_font($font_spec, 36); $my_graph->set_title_font($font_spec, 48); $my_graph->set_legend_font($font_spec, 8); $my_graph->set_values_font($font_spec, 8);
Dustismo_Sans.ttf is in pwd. And I have tried "Dustismo_Sans" and "Dustismo_Sans.ttf" and "/home/john/Dustismo_Sans.ttf" for $font_spec

Whatever I put in $font_spec or in the size field, the appearance of the resulting image is always the same!


1. I assume that GD would look for the font file given a relative (to pwd) file name or an absolute file name. Correct?

2. Why can I not change size or font?

3. My OS is FC 8. I loaded msttcorefonts-2.0-1.spec, Microsoft TTL fonts, and they are usable by OpenOffice but I cannot locate corresponding .ttf files. Do they exist as such and if so, where are they?


uname -a Linux scan #1 SMP Thu Dec 18 19:19:45 EST 2008 i686 i6 +86 i386 This is perl, v5.8.8 built for i386-linux-thread-multi GD-2.45 GDGraph-1.44 GDTextUtil-0.86

Comment on GD::Graph cannot change font
Select or Download Code
Replies are listed 'Best First'.
Re: GD::Graph cannot change font
by Anonymous Monk on Apr 24, 2011 at 15:24 UTC
    Try like this
    $my_graph->set_y_label_font($font_spec, 12) or warn $my_graph->error;
    Hopefully there will be a warning
      Thanks. Yes, a warning
      Processing sample95 libgd was not built with FreeType font support ...caught at ./ line 84.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2016-02-09 10:30 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (310 votes), past polls