annotate scripts/plot/util/private/__print_parse_opts__.m @ 32632:2e484f9f1f18 stable

maint: update Octave Project Developers copyright for the new year
author John W. Eaton <jwe@octave.org>
date Fri, 22 Dec 2023 12:08:17 -0500
parents d668c52cf2e6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 32283
diff changeset
3 ## Copyright (C) 2010-2024 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27343
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
7 ##
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
8 ## This file is part of Octave.
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22571
diff changeset
13 ## (at your option) any later version.
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
14 ##
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22571
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22571
diff changeset
18 ## GNU General Public License for more details.
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
19 ##
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
25
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
27 ## @deftypefn {} {@var{args} =} __print_parse_opts__ (@var{propname}, @var{propvalue})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
28 ## @deftypefnx {} {@var{args} =} __print_parse_opts__ (@var{struct})
14130
e13bfbc2c4c5 __print_parse_opts__.m: Fix doc string and copyright.
Ben Abbott <bpabbott@mac.com>
parents: 13728
diff changeset
29 ## Undocumented internal function.
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
30 ## @end deftypefn
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
31
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
32 function arg_st = __print_parse_opts__ (varargin)
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
33
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
34 persistent warn_on_missing_ghostscript = true;
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
35
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
36 arg_st.append_to_file = false;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
37 arg_st.canvas_size = [];
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
38 arg_st.debug = false;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
39 arg_st.debug_file = "octave-print-commands.log";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
40 arg_st.devopt = "";
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
41 arg_st.epstool_binary = __quote_path__ (__find_binary__ ("epstool"));
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
42 arg_st.figure = get (0, "currentfigure");
10889
1d7a7fb5074b __print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents: 10876
diff changeset
43 arg_st.fig2dev_binary = __quote_path__ (__find_binary__ ("fig2dev"));
27007
dd31206c87c0 Fix scaling of fonts when printing with -Sxsz,ysz option (bug #55907).
Rik <rik@octave.org>
parents: 26936
diff changeset
44 arg_st.fontsize = [];
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
45 arg_st.font = "";
14206
df695e37d404 Make sure "print '-SX,Y' ..." doesn't round down a pixel. Bug # 35307.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
46 arg_st.scalefontsize = 1;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
47 arg_st.force_solid = 0; # 0=default, -1=dashed, +1=solid
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
48 arg_st.formatted_for_printing = false;
10889
1d7a7fb5074b __print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents: 10876
diff changeset
49 arg_st.ghostscript.binary = __quote_path__ (__ghostscript_binary__ ());
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
50 arg_st.ghostscript.debug = false;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
51 arg_st.ghostscript.device = "";
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
52 arg_st.ghostscript.epscrop = true;
19567
6a9bde1ba0ea Stop using deprecated and removed ghostscript device pswrite (bug #41141)
Rik <rik@octave.org>
parents: 17744
diff changeset
53 arg_st.ghostscript.level = 2;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
54 arg_st.ghostscript.output = "";
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
55 arg_st.ghostscript.papersize = "letter";
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
56 arg_st.ghostscript.pageoffset = [];
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
57 arg_st.ghostscript.resolution = 150;
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
58 arg_st.ghostscript.antialiasing = false;
14774
0d6dae0f6bc2 Allow setting of ghostscript TextAlphaBits and GraphicsAlphaBits.
John Hunt <huntj@gmx.us>
parents: 14549
diff changeset
59 arg_st.ghostscript.antialiasing_textalphabits = 4;
22517
34f98c1e4d56 Disable anti-aliasing for graphics in raster outputs (bug #48873).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22488
diff changeset
60 arg_st.ghostscript.antialiasing_graphicsalphabits = 1;
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
61 arg_st.lpr_binary = __quote_path__ (__find_binary__ ("lpr"));
31798
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
62 arg_st.polymerge = 1;
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
63 arg_st.name = "";
32283
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
64 arg_st.append_file_extension = true;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
65 arg_st.orientation = "";
10889
1d7a7fb5074b __print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents: 10876
diff changeset
66 arg_st.pstoedit_binary = __quote_path__ (__find_binary__ ("pstoedit"));
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
67 arg_st.preview = "";
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
68 arg_st.printer = "";
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
69 arg_st.renderer = "auto";
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
70 arg_st.resize_flag = "";
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
71 arg_st.rgb_output = false;
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
72 arg_st.send_to_printer = false;
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
73 arg_st.special_flag = "textnormal";
31432
df8bdaf1164b print.m: Use -svgconvert by default (bug #62979)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 31254
diff changeset
74 arg_st.svgconvert = true;
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
75 arg_st.svgconvert_binary = __quote_path__ (__svgconv_binary__ ());
26739
0c18acaa8b58 Revert changeset 3a10bdbe6839 which is only for stable branch.
Rik <rik@octave.org>
parents: 26737
diff changeset
76 arg_st.tight = true;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
77 arg_st.use_color = 0; # 0=default, -1=mono, +1=color
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
78
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
79 if (isunix ())
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
80 arg_st.lpr_options = "-l";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
81 elseif (ispc ())
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
82 arg_st.lpr_options = "-o l";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
83 else
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
84 arg_st.lpr_options = "";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
85 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
86 arg_st.unlink = {};
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
87
11268
1ddf64be9cbd __print_parse_opts__.m: For tests, allow __print_parse_opts__ to run with no inputs.
Ben Abbott <bpabbott@mac.com>
parents: 11253
diff changeset
88 if (nargin > 0 && isfigure (varargin{1}))
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents: 11120
diff changeset
89 arg_st.figure = varargin{1};
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents: 11120
diff changeset
90 varargin(1) = [];
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents: 11120
diff changeset
91 endif
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents: 11120
diff changeset
92
31798
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
93 if (! isempty (findall (arg_st.figure, "type", "patch", ...
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
94 "-or", "type", "surface")))
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
95 arg_st.polymerge = 2;
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
96 endif
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
97
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14774
diff changeset
98 for i = 1:numel (varargin)
30362
512f3d68bb49 print: Use clearer error message on invalid input (bug #61557).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30308
diff changeset
99 if (! ischar (varargin{i}) && ! iscellstr (varargin{i}))
512f3d68bb49 print: Use clearer error message on invalid input (bug #61557).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30308
diff changeset
100 error ("print: input arguments must be a graphics handle or strings.");
512f3d68bb49 print: Use clearer error message on invalid input (bug #61557).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30308
diff changeset
101 endif
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
102 arg = strtrim (varargin{i});
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
103 if (ischar (arg))
28388
56e7b2bb1dc6 Ignore empty arguments passed to print() (bug #58477).
Rik <rik@octave.org>
parents: 27923
diff changeset
104 if (isempty (arg))
56e7b2bb1dc6 Ignore empty arguments passed to print() (bug #58477).
Rik <rik@octave.org>
parents: 27923
diff changeset
105 continue;
56e7b2bb1dc6 Ignore empty arguments passed to print() (bug #58477).
Rik <rik@octave.org>
parents: 27923
diff changeset
106 elseif (strcmp (arg, "-color"))
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
107 arg_st.use_color = 1;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
108 elseif (strcmp (arg, "-append"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
109 arg_st.append_to_file = true;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
110 elseif (strcmp (arg, "-mono"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
111 arg_st.use_color = -1;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
112 elseif (strcmp (arg, "-solid"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
113 arg_st.force_solid = 1;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
114 elseif (strcmp (arg, "-dashed"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
115 arg_st.force_solid = -1;
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
116 elseif (any (strcmp (arg, {"-opengl", "-painters"})))
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
117 arg_st.renderer = arg(2:end);
30958
8a8f82c0235e print.m: Add options "-image"/"-vector" for Matlab compatibility.
Rik <rik@octave.org>
parents: 30564
diff changeset
118 elseif (strcmp (arg, "-image"))
8a8f82c0235e print.m: Add options "-image"/"-vector" for Matlab compatibility.
Rik <rik@octave.org>
parents: 30564
diff changeset
119 arg_st.renderer = "opengl";
8a8f82c0235e print.m: Add options "-image"/"-vector" for Matlab compatibility.
Rik <rik@octave.org>
parents: 30564
diff changeset
120 elseif (strcmp (arg, "-vector"))
8a8f82c0235e print.m: Add options "-image"/"-vector" for Matlab compatibility.
Rik <rik@octave.org>
parents: 30564
diff changeset
121 arg_st.renderer = "painters";
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
122 elseif (strcmp (arg, "-RGBImage"))
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
123 arg_st.rgb_output = true;
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
124 arg_st.renderer = "opengl";
17405
3f0ed69d21c6 Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents: 17380
diff changeset
125 elseif (strncmp (arg, "-portrait", length (arg)))
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
126 arg_st.orientation = "portrait";
17405
3f0ed69d21c6 Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents: 17380
diff changeset
127 elseif (strncmp (arg, "-landscape", length (arg)))
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
128 arg_st.orientation = "landscape";
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
129 elseif (strcmp (arg, "-loose"))
26173
0a145a1600e3 Use -tight option by default when printing EPS files (bug #53535).
Rik <rik@octave.org>
parents: 26104
diff changeset
130 arg_st.tight = false;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
131 elseif (strcmp (arg, "-tight"))
26173
0a145a1600e3 Use -tight option by default when printing EPS files (bug #53535).
Rik <rik@octave.org>
parents: 26104
diff changeset
132 arg_st.tight = true;
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
133 elseif (strcmp (arg, "-svgconvert"))
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
134 arg_st.svgconvert = true;
31432
df8bdaf1164b print.m: Use -svgconvert by default (bug #62979)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 31254
diff changeset
135 elseif (strcmp (arg, "-nosvgconvert"))
df8bdaf1164b print.m: Use -svgconvert by default (bug #62979)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 31254
diff changeset
136 arg_st.svgconvert = false;
31798
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
137 elseif (strcmp (arg, "-polymerge"))
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
138 arg_st.polymerge = 1;
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
139 elseif (strcmp (arg, "-nopolymerge"))
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
140 arg_st.polymerge = 0;
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
141 elseif (strcmp (arg, "-polymerge-all"))
82128f652585 print: Add option to merge only subsequent triangles with SVG toolchain (bug #63646).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31706
diff changeset
142 arg_st.polymerge = 2;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
143 elseif (strcmp (arg, "-textspecial"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
144 arg_st.special_flag = "textspecial";
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
145 elseif (strcmp (arg, "-fillpage"))
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
146 arg_st.resize_flag = "fillpage";
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
147 elseif (strcmp (arg, "-bestfit"))
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
148 arg_st.resize_flag = "bestfit";
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
149 elseif (any (strcmp (arg,
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
150 {"-interchange", "-metafile", "-pict", "-tiff"})))
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
151 arg_st.preview = arg(2:end);
32283
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
152 elseif (strcmp (arg, "-no-append-file-extension"))
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
153 arg_st.append_file_extension = false;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
154 elseif (strncmp (arg, "-debug", 6))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
155 arg_st.debug = true;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
156 arg_st.ghostscript.debug = true;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
157 if (length (arg) > 7)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
158 arg_st.debug_file = arg(8:end);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
159 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
160 elseif (length (arg) > 2 && arg(1:2) == "-d")
32002
939e5d952675 Use upper/lower in preference to toupper/tolower to match Matlab.
Rik <rik@octave.org>
parents: 31799
diff changeset
161 arg_st.devopt = lower (arg(3:end));
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
162 elseif (length (arg) > 2 && arg(1:2) == "-P")
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
163 arg_st.printer = arg;
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
164 elseif (strncmp (arg, "-EPSTOOL:", 9))
20950
165ba7463ca9 Fix indexing bugs in __print_parse_opts__.m (part of bug #44187)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20852
diff changeset
165 arg_st.epstool_binary = arg(10:end);
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
166 elseif (strncmp (arg, "-FIG2DEV:", 9))
20950
165ba7463ca9 Fix indexing bugs in __print_parse_opts__.m (part of bug #44187)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20852
diff changeset
167 arg_st.fig2dev_binary = arg(10:end);
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
168 elseif (strncmp (arg, "-PSTOEDIT:", 9))
20950
165ba7463ca9 Fix indexing bugs in __print_parse_opts__.m (part of bug #44187)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20852
diff changeset
169 arg_st.pstoedit_binary = arg(10:end);
14774
0d6dae0f6bc2 Allow setting of ghostscript TextAlphaBits and GraphicsAlphaBits.
John Hunt <huntj@gmx.us>
parents: 14549
diff changeset
170 elseif (strncmpi (arg, "-textalphabits=", 15))
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
171 if (length (arg) == 16 && any (arg(end) == "124"))
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
172 arg_st.ghostscript.antialiasing_textalphabits = str2double (arg(end));
14774
0d6dae0f6bc2 Allow setting of ghostscript TextAlphaBits and GraphicsAlphaBits.
John Hunt <huntj@gmx.us>
parents: 14549
diff changeset
173 else
15202
f3b5cadfd6d5 fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents: 14872
diff changeset
174 error ("print: improper syntax, or value, for TextAlphaBits");
14774
0d6dae0f6bc2 Allow setting of ghostscript TextAlphaBits and GraphicsAlphaBits.
John Hunt <huntj@gmx.us>
parents: 14549
diff changeset
175 endif
0d6dae0f6bc2 Allow setting of ghostscript TextAlphaBits and GraphicsAlphaBits.
John Hunt <huntj@gmx.us>
parents: 14549
diff changeset
176 elseif (strncmpi (arg, "-graphicsalphabits=", 19))
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
177 if (numel (arg) == 20 && any (arg(end) == "124"))
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
178 arg_st.ghostscript.antialiasing_graphicsalphabits = str2double (arg(end));
14774
0d6dae0f6bc2 Allow setting of ghostscript TextAlphaBits and GraphicsAlphaBits.
John Hunt <huntj@gmx.us>
parents: 14549
diff changeset
179 else
15202
f3b5cadfd6d5 fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents: 14872
diff changeset
180 error ("print: improper syntax, or value, for GraphicsAlphaBits");
14774
0d6dae0f6bc2 Allow setting of ghostscript TextAlphaBits and GraphicsAlphaBits.
John Hunt <huntj@gmx.us>
parents: 14549
diff changeset
181 endif
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
182 elseif (length (arg) > 2 && arg(1:2) == "-G")
11300
4ecc7bc5bc83 search PATH from environment for programs, not EXEC_PATH
John W. Eaton <jwe@octave.org>
parents: 11268
diff changeset
183 arg_st.ghostscript.binary = file_in_path (getenv ("PATH"), arg(3:end));
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
184 if (isempty (arg_st.ghostscript.binary))
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
185 error ('print: Ghostscript binary "%s" not found in PATH',
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
186 arg(3:end));
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
187 endif
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
188 arg_st.ghostscript.binary = __quote_path__ (arg_st.ghostscript.binary);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
189 elseif (length (arg) > 2 && arg(1:2) == "-F")
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
190 idx = rindex (arg, ":");
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
191 if (idx)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
192 arg_st.font = arg(3:idx-1);
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
193 arg_st.fontsize = str2double (arg(idx+1:end));
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
194 else
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
195 arg_st.font = arg(3:end);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
196 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
197 elseif (length (arg) > 2 && arg(1:2) == "-S")
24688
dd68506c0926 Fix print "-S" option parsing (bug #45285)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
198 arg_st.canvas_size = str2double (strsplit (arg(3:end), ","));
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
199 elseif (length (arg) > 2 && arg(1:2) == "-r")
11333
492e7b587352 Convert print resolution from char to double.
Rik <octave@nomad.inbox5.com>
parents: 11300
diff changeset
200 arg_st.ghostscript.resolution = str2double (arg(3:end));
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
201 elseif (length (arg) > 2 && arg(1:2) == "-f")
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
202 arg_st.figure = str2double (arg(3:end));
20038
6b78feb92f53 Accept, but warn about unimplemented Matlab print options (bug #44760).
Rik <rik@octave.org>
parents: 19833
diff changeset
203 elseif (strcmp (arg, "-noui"))
26104
0e4b9df85361 Don't issue a warning when -noui option used with print.
Rik <rik@octave.org>
parents: 26103
diff changeset
204 ## Accepted, but nothing needs to be done since Octave already
0e4b9df85361 Don't issue a warning when -noui option used with print.
Rik <rik@octave.org>
parents: 26103
diff changeset
205 ## excludes uicontrol objects when printing.
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
206 elseif (length (arg) >= 1 && arg(1) == "-")
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14530
diff changeset
207 error ("print: unknown option '%s'", arg);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
208 elseif (length (arg) > 0)
16488
d4ce14c19c2c Fix print to work with filenames which begin with '~' (bug #38694).
Rik <rik@octave.org>
parents: 15624
diff changeset
209 arg_st.name = tilde_expand (arg);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
210 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
211 elseif (isfigure (arg))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
212 arg_st.figure = arg;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
213 else
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20231
diff changeset
214 error ("print: first argument must be string or figure handle");
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
215 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
216 endfor
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
217
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
218 ## Resolution
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
219 if (arg_st.ghostscript.resolution == 0)
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
220 ## Do as Matlab does.
14530
93cb513ed5fc Fix regression after 3.4.0 with '-r0' option to print (bug #36092).
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
221 arg_st.ghostscript.resolution = get (0, "screenpixelsperinch");
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
222 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
223
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
224 ## Orientation
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
225 if (isempty (arg_st.orientation))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
226 if (isfigure (arg_st.figure))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
227 arg_st.orientation = get (arg_st.figure, "paperorientation");
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
228 else
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
229 ## Allows tests to be run without error.
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
230 arg_st.orientation = "portrait";
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
231 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
232 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
233
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
234 ## The device is infered from extension if not provided
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
235 dot = rindex (arg_st.name, ".");
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
236 if (isempty (arg_st.devopt))
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
237 if (arg_st.rgb_output)
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
238 arg_st.devopt = "png";
32283
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
239 elseif (dot == 0 || ! arg_st.append_file_extension)
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
240 arg_st.devopt = "psc";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
241 else
32002
939e5d952675 Use upper/lower in preference to toupper/tolower to match Matlab.
Rik <rik@octave.org>
parents: 31799
diff changeset
242 arg_st.devopt = lower (arg_st.name(dot+1:end));
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
243 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
244 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
245
26934
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
246 ## Warn about deprecated output formats
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
247 persistent unsupported = {"aifm", "ill","cdr", "corel", ...
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
248 "hpgl", "mf", "cgm", "dxf"}
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
249
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
250 if (any (strcmp (unsupported, arg_st.devopt)))
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
251 warning ('Octave:print:deprecated-format',
31463
6ea81caebab0 __print_parse_opts__.m: Correct language in warning message.
Rik <rik@octave.org>
parents: 31432
diff changeset
252 'print: "%s" format is no longer officially supported',
26934
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
253 arg_st.devopt);
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
254 endif
1771bed38482 Remove some formats from the list of supported formats (bug #55906)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26739
diff changeset
255
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
256 ## By default, use the "opengl" renderer for all raster outputs
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
257 ## supported by "imwrite".
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
258 fmts = imformats ();
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
259 persistent gl_devlist = [fmts(! cellfun (@isempty, {fmts.write})).ext, ...
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
260 "tiffn"];
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
261 opengl_ok = any (strcmp (gl_devlist, arg_st.devopt));
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
262
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
263 if (strcmp (arg_st.renderer, "auto")
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
264 && strcmp (get (arg_st.figure, "renderermode"), "manual"))
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
265 arg_st.renderer = get (arg_st.figure, "renderer");
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
266 endif
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
267
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
268 if (strcmp (arg_st.renderer, "auto"))
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
269 if (opengl_ok && strcmp (graphics_toolkit (arg_st.figure), "qt"))
29433
8811d8274118 Allow arbitrary text rotation onscreen (bug #33118)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29359
diff changeset
270 arg_st.renderer = "opengl";
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
271 else
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
272 arg_st.renderer = "painters";
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
273 endif
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
274 elseif (strcmp (arg_st.renderer, "opengl") && ! opengl_ok)
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
275 arg_st.renderer = "painters";
26567
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
276 warning (['print: unsupported output format "%s" for renderer ', ...
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
277 '"opengl".'], arg_st.devopt);
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
278 elseif (! strcmp (graphics_toolkit (arg_st.figure), "qt")
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
279 && strcmp (arg_st.renderer, "opengl"))
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
280 ## The opengl renderer only works with the "qt" toolkit
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
281 arg_st.renderer = "painters";
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
282 warning ('Octave:print:unsupported-renderer',
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
283 'print: "opengl" renderer unsupported for "%s" toolkit',
bf05a7c16e9e Choose "painters" renderer when printing rotated text (bug #55485)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
284 graphics_toolkit (arg_st.figure));
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
285 endif
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
286
26617
98afb8bbd1f6 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 26567
diff changeset
287
10918
811f8611995d __print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 10913
diff changeset
288 if (arg_st.use_color == 0)
811f8611995d __print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 10913
diff changeset
289 if (any (strcmp ({"ps", "ps2", "eps", "eps2"}, arg_st.devopt)))
811f8611995d __print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 10913
diff changeset
290 arg_st.use_color = -1;
811f8611995d __print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 10913
diff changeset
291 else
811f8611995d __print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 10913
diff changeset
292 arg_st.use_color = 1;
811f8611995d __print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 10913
diff changeset
293 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
294 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
295
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
296 if (strcmp (arg_st.devopt, "tex"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
297 arg_st.devopt = "epslatex";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
298 elseif (strcmp (arg_st.devopt, "ill"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
299 arg_st.devopt = "aifm";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
300 elseif (strcmp (arg_st.devopt, "cdr"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
301 arg_st.devopt = "corel";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
302 elseif (strcmp (arg_st.devopt, "meta"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
303 arg_st.devopt = "emf";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
304 elseif (strcmp (arg_st.devopt, "jpg"))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
305 arg_st.devopt = "jpeg";
25582
0df6454f58ea print.m: Allow 'tif' to indicate 'tiff' format (bug #54282).
Rik <rik@octave.org>
parents: 25307
diff changeset
306 elseif (strcmp (arg_st.devopt, "tif"))
0df6454f58ea print.m: Allow 'tif' to indicate 'tiff' format (bug #54282).
Rik <rik@octave.org>
parents: 25307
diff changeset
307 arg_st.devopt = "tiff";
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
308 elseif (strcmp (arg_st.devopt, "pdfcrop"))
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
309 arg_st.devopt = "pdfwrite";
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
310 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
311
26191
f41494a4977f Add "dumb" terminal to produce ASCII art with gnuplot (patch #8203).
Rüdiger Sonderfeld <ruediger@c-plusplus.de>
parents: 26173
diff changeset
312 persistent dev_list = [{"aifm", "corel", "dumb", "fig", "png", "jpeg", ...
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
313 "gif", "pbm", "pbmraw", "dxf", "mf", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
314 "svg", "hpgl", "ps", "ps2", "psc", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
315 "psc2", "eps", "eps2", "epsc", "epsc2", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
316 "emf", "pdf", "pslatex", "epslatex", "epslatexstandalone", ...
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
317 "pslatexstandalone", "pdflatexstandalone", ...
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
318 "pstex", "tiff", "tiffn", "tikz", "tikzstandalone", "pcxmono", ...
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
319 "pcx24b", "pcx256", "pcx16", "pgm", "pgmraw", ...
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
320 "ppm", "ppmraw", "pdflatex", "texdraw", ...
22571
83f106bfcb37 Make "pdflatex" an alias of "pdfcairolatex" for gnuplot toolkit print (bug #49223).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22533
diff changeset
321 "epscairo", "pdfcairo", "pngcairo", "cairolatex", ...
83f106bfcb37 Make "pdflatex" an alias of "pdfcairolatex" for gnuplot toolkit print (bug #49223).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22533
diff changeset
322 "pdfcairolatex", "pdfcairolatexstandalone", ...
83f106bfcb37 Make "pdflatex" an alias of "pdfcairolatex" for gnuplot toolkit print (bug #49223).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22533
diff changeset
323 "epscairolatex", "epscairolatexstandalone", "pstricks", ...
25307
f2eb8bfcccb6 Use consistent gnuplot toolkit font syntax allow SVG fractional font size (bug #53737)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25054
diff changeset
324 "epswrite", "eps2write", "pswrite", "ps2write", "pdfwrite", ...
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
325 "canvas", "cgm", "latex", "eepic"}, gl_devlist];
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
326
26191
f41494a4977f Add "dumb" terminal to produce ASCII art with gnuplot (patch #8203).
Rüdiger Sonderfeld <ruediger@c-plusplus.de>
parents: 26173
diff changeset
327 persistent suffixes = [{"ai", "cdr", "txt", "fig", "png", "jpg", ...
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
328 "gif", "pbm", "pbm", "dxf", "mf", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
329 "svg", "hpgl", "ps", "ps", "ps", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
330 "ps", "eps", "eps", "eps", "eps", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
331 "emf", "pdf", "tex", "tex", "tex", ...
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
332 "tex", "tex", ...
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
333 "ps", "tiff", "tiff", "tikz", "tikz", "pcx", ...
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
334 "pcx", "pcx", "pcx", "pgm", "pgm", ...
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
335 "ppm", "ppm", "tex", "tex", ...
22571
83f106bfcb37 Make "pdflatex" an alias of "pdfcairolatex" for gnuplot toolkit print (bug #49223).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22533
diff changeset
336 "eps", "pdf", "png", "tex", ...
83f106bfcb37 Make "pdflatex" an alias of "pdfcairolatex" for gnuplot toolkit print (bug #49223).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22533
diff changeset
337 "tex", "tex", ...
83f106bfcb37 Make "pdflatex" an alias of "pdfcairolatex" for gnuplot toolkit print (bug #49223).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22533
diff changeset
338 "tex", "tex", "tex", ...
25307
f2eb8bfcccb6 Use consistent gnuplot toolkit font syntax allow SVG fractional font size (bug #53737)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25054
diff changeset
339 "eps", "eps", "ps", "ps", "pdf", ...
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
340 "js", "cgm", "tex", "tex"}, gl_devlist];
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
341
11027
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
342 if (isfigure (arg_st.figure))
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
343 __graphics_toolkit__ = get (arg_st.figure, "__graphics_toolkit__");
11027
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
344 else
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
345 ## Allow tests when no figures are present.
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
346 __graphics_toolkit__ = get (0, "defaultfigure__graphics_toolkit__");
11027
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
347 endif
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
348
22488
a666e3ee6af8 Require gnuplot 4.4 as mininimum supported version.
Rik <rik@octave.org>
parents: 22323
diff changeset
349 if (strcmp (__graphics_toolkit__, "gnuplot"))
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
350 suffixes(strncmp (dev_list, "epslatex", 8)) = {"eps"};
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
351 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
352
25583
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
353 unknown_device = true;
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
354 default_suffix = "";
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
355 match = strcmpi (dev_list, arg_st.devopt);
25583
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
356 if (any (match))
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
357 unknown_device = false;
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
358 default_suffix = suffixes{match};
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
359 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
360
32283
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
361 if (arg_st.append_file_extension && dot == 0 && ! isempty (arg_st.name) ...
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
362 && ! isempty (default_suffix))
20778
8513c84a13cb Use parser string concatenation rather than strcat() for performance in m-files.
Rik <rik@octave.org>
parents: 20713
diff changeset
363 arg_st.name = [arg_st.name "." default_suffix];
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
364 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
365
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
366 if (arg_st.append_to_file)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
367 if (isempty (arg_st.name))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
368 arg_st.append_to_file = false;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
369 elseif (any (strcmpi (arg_st.devopt, {"eps", "eps2", "epsc", "epsc2", ...
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
370 "ps", "ps2", "psc", "psc2", "pdf"})))
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
371 have_ghostscript = ! isempty (__ghostscript_binary__ ());
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
372 if (have_ghostscript)
25781
e04c56bbbace isdir.m: Make m-file a legacy function (bug #54489)
Rik <rik@octave.org>
parents: 25626
diff changeset
373 file_exists = (numel (dir (arg_st.name)) == 1
e04c56bbbace isdir.m: Make m-file a legacy function (bug #54489)
Rik <rik@octave.org>
parents: 25626
diff changeset
374 && ! isfolder (arg_st.name));
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
375 if (! file_exists)
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
376 arg_st.append_to_file = false;
11113
a8ac114ec9ab Stylefixes, replace end by endif.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 11031
diff changeset
377 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
378 else
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
379 arg_st.append_to_file = false;
27059
2bf6dcb1563c Clean up error messages in print subsystem.
Rik <rik@octave.org>
parents: 27007
diff changeset
380 warning ("print: appended output requires Ghostscript to be installed");
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
381 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
382 else
27059
2bf6dcb1563c Clean up error messages in print subsystem.
Rik <rik@octave.org>
parents: 27007
diff changeset
383 warning ("print: appended output is not supported for device '%s'",
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
384 arg_st.devopt);
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
385 arg_st.append_to_file = false;
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
386 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
387 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10889
diff changeset
388
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
389 if (arg_st.rgb_output)
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
390 if (! isempty (arg_st.printer) || ! isempty (arg_st.name))
26936
72fab319b47d Capitalize "Octave" in warning IDs.
Rik <rik@octave.org>
parents: 26934
diff changeset
391 warning ("Octave:print:ignored_argument",
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
392 "print: ignoring file name and printer argument when using -RGBImage option");
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
393 endif
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
394 elseif (! isempty (arg_st.printer) || isempty (arg_st.name))
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
395 arg_st.send_to_printer = true;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
396 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
397
11022
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
398 if (any (strcmp (arg_st.devopt, {"ps", "ps2", "psc", "psc2", "pdf"})))
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
399 arg_st.formatted_for_printing = true;
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
400 endif
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
401
27343
2c9795736894 print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
402 aliases = gs_aliases (arg_st.svgconvert);
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
403 if (any (strcmp (arg_st.devopt, fieldnames (aliases)))
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
404 && ! strcmp (arg_st.renderer, "opengl"))
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
405 arg_st.devopt = aliases.(arg_st.devopt);
25583
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
406 unknown_device = false;
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
407 endif
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
408
11022
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
409 if ((any (strcmp (arg_st.devopt, gs_device_list))
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
410 && ! arg_st.formatted_for_printing)
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
411 || any (strcmp (arg_st.devopt, {"pswrite", "ps2write", "pdfwrite"})))
25583
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
412 unknown_device = false;
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
413 ## Use ghostscript for graphic formats
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
414 arg_st.ghostscript.device = arg_st.devopt;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
415 arg_st.ghostscript.output = arg_st.name;
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
416 arg_st.ghostscript.antialiasing = true;
11027
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
417 if (arg_st.formatted_for_printing)
26173
0a145a1600e3 Use -tight option by default when printing EPS files (bug #53535).
Rik <rik@octave.org>
parents: 26104
diff changeset
418 arg_st.ghostscript.epscrop = arg_st.tight;
11027
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
419 else
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
420 ## pstoedit throws errors if the EPS file isn't cropped
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
421 arg_st.ghostscript.epscrop = true;
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
422 endif
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
423 elseif (all (! strcmp (arg_st.devopt, dev_list)))
25583
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
424 ## Assume we are formatting output for a printer
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
425 arg_st.formatted_for_printing = true;
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
426 arg_st.ghostscript.device = arg_st.devopt;
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
427 arg_st.ghostscript.output = arg_st.name;
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
428 arg_st.ghostscript.antialiasing = false;
26173
0a145a1600e3 Use -tight option by default when printing EPS files (bug #53535).
Rik <rik@octave.org>
parents: 26104
diff changeset
429 arg_st.ghostscript.epscrop = arg_st.tight;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
430 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
431
25583
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
432 if (unknown_device)
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
433 error ("print: unknown device %s", arg_st.devopt);
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
434 endif
18148dc92122 Fix regression in 4.2.0 which disallowed printing with some Ghostscript devices.
Rik <rik@octave.org>
parents: 25307
diff changeset
435
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
436 if (arg_st.resize_flag)
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
437 if (! (arg_st.send_to_printer || arg_st.formatted_for_printing
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
438 || strncmp (arg_st.devopt, "pdf", 3)
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
439 || strncmp (arg_st.devopt, "ps", 2)))
28905
89a425f2c202 maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents: 28390
diff changeset
440 error ("print: the '%s' option is only valid for page formats and printers", arg_st.resize_flag);
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
441 endif
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
442 endif
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
443
17380
50794f5e2323 Set gs sOutputFile option to "-" when spooling to the system printer.
Ben Abbott <bpabbott@mac.com>
parents: 17174
diff changeset
444 if (arg_st.send_to_printer)
50794f5e2323 Set gs sOutputFile option to "-" when spooling to the system printer.
Ben Abbott <bpabbott@mac.com>
parents: 17174
diff changeset
445 if (isempty (arg_st.name))
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
446 ## Pipe the ghostscript output
17380
50794f5e2323 Set gs sOutputFile option to "-" when spooling to the system printer.
Ben Abbott <bpabbott@mac.com>
parents: 17174
diff changeset
447 arg_st.name = "-";
50794f5e2323 Set gs sOutputFile option to "-" when spooling to the system printer.
Ben Abbott <bpabbott@mac.com>
parents: 17174
diff changeset
448 else
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20950
diff changeset
449 error ("print: a filename may not specified when spooling to a printer");
17380
50794f5e2323 Set gs sOutputFile option to "-" when spooling to the system printer.
Ben Abbott <bpabbott@mac.com>
parents: 17174
diff changeset
450 endif
18601
077575fe9a7e __print_parse_opts__.m: Add ')' missing in cset cdc16fbb513f.
Rik <rik@octave.org>
parents: 18600
diff changeset
451 if (! any (strcmp (arg_st.devopt, gs_device_list)))
18600
cdc16fbb513f Allow only Ghostscript devices when spooling to a printer (bug #41957)
Rik <rik@octave.org>
parents: 17744
diff changeset
452 ## Only supported ghostscript devices
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20950
diff changeset
453 error ("print: format must be a valid Ghostscript format for spooling to a printer");
17380
50794f5e2323 Set gs sOutputFile option to "-" when spooling to the system printer.
Ben Abbott <bpabbott@mac.com>
parents: 17174
diff changeset
454 endif
25998
8d2b3e3ff182 print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25781
diff changeset
455 elseif (isempty (arg_st.name) && ! arg_st.rgb_output)
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20950
diff changeset
456 error ("print: an output filename must be specified");
17380
50794f5e2323 Set gs sOutputFile option to "-" when spooling to the system printer.
Ben Abbott <bpabbott@mac.com>
parents: 17174
diff changeset
457 endif
50794f5e2323 Set gs sOutputFile option to "-" when spooling to the system printer.
Ben Abbott <bpabbott@mac.com>
parents: 17174
diff changeset
458
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
459 if (isempty (arg_st.canvas_size))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
460 if (isfigure (arg_st.figure))
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
461 [arg_st.ghostscript.papersize, papersize_points, paperposition] = ...
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
462 gs_papersize (arg_st.figure, arg_st.orientation);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
463 else
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
464 ## allows BIST tests to be run
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
465 arg_st.ghostscript.papersize = "letter";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
466 paperposition = [0.25, 2.50, 8.00, 6.00] * 72;
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
467 papersize_points = [8.5, 11.0] * 72;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
468 endif
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
469
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
470 ## resize paper
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
471 if (arg_st.resize_flag)
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
472 if (strcmp (arg_st.resize_flag, "fillpage"))
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
473 ## leave a 0.25 inch margin on all sides of the page.
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
474 paperposition = [0.25 * 72, 0.25 * 72, ...
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
475 papersize_points(1) - 0.5*72, ...
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
476 papersize_points(2) - 0.5*72];
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
477 elseif (strcmp (arg_st.resize_flag, "bestfit"))
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
478 ## leaves a minimum page margin of 0.25 inches
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
479 if (paperposition(3) > paperposition(4))
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
480 fit_scale = papersize_points(1) / paperposition(3);
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
481 else
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
482 fit_scale = papersize_points(2) / paperposition(4);
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
483 endif
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
484 paperposition = [(papersize_points(1) - fit_scale*paperposition(3)) * 0.5, ...
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
485 (papersize_points(2) - fit_scale*paperposition(4)) * 0.5, ...
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
486 fit_scale * paperposition(3), ...
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
487 fit_scale * paperposition(4)];
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
488 endif
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
489 endif
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
490
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
491 arg_st.canvas_size = paperposition(3:4);
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
492 if (strcmp (__graphics_toolkit__, "gnuplot")
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
493 && ! arg_st.ghostscript.epscrop)
11027
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
494 arg_st.ghostscript.pageoffset = paperposition(1:2) - 50;
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
495 else
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
496 arg_st.ghostscript.pageoffset = paperposition(1:2);
a2bdd9180a3c __print_parse_opts__.m: Properly crop eps image and fix tests.
Ben Abbott <bpabbott@mac.com>
parents: 11022
diff changeset
497 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
498 else
27007
dd31206c87c0 Fix scaling of fonts when printing with -Sxsz,ysz option (bug #55907).
Rik <rik@octave.org>
parents: 26936
diff changeset
499 ## Size specified with -S option
dd31206c87c0 Fix scaling of fonts when printing with -Sxsz,ysz option (bug #55907).
Rik <rik@octave.org>
parents: 26936
diff changeset
500 if (arg_st.ghostscript.resolution != 150)
dd31206c87c0 Fix scaling of fonts when printing with -Sxsz,ysz option (bug #55907).
Rik <rik@octave.org>
parents: 26936
diff changeset
501 warning ("print: '-Sxsize,ysize' overrides resolution option -r\n");
14206
df695e37d404 Make sure "print '-SX,Y' ..." doesn't round down a pixel. Bug # 35307.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
502 endif
27007
dd31206c87c0 Fix scaling of fonts when printing with -Sxsz,ysz option (bug #55907).
Rik <rik@octave.org>
parents: 26936
diff changeset
503 arg_st.scalefontsize = arg_st.canvas_size(1) / ...
dd31206c87c0 Fix scaling of fonts when printing with -Sxsz,ysz option (bug #55907).
Rik <rik@octave.org>
parents: 26936
diff changeset
504 6 / get (0, "screenpixelsperinch");
14206
df695e37d404 Make sure "print '-SX,Y' ..." doesn't round down a pixel. Bug # 35307.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
505 arg_st.ghostscript.resolution = 72;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
506 arg_st.ghostscript.papersize = arg_st.canvas_size;
30972
973be5be3327 __print_parse_opts__.m: Initialize variables in all cases for print warnings (bug #62287)
Rik <rik@octave.org>
parents: 30564
diff changeset
507 papersize_points = arg_st.canvas_size * 72;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
508 arg_st.ghostscript.epscrop = true;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
509 arg_st.ghostscript.pageoffset = [0, 0];
30972
973be5be3327 __print_parse_opts__.m: Initialize variables in all cases for print warnings (bug #62287)
Rik <rik@octave.org>
parents: 30564
diff changeset
510 paperposition = [0, 0];
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
511 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
512
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
513 if (arg_st.formatted_for_printing)
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
514 arg_st.ghostscript.resolution = [];
29442
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
515
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
516 ## Warn if the figure is too large for the selected paper size
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
517 if (any (papersize_points < (arg_st.canvas_size + paperposition(1:2)))
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
518 || any (paperposition(1:2) < 0))
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
519 warning ("Octave:print:figure-too-large", ...
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
520 ['print: given the current "paperposition" and ', ...
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
521 '"papersize" properties, the figure is too large ', ...
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
522 "and will be cropped to fit on the output page."]);
3a27122022f7 print.m: Warn when figure is too large to be printed to output page (bug #60236)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 29358
diff changeset
523 endif
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
524 else
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
525 arg_st.ghostscript.papersize = "";
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
526 arg_st.ghostscript.pageoffset = [0, 0];
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
527 endif
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
528
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
529 if (warn_on_missing_ghostscript)
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
530 if (isempty (arg_st.ghostscript.binary))
27068
2cede23e44c3 Warn gently if ghostscript binary is missing (bug #56201).
Rik <rik@octave.org>
parents: 27059
diff changeset
531 warning ("print:nogs", ...
2cede23e44c3 Warn gently if ghostscript binary is missing (bug #56201).
Rik <rik@octave.org>
parents: 27059
diff changeset
532 "print: 'gs' (Ghostscript) binary is not available. Many formats may not be available\n");
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
533 endif
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
534 warn_on_missing_ghostscript = false;
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
535 endif
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
536
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
537 endfunction
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
538
21759
b002b4331a12 maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents: 21758
diff changeset
539
12793
6f91ca83d2be codesprint : Make many plot helper functions private.
Rik <octave@nomad.inbox5.com>
parents: 12460
diff changeset
540 ## Test blocks are not allowed (and not needed) for private functions
31254
5d6b058a22dc maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents: 30973
diff changeset
541 %!#test
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
542 %! opts = __print_parse_opts__ ();
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
543 %! assert (opts.devopt, "pswrite");
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
544 %! assert (opts.use_color, 1);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
545 %! assert (opts.send_to_printer, true);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
546 %! assert (opts.canvas_size, [576, 432]);
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
547 %! assert (opts.ghostscript.device, "pswrite");
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
548
31254
5d6b058a22dc maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents: 30973
diff changeset
549 %!#test
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
550 %! opts = __print_parse_opts__ ("test.pdf", "-S640,480");
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
551 %! assert (opts.canvas_size, [307.2, 230.4], 0.1);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
552
31254
5d6b058a22dc maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents: 30973
diff changeset
553 %!#test
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
554 %! opts = __print_parse_opts__ ("-dpsc", "-append", "-loose");
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
555 %! assert (opts.devopt, "pswrite");
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
556 %! assert (opts.send_to_printer, true);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
557 %! assert (opts.use_color, 1);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
558 %! assert (opts.append_to_file, false);
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
559 %! assert (opts.ghostscript.device, "pswrite");
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
560 %! assert (opts.ghostscript.epscrop, false);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
561
31254
5d6b058a22dc maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents: 30973
diff changeset
562 %!#test
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
563 %! opts = __print_parse_opts__ ("-deps", "-tight");
26173
0a145a1600e3 Use -tight option by default when printing EPS files (bug #53535).
Rik <rik@octave.org>
parents: 26104
diff changeset
564 %! assert (opts.tight, true);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
565 %! assert (opts.send_to_printer, true);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
566 %! assert (opts.use_color, -1);
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
567 %! assert (opts.ghostscript.device, "");
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
568
31254
5d6b058a22dc maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents: 30973
diff changeset
569 %!#test
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
570 %! opts = __print_parse_opts__ ("-djpg", "foobar", "-mono", "-loose");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
571 %! assert (opts.devopt, "jpeg");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
572 %! assert (opts.name, "foobar.jpg");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
573 %! assert (opts.ghostscript.device, "jpeg");
11031
d81b6144c4ba __print_parse_opts__.m: Fix test.
Ben Abbott <bpabbott@mac.com>
parents: 11027
diff changeset
574 %! assert (opts.ghostscript.epscrop, true);
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
575 %! assert (opts.ghostscript.papersize, "");
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
576 %! assert (opts.ghostscript.pageoffset, [0, 0]);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
577 %! assert (opts.send_to_printer, false);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
578 %! assert (opts.printer, "");
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
579 %! assert (opts.use_color, -1);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
580
31254
5d6b058a22dc maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents: 30973
diff changeset
581 %!#test
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
582 %! opts = __print_parse_opts__ ("-ddeskjet", "foobar", "-mono", "-Pmyprinter");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
583 %! assert (opts.ghostscript.output, "foobar.deskjet");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
584 %! assert (opts.ghostscript.device, "deskjet");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
585 %! assert (opts.devopt, "deskjet");
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
586 %! assert (opts.send_to_printer, true);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
587 %! assert (opts.printer, "-Pmyprinter");
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
588 %! assert (opts.use_color, -1);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
589
31254
5d6b058a22dc maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents: 30973
diff changeset
590 %!#test
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
591 %! opts = __print_parse_opts__ ("-f5", "-dljet3");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
592 %! assert (opts.ghostscript.device, "ljet3");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
593 %! assert (strfind (opts.ghostscript.output, ".ljet3"));
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
594 %! assert (opts.devopt, "ljet3");
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
595 %! assert (opts.send_to_printer, true);
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14206
diff changeset
596 %! assert (opts.figure, 5);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
597
10889
1d7a7fb5074b __print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents: 10876
diff changeset
598 function cmd = __quote_path__ (cmd)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21385
diff changeset
599
14403
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
600 if (! isempty (cmd))
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
601 is_quoted = all (cmd([1, end]) == "'");
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
602 if (! is_quoted)
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
603 dos_shell = ! isunix () && ispc ();
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
604 if (dos_shell && any (cmd == "/"))
24370
b1d1229d9e83 maint: Use single quotes to simplify excessive backslash escapes in code.
Rik <rik@octave.org>
parents: 23991
diff changeset
605 cmd = strrep (cmd, '/', '\');
14403
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
606 endif
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
607 if (any (cmd == " "))
20778
8513c84a13cb Use parser string concatenation rather than strcat() for performance in m-files.
Rik <rik@octave.org>
parents: 20713
diff changeset
608 cmd = ['"' strrep(cmd, '"', '""') '"'];
14403
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
609 endif
61cc4c715962 Replace file-separater "/" with "\" for MinGW MSYS shell.
Ben Abbott <bpabbott@mac.com>
parents: 14366
diff changeset
610 endif
10889
1d7a7fb5074b __print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents: 10876
diff changeset
611 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21385
diff changeset
612
10889
1d7a7fb5074b __print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents: 10876
diff changeset
613 endfunction
1d7a7fb5074b __print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents: 10876
diff changeset
614
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
615 function gs = __ghostscript_binary__ ()
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
616
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
617 persistent ghostscript_binary = "";
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
618 persistent warn_on_bad_gsc = true;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
619
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
620 if (isempty (ghostscript_binary))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
621 GSC = getenv ("GSC");
11300
4ecc7bc5bc83 search PATH from environment for programs, not EXEC_PATH
John W. Eaton <jwe@octave.org>
parents: 11268
diff changeset
622 if (exist (GSC, "file")
4ecc7bc5bc83 search PATH from environment for programs, not EXEC_PATH
John W. Eaton <jwe@octave.org>
parents: 11268
diff changeset
623 || (! isempty (GSC) && file_in_path (getenv ("PATH"), GSC)))
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
624 gs_binaries = {GSC};
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
625 elseif (! isempty (GSC) && warn_on_bad_gsc)
26936
72fab319b47d Capitalize "Octave" in warning IDs.
Rik <rik@octave.org>
parents: 26934
diff changeset
626 warning ("Octave:print:badgscenv",
72fab319b47d Capitalize "Octave" in warning IDs.
Rik <rik@octave.org>
parents: 26934
diff changeset
627 "print: GSC environment variable not set properly");
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
628 warn_on_bad_gsc = false;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
629 gs_binaries = {};
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
630 else
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
631 gs_binaries = {};
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
632 endif
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
633
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
634 if (isunix ())
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
635 ## Unix - Includes Mac OSX and Cygwin.
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
636 gs_binaries = [gs_binaries, {"gs", "gs.exe"}];
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
637 else
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
638 ## pc - Includes Win32 and mingw.
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
639 gs_binaries = [gs_binaries, ...
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
640 {"gs.exe", "gswin32c.exe", "gswin64c.exe", "mgs.exe"}];
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
641 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
642 n = 0;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
643 while (n < numel (gs_binaries) && isempty (ghostscript_binary))
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
644 ghostscript_binary = file_in_path (getenv ("PATH"), gs_binaries{++n});
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
645 endwhile
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
646 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
647
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
648 gs = ghostscript_binary;
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
649
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
650 endfunction
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
651
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
652 function bin = __svgconv_binary__ ()
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
653
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
654 persistent binary = "";
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
655
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
656 if (isempty (binary))
29464
7aa1994c0ca2 Prefer "octave-svgconvert" in "bin" directory on Windows (bug #59546).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29443
diff changeset
657 ## default installation location is the archlib directory
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
658 bindir = getenv ("OCTAVE_ARCHLIBDIR");
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
659 if (isempty (bindir))
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
660 bindir = __octave_config_info__ ("archlibdir");
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
661 endif
26617
98afb8bbd1f6 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 26567
diff changeset
662
29464
7aa1994c0ca2 Prefer "octave-svgconvert" in "bin" directory on Windows (bug #59546).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29443
diff changeset
663 binary = fullfile (bindir, ...
7aa1994c0ca2 Prefer "octave-svgconvert" in "bin" directory on Windows (bug #59546).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29443
diff changeset
664 ["octave-svgconvert", ...
7aa1994c0ca2 Prefer "octave-svgconvert" in "bin" directory on Windows (bug #59546).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29443
diff changeset
665 __octave_config_info__("EXEEXT")]);
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
666
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
667 if (! exist (binary, "file"))
29464
7aa1994c0ca2 Prefer "octave-svgconvert" in "bin" directory on Windows (bug #59546).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29443
diff changeset
668 binary = "";
26027
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
669 endif
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
670 endif
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
671
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
672 bin = binary;
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
673
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
674 endfunction
98d7a111786a Add SVG convertion option for printing to PDF and raster outputs (bug #52193)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25998
diff changeset
675
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
676 function bin = __find_binary__ (binary)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
677
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
678 persistent data = struct ();
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
679
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
680 if (! isfield (data, binary))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
681 data.(binary).bin = "";
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
682 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
683
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
684 if (isempty (data.(binary).bin))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
685 if (isunix ())
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
686 ## Unix - Includes Mac OSX and Cygwin.
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
687 binaries = strcat (binary, {"", ".exe"});
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
688 else
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
689 ## pc - Includes Win32 and mingw.
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
690 binaries = strcat (binary, {".exe"});
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
691 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
692 n = 0;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
693 while (n < numel (binaries) && isempty (data.(binary).bin))
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
694 data.(binary).bin = file_in_path (getenv ("PATH"), binaries{++n});
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
695 endwhile
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
696 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
697
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
698 bin = data.(binary).bin;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
699
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
700 endfunction
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
701
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
702 function [papersize, papersize_points, paperposition] = gs_papersize (hfig, paperorientation)
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
703 persistent papertypes papersizes;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10727
diff changeset
704
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
705 if (isempty (papertypes))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
706 papertypes = {"usletter", "uslegal", "a0", "a1", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
707 "a2", "a3", "a4", "a5", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
708 "b0", "b1", "b2", "b3", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
709 "b4", "b5", "arch-a", "arch-b", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
710 "arch-c", "arch-d", "arch-e", "a", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
711 "b", "c", "d", "e", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
712 "tabloid"};
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
713 papersizes = [ 8.5, 11.0; 8.5, 14.0; 33.1, 46.8; 23.4, 33.1;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
714 16.5, 23.4; 11.7, 16.5; 8.3, 11.7; 5.8, 8.3;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
715 39.4, 55.7; 27.8, 39.4; 19.7, 27.8; 13.9, 19.7;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
716 9.8, 13.9; 6.9, 9.8; 9.0, 12.0; 12.0, 18.0;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
717 18.0, 24.0; 24.0, 36.0; 36.0, 48.0; 8.5, 11.0;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
718 11.0, 17.0; 18.0, 24.0; 24.0, 36.0; 36.0, 48.0;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
719 11.0, 17.0] * 72;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
720 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
721
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
722 papertype = get (hfig, "papertype");
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
723 paperunits = get (hfig, "paperunits");
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
724 paperposition = get (hfig, "paperposition");
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
725 if (strcmp (papertype, "<custom>"))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
726 papersize = get (hfig, "papersize");
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
727 papersize = convert2points (papersize, paperunits);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
728 else
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
729 papersize = papersizes(strcmp (papertypes, papertype), :);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
730 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
731
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
732 if (strcmp (paperunits, "normalized"))
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 20038
diff changeset
733 paperposition .*= papersize([1,2,1,2]);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
734 else
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
735 paperposition = convert2points (paperposition, paperunits);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
736 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
737
18857
7bbe3658c5ef maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents: 18601
diff changeset
738 ## FIXME: This will be obsoleted by listeners for paper properties.
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
739 ## papersize is tall when portrait, and wide when landscape.
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
740 if ((papersize(1) > papersize(2) && strcmpi (paperorientation, "portrait"))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
741 || (papersize(1) < papersize(2) && strcmpi (paperorientation, "landscape")))
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
742 papersize = papersize([2,1]);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
743 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
744
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
745 ## papersize is now [h,w] and measured in points.
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
746 ## Return it for possible resize outside of this function.
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
747 papersize_points = papersize;
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
748
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
749 if (! strcmp (papertype, "<custom>")
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
750 && (strcmp (paperorientation, "portrait")))
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
751 ## For portrait use the ghostscript name
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
752 papersize = papertype;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
753 papersize(papersize=="-") = "";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
754 papersize = strrep (papersize, "us", "");
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11113
diff changeset
755 switch (papersize)
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 16488
diff changeset
756 case "a"
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 16488
diff changeset
757 papersize = "letter";
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 16488
diff changeset
758 case {"b", "tabloid"}
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 16488
diff changeset
759 papersize = "11x17";
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 16488
diff changeset
760 case {"c", "d", "e"}
20778
8513c84a13cb Use parser string concatenation rather than strcat() for performance in m-files.
Rik <rik@octave.org>
parents: 20713
diff changeset
761 papersize = ["arch" papersize];
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
762 endswitch
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
763 if (strncmp (papersize, "arch", 4))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
764 papersize(end) = upper (papersize(end));
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
765 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
766 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
767
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
768 endfunction
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
769
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
770 function value = convert2points (value, units)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21385
diff changeset
771
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 16488
diff changeset
772 switch (units)
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11113
diff changeset
773 case "inches"
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 20038
diff changeset
774 value *= 72;
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11113
diff changeset
775 case "centimeters"
26103
9cfbe7688368 Add -fillpage and -bestfit print options (bug #52838).
Jun Wang <jstzwj@aliyun.com>
parents: 26027
diff changeset
776 value *= (72 / 2.54);
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11113
diff changeset
777 case "normalized"
27069
0a62d9a6aa2d Place Octave's warning and error IDs in to the "Octave" namespace (bug #56213).
Rik <rik@octave.org>
parents: 27068
diff changeset
778 error ("Octave:print:customnormalized",
27059
2bf6dcb1563c Clean up error messages in print subsystem.
Rik <rik@octave.org>
parents: 27007
diff changeset
779 "print: papersize=='<custom>' and paperunits='normalized' may not be combined");
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 16488
diff changeset
780 endswitch
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21385
diff changeset
781
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
782 endfunction
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
783
22767
212333a97d8d maint: Remove dangling ';' from m-file function declarations.
Rik <rik@octave.org>
parents: 22755
diff changeset
784 function device_list = gs_device_list ()
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30362
diff changeset
785
19568
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
786 ## Graphics formats/languages, not printers.
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
787 device_list = {"bmp16"; "bmp16m"; "bmp256"; "bmp32b"; "bmpgray"; ...
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
788 "epswrite"; "eps2write"; "jpeg"; "jpegcymk"; "jpeggray";
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
789 "pbm"; "pbmraw"; "pcx16"; "pcx24b"; "pcx256"; "pcx2up"; ...
11022
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
790 "pcxcmyk"; "pcxgray"; "pcxmono"; "pdfwrite"; "pgm"; ...
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
791 "pgmraw"; "pgnm"; "pgnmraw"; "png16"; "png16m"; ...
a5bee81bb69f __print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
792 "png256"; "png48"; "pngalpha"; "pnggray"; "pngmono"; ...
25626
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25584
diff changeset
793 "pnm"; "pnmraw"; "ppm"; "ppmraw"; "pswrite"; "ps2write"; ...
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25584
diff changeset
794 "tiff12nc"; "tiff24nc"; "tiff32nc"; "tiff48nc"; ...
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25584
diff changeset
795 "tiff64nc"; "tiffcrle"; "tiffg3"; "tiffg32d"; "tiffg4"; ...
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25584
diff changeset
796 "tiffgray"; "tifflzw"; "tiffpack"; "tiffscaled"; ...
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25584
diff changeset
797 "tiffscaled24"; "tiffscaled32"; "tiffscaled4"; ...
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25584
diff changeset
798 "tiffscaled8"; "tiffsep"; "tiffsep1" };
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25584
diff changeset
799
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
800 endfunction
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
801
27343
2c9795736894 print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
802 function aliases = gs_aliases (do_eps)
2c9795736894 print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
803
2c9795736894 print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
804 ## Ghostscript device names
19568
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
805 aliases.bmp = "bmp32b";
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
806 aliases.pdf = "pdfwrite";
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
807 aliases.png = "png16m";
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
808 aliases.ps = "ps2write";
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
809 aliases.ps2 = "ps2write";
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
810 aliases.psc = "ps2write";
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
811 aliases.psc2 = "ps2write";
25626
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25584
diff changeset
812 aliases.tiff = "tiffscaled24";
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
813 aliases.tiffn = "tiff24nc";
27343
2c9795736894 print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
814
2c9795736894 print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
815 if (do_eps)
32283
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
816 aliases.eps = "eps2write";
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
817 aliases.eps2 = "eps2write";
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
818 aliases.epsc = "eps2write";
d668c52cf2e6 print.m: Optionally don't append file extension to file name (bug #64510).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32002
diff changeset
819 aliases.epsc2 = "eps2write";
27343
2c9795736894 print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
820 endif
2c9795736894 print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
821
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10918
diff changeset
822 endfunction