# HG changeset patch # User Markus Mützel # Date 1752568258 -7200 # Tue Jul 15 10:30:58 2025 +0200 # Node ID e0dfd0f1abe927275328ebe40c1bd92e02bfb3f3 # Parent 2b1e9d51ed45cb853e7e2e451ce0e0a7e1758172 print: Optionally use svgconvert for "*latex*" devices (bug #67318). * scripts/plot/util/private/__opengl_print__.m: Optionally, use toolchain that goes through svgconvert to print non-text part when printing to "*latex*" devices. diff --git a/scripts/plot/util/private/__opengl_print__.m b/scripts/plot/util/private/__opengl_print__.m --- a/scripts/plot/util/private/__opengl_print__.m +++ b/scripts/plot/util/private/__opengl_print__.m @@ -68,15 +68,61 @@ function opts = __opengl_print__ (opts) "invalid suffix '%s' for device '%s'.", ext, lower (opts.devopt)); endif - gl2ps_device = {sprintf("%snotxt", lower (suffix))}; + svgcmd = ""; + if (opts.svgconvert) + svgcmd = opts.svgconvert_cmd (opts); + endif + dosvg = ! isempty (svgcmd); + if (dosvg) + gl2ps_device = {"svgnotxt"}; + else + gl2ps_device = {sprintf("%snotxt", lower (suffix))}; + endif gl2ps_device{2} = "tex"; if (dos_shell) - pipeline = {sprintf('findstr . > "%s-inc.%s"', name, suffix)}; - pipeline{2} = sprintf ('findstr . > "%s.tex"', name); + cat_cmd = "findstr ."; else - pipeline = {sprintf('cat > "%s-inc.%s"', name, suffix)}; - pipeline{2} = sprintf ('cat > "%s.tex"', name); + cat_cmd = "cat"; endif + if (dosvg) + if (strcmpi (suffix, "pdf")) + cmd = sprintf (svgcmd, "pdf", sprintf ("%s-inc.pdf", name)); + else + tmp = [tempname(), ".pdf"]; + svgcmd = sprintf (svgcmd, "pdf", tmp); + opts.unlink = [opts.unlink, tmp]; + opts.ghostscript.source = tmp; + opts.ghostscript.output = sprintf ("%s-inc.%s", name, suffix); + if (strfind (lower (opts.devopt), "eps")) + opts.ghostscript.device = "eps2write"; + else + opts.ghostscript.device = "ps2write"; + endif + [cmd_gs, cmd_cleanup] = __ghostscript__ (opts.ghostscript); + if (dos_shell) + cmd = sprintf ("%s & %s", svgcmd, cmd_gs); + else + cmd = sprintf ("%s ; %s", svgcmd, cmd_gs); + endif + if (! isempty (cmd_cleanup)) + if (dos_shell) + cmd = sprintf ("%s & %s", cmd, cmd_cleanup); + else + cmd = sprintf ("%s ; %s", cmd, cmd_cleanup); + endif + endif + endif + ## append comment with file name for heuristics in gl2ps_renderer::draw + if (dos_shell) + cmd = sprintf ('%s & :: > "%s-inc.%s"', cmd, name, suffix); + else + cmd = sprintf ('%s # > "%s-inc.%s"', cmd, name, suffix); + endif + else + cmd = sprintf ('%s > "%s-inc.%s"', cat_cmd, name, suffix); + endif + pipeline = {cmd}; + pipeline{2} = sprintf ('%s > "%s.tex"', cat_cmd, name); case "tikz" ## format GL2PS_PGF gl2ps_device = {"pgf"};