A problem with fonts and/or printing PNG files?
John W. Eaton
jwe at bevo.che.wisc.edu
Thu Feb 28 13:57:16 CST 2008
On 28-Feb-2008, Petr Mikulik wrote:
| > I'm having a problem when I try to print a plot in PNG format. Here's
| > a simple script that reproduces the problem on my machine:
| >
| > x = 1:10 ;
| > plot (x);
| > title ('My plot');
| > print myplot.png -dpng
| >
| > When I type the print command, I get this error message:
| >
| > gdImageStringFT: Could not find/open font while printing string My plot
| > with font Helvetica
| >
| > It only seems to happen when I try to print PNG. JPG, GIF and SVG
| > formats all print fine.
|
| It seems to me that all, including the postscript output, are wrong.
| See the postscript code generated by
| print myplot.eps -deps
| According to
| drawnow("postscript","/dev/null",false,"debugeps.gp")
| Octave sends to gnuplot
| set title "My plot" font "helvetica,10";
| which is wrong, because the postscript font name is "Helvetica", no
| "helvetica". This needs a bug fix in Octave.
This is fixed now.
| In the case of
| print myplot.png -dpng
| the gd+freetype library used by gnuplot cannot find file "helvetica.ttf" and
| thus producing the error message. I don't see any such file on my Linux box.
| I think that another font, e.g. arial (arial.ttf exists) should be used
| instead.
On my system (Debian testing, up to date) I also see the error if I
use gnuplot directly and ask for Arial:
gnuplot> plot sin(x)
gnuplot> set title "foobar" font "Arial,10"
gnuplot> set term png
Terminal type set to 'png'
Options are 'nocrop medium '
gnuplot> set output "foo.png"
gnuplot> replot
gdImageStringFT: Could not find/open font while printing string foobar with font Arial
so what package do I need to get Arial?
I'd consider switching the default to Arial. Matlab specifies that
the default font is Helvetica, so a change would break any code that
expects that. OTOH, this probably doesn't affect much real code, so
it would probably be OK.
| Output to GIF or JPG does not work either. It seems to me that gnuplot's
| "set term gif|jpeg" is not used as
| print('myplot.jpg', '-djpg', '-S800,600')
| print('myplot.gif', '-dgif', '-S800,600')
| does not work. I propose Octave uses gnuplot for this output, not a
| conversion via postscript.
I'd consider a patch.
Thanks,
jwe
More information about the Bug-octave
mailing list