Mercurial > octave
changeset 26932:aa9745a1114a stable
Feed fig2dev with PDF files converted from svg (bug #55906)
* print.m (pstoedit): New argument to decide if pstoedit command is prepended
with svgconvert template.
* __opengl_print__.m: Use SVG base format for all fig2dev devices except pstex.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Fri, 15 Mar 2019 23:41:48 +0100 |
parents | 3e6aa7c7bbbb |
children | b6ac4615214f b4cb230ced82 |
files | scripts/plot/util/print.m scripts/plot/util/private/__opengl_print__.m |
diffstat | 2 files changed, 35 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/print.m Wed Mar 13 06:24:13 2019 +0100 +++ b/scripts/plot/util/print.m Fri Mar 15 23:41:48 2019 +0100 @@ -1014,22 +1014,36 @@ endfunction -function cmd = pstoedit (opts, devopt) +function cmd = pstoedit (opts, devopt, do_svg = true) if (nargin < 2) devopt = opts.devopt; endif if (isempty (opts.pstoedit_binary)) - error ("print:nopstoedit", "print.m: 'pstoedit' is required for specified output format, but binary is not available in PATH"); + error ("print:nopstoedit", ... + ["print.m: 'pstoedit' is required for specified output format, ", ... + "but binary is not available in PATH"]); endif dos_shell = (ispc () && ! isunix ()); - if (dos_shell) - cmd = sprintf ("%s -f %s 2> NUL", opts.pstoedit_binary, devopt); + + if (! do_svg) + if (dos_shell) + cmd = sprintf ("%s -f %s 2> NUL", opts.pstoedit_binary, devopt); + else + cmd = sprintf ("%s -f %s 2> /dev/null", opts.pstoedit_binary, devopt); + endi;f + endif else - ## FIXME: Is this the right thing to do for DOS? - cmd = sprintf ("%s -f %s 2> /dev/null", opts.pstoedit_binary, devopt); + cmd = svgconvert (opts, devopt); + if (dos_shell) + cmd = sprintf ("%s & %s -ssp -f %s %%s 2> NUL", cmd, ... + opts.pstoedit_binary, devopt); + else + cmd = sprintf ("%s ; %s -ssp -f %s %%s 2> /dev/null", cmd, ... + opts.pstoedit_binary, devopt); + endif endif if (opts.debug)
--- a/scripts/plot/util/private/__opengl_print__.m Wed Mar 13 06:24:13 2019 +0100 +++ b/scripts/plot/util/private/__opengl_print__.m Fri Mar 15 23:41:48 2019 +0100 @@ -88,9 +88,9 @@ pipeline = {sprintf("cat > %s", opts.name)}; endif case fig2dev_devices - cmd_pstoedit = opts.pstoedit_cmd (opts, "fig"); cmd_fig2dev = opts.fig2dev_cmd (opts, opts.devopt); if (strcmp (opts.devopt, "pstex")) + cmd_pstoedit = opts.pstoedit_cmd (opts, "fig", false); [~, ~, ext] = fileparts (opts.name); if (any (strcmpi (ext, {".ps", ".tex", "."}))) opts.name = opts.name(1:end-numel(ext)); @@ -104,17 +104,26 @@ pipeline{2} = sprintf ("%s | %s > %s", cmd_pstoedit, cmd_fig2dev, strrep(opts.name, ".ps", ".tex")); else + ## Using svgconvert + tmp = tempname (); + opts.unlink = [opts.unlink tmp]; + cmd_pstoedit = sprintf (opts.pstoedit_cmd (opts, "fig"), ... + "pdf", tmp, tmp); cmd = sprintf ("%s | %s > %s", cmd_pstoedit, cmd_fig2dev, opts.name); - gl2ps_device = {"eps"}; + gl2ps_device = {"svg"}; pipeline = {cmd}; endif case "aifm" - cmd = opts.pstoedit_cmd (opts, "ps2ai"); - gl2ps_device = {"eps"}; + tmp = tempname (); + opts.unlink = [opts.unlink tmp]; + cmd = sprintf (opts.pstoedit_cmd (opts, "ps2ai"), "pdf", tmp, tmp); + gl2ps_device = {"svg"}; pipeline = {sprintf("%s > %s", cmd, opts.name)}; case {"dxf", "emf", "fig", "hpgl"} - cmd = opts.pstoedit_cmd (opts); - gl2ps_device = {"eps"}; + tmp = tempname (); + opts.unlink = [opts.unlink tmp]; + cmd = sprintf (opts.pstoedit_cmd (opts), "pdf", tmp, tmp); + gl2ps_device = {"svg"}; pipeline = {sprintf("%s > %s", cmd, opts.name)}; case {"corel", "gif"} error ("print:unsupporteddevice",