annotate scripts/plot/__gnuplot_print__.m @ 10913:dd6b90f44ae5

Unify gnuplot printing with the fltk backend.
author Ben Abbott <bpabbott@mac.com>
date Fri, 27 Aug 2010 06:39:36 -0400
parents d5a7db05d591
children 2a25f282e965
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8889
diff changeset
1 ## Copyright (C) 1999, 2005, 2006, 2007, 2008, 2009 Daniel Heiserer
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
2 ## Copyright (C) 2001 Laurent Mazet
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
3 ##
5362
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
4 ## This file is part of Octave.
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
5 ##
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
7 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6965
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6965
diff changeset
9 ## your option) any later version.
5362
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
10 ##
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
14 ## General Public License for more details.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
15 ##
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6965
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6965
diff changeset
18 ## <http://www.gnu.org/licenses/>.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
19
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
21 ## @deftypefn {Function File} {} __gnuplot_print__ (@var{@dots{}})
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10711
diff changeset
22 ## Undocumented internal function.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
23 ## @end deftypefn
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
24
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
25 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de>
5362
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
26 ## Adapted-By: jwe
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
27
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
28 function __gnuplot_print__ (opts)
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
29
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
30 file2unlink = "";
9157
fce7315c1eee print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents: 9152
diff changeset
31
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
32 if (isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
33 ## If no fontsize, determine the nominal axes fontsize.
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
34 defaultfontsize = get (0, "defaultaxesfontsize");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
35 axesfontsize = get (findobj (opts.figure, "type", "axes"), "fontsize");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
36 if (iscell (axesfontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
37 axesfontsize = round (median (cell2mat (axesfontsize)));
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
38 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
39 if (isempty (axesfontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
40 opts.fontsize = defaultfontsize;
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
41 else
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
42 opts.fontsize = axesfontsize;
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
43 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
44 end
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
45 ## The axes-label and tick-label spacing is determined by
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
46 ## the font spec given in "set terminal ..."
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
47 gp_opts = font_spec (opts);
10423
dfc662a47b7a print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents: 10422
diff changeset
48
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
49 unwind_protect
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
50 switch lower (opts.devopt)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
51 case {"eps", "eps2", "epsc", "epsc2"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
52 if (any (strcmp (opts.devopt, {"eps", "epsc"})))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
53 gp_opts = sprintf ("%s level1", gp_opts);
10472
944aa97069ed print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents: 10423
diff changeset
54 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
55 eps_drawnow (opts, opts.name, gp_opts);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
56 case {"epslatex", "pslatex", "pstex", "epslatexstandalone"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
57 n = find (opts.devopt == "l", 1);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
58 suffix = opts.devopt(1:n-1);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
59 dot = find (opts.name == ".", 1, "last");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
60 if ((! isempty (dot))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
61 && any (strcmpi (opts.name(dot:end),
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
62 {".eps", ".ps", ".pdf", ".tex", "."})))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
63 name = opts.name(1:dot-1);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
64 if (dot < numel (opts.name)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
65 && any (strcmpi (opts.name(dot+1:end), {"eps", "ps"})))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
66 ## If user provides eps/ps suffix, use it.
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
67 suffix = opts.name(dot+1:end);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
68 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
69 elseif (dot == numel (opts.name))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
70 name = opts.name;
9393
d6c99b2ee941 print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents: 9337
diff changeset
71 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
72 if (strfind (opts.devopt, "standalone"))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
73 term = sprintf ("%s ",
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
74 strrep (opts.devopt, "standalone", " standalone"));
6727
3d1e0a056e6e [project @ 2007-06-14 20:45:10 by jwe]
jwe
parents: 6272
diff changeset
75 else
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
76 term = sprintf ("%s ", opts.devopt);
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
77 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
78 local_drawnow (sprintf ("%s %s", term, gp_opts),
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
79 strcat (name, ".", suffix, ".tex"), opts)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
80 movefile (strcat (name, ".", suffix, ".tex"), strcat (name, ".tex"));
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
81 if (opts.tight_flag && strncmpi (opts.devopt, "eps", 3))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
82 __tight_eps_bbox__ (opts, strcat (opts.name, ".eps"));
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
83 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
84 case {"tikz"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
85 local_drawnow (sprintf ("lua tikz %s", gp_opts), opts.name, opts);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
86 case {"ps", "ps2", "psc", "psc2", "pdf"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
87 if (any (strcmp (opts.devopt, {"ps", "psc"})))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
88 gp_opts = sprintf ("%s level1", gp_opts);
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
89 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
90 ## Gnuplot's BBox LLHC is located at [50,50]
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
91 opts.ghostscript.pageoffset = opts.ghostscript.pageoffset - 50;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
92 opts.ghostscript.source = strcat (tmpnam (), ".eps");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
93 file2unlink = opts.ghostscript.source;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
94 if (strcmp (opts.devopt, "pdf"))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
95 opts.ghostscript.device = "pdfwrite";
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
96 elseif (any (opts.devopt == '2'))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
97 opts.ghostscript.device = "ps2write";
9334
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
98 else
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
99 opts.ghostscript.device = "pswrite";
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
100 opts.ghostscript.level = 1;
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
101 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
102 opts.ghostscript.output = opts.name;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
103 eps_drawnow (opts, opts.ghostscript.source, gp_opts);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
104 case {"svg"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
105 local_drawnow (sprintf ("svg dynamic %s", gp_opts), opts.name, opts);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
106 case {"aifm", "corel", "eepic", "emf", "fig", "pdfcairo", "pngcairo"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
107 local_drawnow (sprintf ("%s %s", opts.devopt, gp_opts), opts.name, opts);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
108 case gs_based_devices ()
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
109 opts.ghostscript.antialiasing = true;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
110 switch opts.devopt
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
111 case "bmp"
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
112 opts.ghostscript.device = "bmp32b";
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
113 case "png"
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
114 opts.ghostscript.device = "png16m";
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
115 case {"tiff", "tiffn"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
116 opts.ghostscript.device = "tiff24nc";
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
117 otherwise
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
118 opts.ghostscript.device = opts.devopt;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
119 endswitch
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
120 opts.ghostscript.output = opts.name;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
121 opts.ghostscript.source = strcat (tmpnam (), ".eps");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
122 opts.ghostscript.epscrop = true;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
123 file2unlink = opts.ghostscript.source;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
124 eps_drawnow (opts, opts.ghostscript.source, gp_opts);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
125 case {"canvas", "dxf", "hpgl", "mf", "gif", "pstricks", "texdraw"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
126 local_drawnow (sprintf ("%s %s", opts.devopt, gp_opts), opts.name, opts)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
127 case {"pdflatex", "pslatexstandalone", "pdflatexstandalone"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
128 error (sprintf ("print:no%soutput", opts.devopt),
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
129 "print.m: %s output is not available for the GNUPLOT backend.",
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
130 upper (opts.devopt))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
131 otherwise
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
132 ## various ghostscript devices for printers
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
133 opts.ghostscript.device = opts.devopt;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
134 opts.ghostscript.output = opts.name;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
135 opts.ghostscript.epscrop = false;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
136 opts.ghostscript.source = strcat (tmpnam (), ".eps");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
137 file2unlink = opts.ghostscript.source;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
138 ## Gnuplot's BBox LLHC is located at [50,50]
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
139 opts.ghostscript.pageoffset = opts.ghostscript.pageoffset - 50;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
140 ## Empirical observation: "-dpxlcolor" requires a sign change.
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
141 opts.ghostscript.pageoffset = opts.ghostscript.pageoffset .* [1, -1];
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
142 ## Printers are not included in gs_devices()
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
143 gp_opts = font_spec (opts, "devopt", "eps");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
144 eps_drawnow (opts, opts.ghostscript.source, gp_opts);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
145 endswitch
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
146
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
147 if (! isempty (opts.ghostscript.device))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
148 status = __ghostscript__ (opts.ghostscript);
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
149 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
150
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
151 unwind_protect_cleanup
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
152 if (! isempty (file2unlink))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
153 [status, output] = unlink (file2unlink);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
154 if (status != 0)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
155 warning ("print.m: %s, '%s'.", output, file2unlink)
10423
dfc662a47b7a print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents: 10422
diff changeset
156 endif
6965
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
157 endif
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
158 end_unwind_protect
5363
37f62a7778c2 [project @ 2005-05-23 19:52:15 by jwe]
jwe
parents: 5362
diff changeset
159
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
160 endfunction
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
161
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
162 function eps_drawnow (opts, epsfile, gp_opts)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
163 [h, fontsize] = get_figure_text_objs (opts);
9334
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
164 unwind_protect
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
165 for n = 1:numel(h)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
166 set (h, "fontsize", 2 * fontsize{n});
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
167 endfor
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
168 local_drawnow (sprintf ("postscript eps %s", gp_opts), epsfile, opts);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
169 if (opts.tight_flag)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
170 __tight_eps_bbox__ (opts, epsfile);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
171 endif
9334
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
172 unwind_protect_cleanup
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
173 for n = 1:numel(h)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
174 set (h, "fontsize", fontsize{n});
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
175 endfor
9334
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
176 end_unwind_protect
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
177 endfunction
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
178
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
179 function local_drawnow (term, file, opts)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
180 if (opts.use_color < 0)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
181 mono = true;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
182 else
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
183 mono = false;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
184 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
185 figure (opts.figure)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
186 if (isempty (opts.debug_file) || ! opts.debug)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
187 drawnow (term, file, mono);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
188 else
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
189 drawnow (term, file, mono, opts.debug_file);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
190 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
191 endfunction
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
192
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
193 function device_list = gs_based_devices ();
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
194 ## Aliases for other devices: "bmp", "png", "tiff", "tiffn", "pdf",
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
195 ## "ps", "ps2", "psc", "psc2"
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
196 device_list = {"bmp16", "bmp16m", "bmp256", "bmp32b", "bmpgray", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
197 "jpeg", "jpegcymk", "jpeggray", "pbm", "pbmraw", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
198 "pcx16", "pcx24b", "pcx256", "pcx2up", "pcxcmyk", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
199 "pcxgray", "pcxmono", "pdfwrite", "pgm", "pgmraw", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
200 "pgnm", "pgnmraw", "png16", "png16m", "png256", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
201 "png48", "pngalpha", "pnggray", "pngmono", "pnm", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
202 "pnmraw", "ppm", "ppmraw", "ps2write", "pswrite", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
203 "tiff12nc", "tiff24nc", "tiff32nc", "tiffcrle", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
204 "tiffg3", "tiffg32d", "tiffg4", "tiffgray", "tifflzw", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
205 "tiffpack", "tiffsep", "bmp", "png", "tiff", "tiffn", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
206 "pdf", "ps", "ps2", "psc", "psc2"};
9334
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
207 endfunction
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
208
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
209 function f = font_spec (opts, varargin)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
210 for n = 1:2:numel(varargin)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
211 opts.(varargin{n}) = varargin{n+1};
9334
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
212 endfor
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
213 f = "";
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
214 switch opts.devopt
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
215 case {"cgm"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
216 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
217 f = sprintf ("font ""%s,%d""", opts.font, opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
218 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
219 f = sprintf ("font ""%s""", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
220 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
221 f = sprintf ("%d", opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
222 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
223 case {"eps", "eps2", "epsc", "epsc2", gs_based_devices(){:}}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
224 ## Gnuplot renders fonts as half their specification, which
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
225 ## results in a tight spacing for the axes-labels and tick-labels.
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
226 ## Compensate for the half scale. This will produce the proper
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
227 ## spacing for the requested fontsize.
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
228 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
229 f = sprintf ("font ""%s,%d""", opts.font, 2 * opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
230 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
231 f = sprintf ("font ""%s""", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
232 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
233 f = sprintf ("%d", 2 * opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
234 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
235 case {"svg"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
236 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
237 fontsize = round (opts.fontsize * 0.75);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
238 f = sprintf ("fname ""%s"" fsize %d", opts.font, fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
239 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
240 f = sprintf ("fname ""%s""", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
241 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
242 fontsize = round (opts.fontsize * 0.75);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
243 f = sprintf ("%s fsize %d", f, fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
244 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
245 case {"pdf"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
246 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
247 f = sprintf ("font ""%s,%d""", opts.font, opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
248 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
249 f = sprintf ("font ""%s""", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
250 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
251 f = sprintf ("fsize %d", f, opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
252 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
253 case {"pdfcairo", "pngcairo"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
254 if (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
255 f = sprintf ("font ""%s""", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
256 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
257 case {"epslatex", "epslatexstandalone"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
258 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
259 f = sprintf ("font ""%s,%d""", opts.font, opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
260 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
261 f = sprintf ("font ""%s""", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
262 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
263 f = sprintf ("%d", opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
264 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
265 case {"pslatex"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
266 if (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
267 f = sprintf ("%d", opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
268 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
269 case {"gif", "jpeg", "png"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
270 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
271 f = sprintf ("font ""%s ,%d""", opts.font, opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
272 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
273 f = sprintf ("font ""%s""", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
274 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
275 f = sprintf ("font ""%d""", opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
276 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
277 case {"emf"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
278 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
279 f = sprintf ("""%s"" %d", opts.font, opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
280 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
281 f = sprintf ("""%s""", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
282 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
283 f = sprintf ("%d", opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
284 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
285 case {"canvas"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
286 if (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
287 f = sprintf ("fsize %d", opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
288 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
289 case {"aifm", "corel"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
290 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
291 f = sprintf ("%s %d", opts.font, opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
292 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
293 f = sprintf ("%s", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
294 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
295 f = sprintf ("%d", opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
296 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
297 case {"fig"}
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
298 if (! isempty (opts.font) && ! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
299 f = sprintf ("font %s fontsize %d", opts.font, opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
300 elseif (! isempty (opts.font))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
301 f = sprintf ("font %s", opts.font);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
302 elseif (! isempty (opts.fontsize))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
303 f = sprintf ("fontsize %d", opts.fontsize);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
304 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
305 endswitch
9334
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
306 endfunction
4f96a7770492 print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents: 9249
diff changeset
307
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
308 function [h, fontsize] = get_figure_text_objs (opts)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
309 h = findall (opts.figure, "-property", "fontsize");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
310 fontsize = get (h, "fontsize");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
311 switch numel (fontsize)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
312 case 0
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
313 fontsize = {};
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
314 case 1
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
315 fontsize = {fontsize};
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
316 endswitch
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
317 endfunction