[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Font problem with png terminal 2.9.17+
From: |
John W. Eaton |
Subject: |
Re: Font problem with png terminal 2.9.17+ |
Date: |
Tue, 04 Dec 2007 20:18:04 -0500 |
On 4-Dec-2007, dbateman wrote:
| Fredrik Lingvall wrote:
| >
| > I have this issue with printing to png files:
| >
| > octave:1> figure(1)
| > octave:2> plot(randn(100,1))
| > octave:3> xlabel('x')
| > octave:4> print -dpng test.png
| > gdImageStringFT: Could not find/open font while printing string x with
| > font helvetica
| >
|
| Ok, I couldn't check the png terminal on my rough gnuplot 4.2.2
| installation. I suppose that in fact the best way to deal with this is to
| have a fontname "default" and don't try to set the fontname at all if the
| fontname is "default". However this might cause issues with the TeX
| \fontname option, but I think we can live with that
OK, I see this problem also bites us when generating png files for the
HTML manual. I think the following patch does what you propose above,
except it uses "*" instead of "default" to specify the default font.
If you think "default" is better, then it is easy enough to change.
Unfortunately, we still have the following problem:
../../run-octave -f -q -H -p /home/jwe/src/octave-trunk/doc/interpreter
--eval "plotimages ('extended', 'png');"
gdImageStringFT: Could not find/open font while printing string ¬ with
font Symbol
gdImageStringFT: Could not find/open font while printing string x = with
font
gdImageStringFT: Could not find/open font while printing string 2/ with font
gdImageStringFT: Could not find/open font while printing string Ö with
font Symbol
gdImageStringFT: Could not find/open font while printing string p with font
Symbol
gdImageStringFT: Could not find/open font while printing string with font
gdImageStringFT: Could not find/open font while printing string ò with
font Symbol
gdImageStringFT: Could not find/open font while printing string 0 with font
gdImageStringFT: Could not find/open font while printing string x with font
gdImageStringFT: Could not find/open font while printing string e with font
gdImageStringFT: Could not find/open font while printing string -t with font
gdImageStringFT: Could not find/open font while printing string 2 with font
gdImageStringFT: Could not find/open font while printing string dt with font
gdImageStringFT: Could not find/open font while printing string = 0.6175
with font
We could avoid this problem by not including "png" in the list of
"enhanced" terminals, but I'm not sure that is the best solution. If
there is a symbol font that can be used with gnuplot's png terminal,
then I would simply use it. If this is possible, will someone please
explain how to do it?
I think we should leave the default fontname property value
"Helvetica". It is easy enough to globally change the default
property for all figures using
set (0, "defaulttextfontname", "*");
in your ~/.octaverc file.
jwe
scripts/ChangeLog:
2007-12-04 John W. Eaton <address@hidden>
* plot/__go_draw_axes__.m: Omit "font \"NAME,SIZE\"" in gnuplot
text and label commands if font is "*".
doc/ChangeLog:
2007-12-04 John W. Eaton <address@hidden>
* interpreter/sparseimages.m, interpreter/plotimages.m,
interpreter/interpimages.m, interpreter/geometryimages.m:
Set default text font to "*" for png images.
Index: scripts/plot/__go_draw_axes__.m
===================================================================
RCS file: /cvs/octave/scripts/plot/__go_draw_axes__.m,v
retrieving revision 1.84
diff -u -u -r1.84 __go_draw_axes__.m
--- scripts/plot/__go_draw_axes__.m 3 Dec 2007 20:16:36 -0000 1.84
+++ scripts/plot/__go_draw_axes__.m 5 Dec 2007 01:09:38 -0000
@@ -74,8 +74,13 @@
else
[tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
have_newer_gnuplot);
- fprintf (plot_stream, "set title \"%s\" font \"%s,%d\";\n",
- undo_string_escapes (tt), f, s);
+ if (strcmp (f, "*"))
+ fontspec = "";
+ else
+ fontspec = sprintf ("font \"%s,%d\"", f, s);
+ endif
+ fprintf (plot_stream, "set title \"%s\" %s;\n",
+ undo_string_escapes (tt), fontspec);
endif
endif
@@ -89,12 +94,17 @@
else
[tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
have_newer_gnuplot);
+ if (strcmp (f, "*"))
+ fontspec = "";
+ else
+ fontspec = sprintf ("font \"%s,%d\"", f, s);
+ endif
if (strcmpi (axis_obj.xaxislocation, "top"))
- fprintf (plot_stream, "set x2label \"%s\" %s font \"%s,%d\"",
- undo_string_escapes (tt), colorspec, f, s);
+ fprintf (plot_stream, "set x2label \"%s\" %s %s",
+ undo_string_escapes (tt), colorspec, fontspec);
else
- fprintf (plot_stream, "set xlabel \"%s\" %s font \"%s,%d\"",
- undo_string_escapes (tt), colorspec, f, s);
+ fprintf (plot_stream, "set xlabel \"%s\" %s %s",
+ undo_string_escapes (tt), colorspec, fontspec);
endif
if (have_newer_gnuplot)
## Rotation of xlabel not yet support by gnuplot as of 4.2, but
@@ -120,12 +130,17 @@
else
[tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
have_newer_gnuplot);
+ if (strcmp (f, "*"))
+ fontspec = "";
+ else
+ fontspec = sprintf ("font \"%s,%d\"", f, s);
+ endif
if (strcmpi (axis_obj.yaxislocation, "right"))
- fprintf (plot_stream, "set y2label \"%s\" %s font \"%s,%d\"",
- undo_string_escapes (tt), colorspec, f, s);
+ fprintf (plot_stream, "set y2label \"%s\" %s %s",
+ undo_string_escapes (tt), colorspec, fontspec);
else
- fprintf (plot_stream, "set ylabel \"%s\" %s font \"%s,%d\"",
- undo_string_escapes (tt), colorspec, f, s);
+ fprintf (plot_stream, "set ylabel \"%s\" %s %s",
+ undo_string_escapes (tt), colorspec, fontspec);
endif
if (have_newer_gnuplot)
fprintf (plot_stream, " rotate by %f;\n", angle);
@@ -148,8 +163,13 @@
else
[tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
have_newer_gnuplot);
- fprintf (plot_stream, "set zlabel \"%s\" %s font \"%s,%d\"",
- undo_string_escapes (tt), colorspec, f, s);
+ if (strcmp (f, "*"))
+ fontspec = "";
+ else
+ fontspec = sprintf ("font \"%s,%d\"", f, s);
+ endif
+ fprintf (plot_stream, "set zlabel \"%s\" %s %s",
+ undo_string_escapes (tt), colorspec, fontspec);
if (have_newer_gnuplot)
## Rotation of zlabel not yet support by gnuplot as of 4.2, but
## there is no message about it.
@@ -913,6 +933,11 @@
case "text"
[label, f, s] = __maybe_munge_text__ (enhanced, obj, "string",
have_newer_gnuplot);
+ if (strcmp (f, "*"))
+ fontspec = "";
+ else
+ fontspec = sprintf ("font \"%s,%d\"", f, s);
+ endif
lpos = obj.position;
halign = obj.horizontalalignment;
angle = obj.rotation;
@@ -930,14 +955,14 @@
if (nd == 3)
fprintf (plot_stream,
- "set label \"%s\" at %s %.15g,%.15g,%.15g font \"%s,%d\"
%s rotate by %f %s;\n",
+ "set label \"%s\" at %s %.15g,%.15g,%.15g %s %s rotate by
%f %s;\n",
undo_string_escapes (label), units, lpos(1),
- lpos(2), lpos(3), f, s, halign, angle, colorspec);
+ lpos(2), lpos(3), fontspec, halign, angle, colorspec);
else
fprintf (plot_stream,
- "set label \"%s\" at %s %.15g,%.15g font \"%s,%d\" %s
rotate by %f %s;\n",
+ "set label \"%s\" at %s %.15g,%.15g %s %s rotate by %f
%s;\n",
undo_string_escapes (label), units,
- lpos(1), lpos(2), f, s, halign, angle, colorspec);
+ lpos(1), lpos(2), fontspec, halign, angle, colorspec);
endif
otherwise
Index: doc/interpreter/geometryimages.m
===================================================================
RCS file: /cvs/octave/doc/interpreter/geometryimages.m,v
retrieving revision 1.5
diff -u -u -r1.5 geometryimages.m
--- doc/interpreter/geometryimages.m 13 Oct 2007 00:52:12 -0000 1.5
+++ doc/interpreter/geometryimages.m 5 Dec 2007 01:09:37 -0000
@@ -18,6 +18,9 @@
function geometryimages (nm, typ)
bury_output ();
+ if (strcmp (typ, "png"))
+ set (0, "defaulttextfontname", "*");
+ endif
if (isempty (findstr (octave_config_info ("DEFS"), "HAVE_QHULL"))
&& (strcmp (nm, "voronoi") || strcmp (nm, "griddata")
|| strcmp (nm, "convhull") || strcmp (nm, "delaunay")
Index: doc/interpreter/interpimages.m
===================================================================
RCS file: /cvs/octave/doc/interpreter/interpimages.m,v
retrieving revision 1.4
diff -u -u -r1.4 interpimages.m
--- doc/interpreter/interpimages.m 13 Oct 2007 00:52:12 -0000 1.4
+++ doc/interpreter/interpimages.m 5 Dec 2007 01:09:37 -0000
@@ -18,6 +18,9 @@
function interpimages (nm, typ)
bury_output ();
+ if (strcmp (typ, "png"))
+ set (0, "defaulttextfontname", "*");
+ endif
if (strcmp (nm, "interpft"))
t = 0 : 0.3 : pi; dt = t(2)-t(1);
n = length (t); k = 100;
Index: doc/interpreter/plotimages.m
===================================================================
RCS file: /cvs/octave/doc/interpreter/plotimages.m,v
retrieving revision 1.4
diff -u -u -r1.4 plotimages.m
--- doc/interpreter/plotimages.m 5 Dec 2007 01:08:17 -0000 1.4
+++ doc/interpreter/plotimages.m 5 Dec 2007 01:09:37 -0000
@@ -18,6 +18,9 @@
function plotimages (nm, typ)
bury_output ();
+ if (strcmp (typ, "png"))
+ set (0, "defaulttextfontname", "*");
+ endif
if (strcmp(typ , "txt"))
image_as_txt(nm);
elseif (strcmp (nm, "plot"))
Index: doc/interpreter/sparseimages.m
===================================================================
RCS file: /cvs/octave/doc/interpreter/sparseimages.m,v
retrieving revision 1.8
diff -u -u -r1.8 sparseimages.m
--- doc/interpreter/sparseimages.m 5 Dec 2007 01:08:17 -0000 1.8
+++ doc/interpreter/sparseimages.m 5 Dec 2007 01:09:37 -0000
@@ -17,6 +17,9 @@
## <http://www.gnu.org/licenses/>.
function sparseimages (nm, typ)
+ if (strcmp (typ, "png"))
+ set (0, "defaulttextfontname", "*");
+ endif
if (! isempty (findstr (octave_config_info ("DEFS"), "HAVE_COLAMD"))
&& ! isempty (findstr (octave_config_info ("DEFS"), "HAVE_CHOLMOD"))
&& ! isempty (findstr (octave_config_info ("DEFS"), "HAVE_UMFPACK")))
Re: Font problem with png terminal 2.9.17+,
John W. Eaton <=
Re: Font problem with png terminal 2.9.17+, Tatsuro MATSUOKA, 2007/12/04