Mercurial > octave
changeset 27343:2c9795736894
print.m: Allow "-svgconvert" to be used for EPS output (bug #52764)
* print.m: Rework documentation about the -svgconvert option, PS, EPS and PDF
formats. Totally remove transparency from grid lines before printing to
PostScript outputs.
* __opengl_print__.m: Don't restrict teh -svgconvert option to non-PostScript
outputs.
* __print_parse_opts__.m: Provide a Ghostscript device name for EPS when using
-svgconvert.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Wed, 12 Jun 2019 21:58:16 +0200 |
parents | 254d6e33a1d0 |
children | 8ff5628d8b55 |
files | scripts/plot/util/print.m scripts/plot/util/private/__opengl_print__.m scripts/plot/util/private/__print_parse_opts__.m |
diffstat | 3 files changed, 78 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/print.m Fri Aug 16 13:13:33 2019 -0700 +++ b/scripts/plot/util/print.m Wed Jun 12 21:58:16 2019 +0200 @@ -114,20 +114,29 @@ ## Specifies whether the opengl (pixel-based) or painters (vector-based) ## renderer is used. This is equivalent to changing the figure's ## @qcode{"Renderer"} property. When the figure @code{RendererMode} property -## is @qcode{"auto"} Octave will use the @qcode{"opengl"} renderer for raster -## formats (e.g., JPEG) and @qcode{"painters"} for vector formats (e.g., PDF)@. +## is @qcode{"auto"} (the default) Octave will use the @qcode{"opengl"} renderer +## for raster formats (e.g., JPEG) and @qcode{"painters"} for vector formats +## (e.g., PDF). ## Those options are only supported for the "qt" graphics tookit. ## ## @item -svgconvert -## For OpenGL-based graphic toolkits, this enables a different backend -## toolchain with enhanced characteristics. The toolchain adds support for -## printing arbitrary characters and fonts in PDF outputs; it avoids some -## anti-aliasing artifacts in the rendering of patch and surface objects -## (particularly for 2-D scenes); and it supports transparency of line, patch, -## and surface objects. +## When using the -painters renderer, this enables a different backend +## toolchain with enhanced characteristics: ## -## This option only affects PDF outputs, unless it is combined with -## @option{-painters} option, in which case raster outputs are also affected. +## @table @asis +## @item Font handling: +## The actual font is embedded in the output file which allows for printing +## arbitrary characters and fonts in all vector formats. +## @item Output Simplification: +## By default, the @code{-painters} renders patch and surface objects +## using assemblies of triangles. This may lead to anti-aliasing +## artifacts when viewing the file. The @code{-svgconvert} option reconstructs +## polygons in order to avoid those artifacts (particularly for 2-D figures). +## @item Transparency: +## Allows for printing transparent graphics objects in PDF format. +## For PostScript formats the presence of any transparent object will cause the +## output to be rasterized. +## @end table ## ## Caution: @option{-svgconvert} may lead to inaccurate rendering of image ## objects. @@ -227,34 +236,39 @@ ## Vector Formats ## ## @table @code +## @item svg +## Scalable Vector Graphics. +## ## @item pdf ## @itemx pdfcrop -## Portable Document Format. The @code{pdfcrop} device removes the default -## surrounding page. +## Portable Document Format. The @code{pdf} device formats the figure for +## printing on paper. The size of the surrounding page and the position of the +## figure inside the page are defined by the +## @ref{XREFfigurepaperorientation,, paper* figure properties}. +## +## Use @code{pdfcrop} if you don't want the surrounding page. ## -## The OpenGL-based graphics toolkits have limited support for text. +## By default, PDF inherits the same limitations as PostScript. +## For an enhanced output with complete text support and basic transparency, +## use the @option{-svgconvert} option. +## +## @item eps(2) +## @itemx epsc(2) +## Encapsulated PostScript (level 1 and 2, mono and color). +## +## The OpenGL-based graphics toolkits always generate PostScript level 3.0. +## They have limited support for text unless using the @code{-svgconvert} +## option. ## Limitations include using only ASCII characters (e.g., no Greek letters) ## and support for just three base PostScript fonts: Helvetica (the default), ## Times, or Courier. Any other font will be replaced by Helvetica. ## -## For an enhanced output with complete text support and basic transparency, -## use the @option{-svgconvert} option. -## -## @item ps -## @itemx ps2 -## @itemx psc -## @itemx psc2 -## PostScript (level 1 and 2, mono and color). The OpenGL-based graphics -## toolkits always generate PostScript level 3.0 and have limited support for -## text. -## -## @item eps -## @itemx eps2 -## @itemx epsc -## @itemx epsc2 -## Encapsulated PostScript (level 1 and 2, mono and color). The -## OpenGL-based toolkits always generate PostScript level 3.0 and have -## limited support for text. +## @item ps(2) +## @itemx psc(2) +## Same as @code{eps} except that the figure is formated for printing on +## paper. The size of the surrounding page and position of the figure inside +## the page are defined by the +## @ref{XREFfigurepaperorientation,, paper* figure properties}. ## ## @item pslatex ## @itemx epslatex @@ -293,9 +307,6 @@ ## the graph portion of the plot. The @samp{standalone} variants behave as ## described for @samp{epslatexstandalone} above. ## -## @item svg -## Scalable Vector Graphics -## ## @item canvas* ## Javascript-based drawing on an HTML5 canvas viewable in a web browser. ## @@ -515,6 +526,16 @@ set (hax(n), "gridcolor", [0.85 0.85 0.85]); nfig += 2; endif + if (strcmp (get (hax(n), "gridalphamode"), "auto")) + props(end+1).h = hax(n); + props(end).name = "gridalphamode"; + props(end).value = {"auto"}; + props(end+1).h = hax(n); + props(end).name = "gridalpha"; + props(end).value = {get(hax(n), "gridalpha")}; + set (hax(n), "gridalpha", 1); + nfig += 2; + endif if (strcmp (get (hax(n), "minorgridcolormode"), "auto")) props(end+1).h = hax(n); @@ -526,6 +547,16 @@ set (hax(n), "minorgridcolor", [0.75 0.75 0.75]); nfig += 2; endif + if (strcmp (get (hax(n), "minorgridalphamode"), "auto")) + props(end+1).h = hax(n); + props(end).name = "minorgridalphamode"; + props(end).value = {"auto"}; + props(end+1).h = hax(n); + props(end).name = "minorgridalpha"; + props(end).value = {get(hax(n), "minorgridalpha")}; + set (hax(n), "minorgridalpha", 1); + nfig += 2; + endif endfor endif
--- a/scripts/plot/util/private/__opengl_print__.m Fri Aug 16 13:13:33 2019 -0700 +++ b/scripts/plot/util/private/__opengl_print__.m Wed Jun 12 21:58:16 2019 +0200 @@ -126,13 +126,11 @@ gl2ps_device = {"svg"}; pipeline = {sprintf("%s > %s", cmd, opts.name)}; case opts.ghostscript.device - ## Except for postscript, use svg format and first convert to pdf - ## before going through ghostscript for final adjustments. svgcmd = ""; if (opts.svgconvert) svgcmd = opts.svgconvert_cmd (opts, opts.ghostscript.device); endif - dosvg = ! (strcmp (opts.devopt, "ps2write") || isempty (svgcmd)); + dosvg = ! isempty (svgcmd); if (! dosvg) opts.ghostscript.source = "-"; else
--- a/scripts/plot/util/private/__print_parse_opts__.m Fri Aug 16 13:13:33 2019 -0700 +++ b/scripts/plot/util/private/__print_parse_opts__.m Wed Jun 12 21:58:16 2019 +0200 @@ -377,7 +377,7 @@ arg_st.formatted_for_printing = true; endif - aliases = gs_aliases (); + aliases = gs_aliases (arg_st.svgconvert); if (any (strcmp (arg_st.devopt, fieldnames (aliases))) && ! strcmp (arg_st.renderer, "opengl")) arg_st.devopt = aliases.(arg_st.devopt); @@ -767,12 +767,9 @@ endfunction -function aliases = gs_aliases () - ## Aliases for other devices: "bmp", "png", "tiff", "tiffn", "pdf", - ## "ps", "ps2", "psc", "psc2" - ## - ## eps, epsc, eps2, epsc2 are not included here because those are - ## are generated by the graphics toolkit. +function aliases = gs_aliases (do_eps) + + ## Ghostscript device names aliases.bmp = "bmp32b"; aliases.pdf = "pdfwrite"; aliases.png = "png16m"; @@ -782,4 +779,12 @@ aliases.psc2 = "ps2write"; aliases.tiff = "tiffscaled24"; aliases.tiffn = "tiff24nc"; + + if (do_eps) + aliases.eps = "ps2write"; + aliases.eps2 = "ps2write"; + aliases.epsc = "ps2write"; + aliases.epsc2 = "ps2write"; + endif + endfunction