# HG changeset patch # User Ben Abbott # Date 1326803016 18000 # Node ID df695e37d404885c0f6158c4acb942b05e2537c6 # Parent 969532305835d15d22bf1e9452a11a18c8147241 Make sure "print '-SX,Y' ..." doesn't round down a pixel. Bug # 35307. The eps output from gnuplot and gl2ps each specify whole numbrer bboxs. Modify ghostscript's resolution to ensure output size is correct. Also adjust fontisize to compenstate for resolution change. * __print_parse_opts__.m: Set ghostscript resolution to 72 to ensure all bboxs have whole numbers. Add a scalefontsize variable to enable fontsize to be compensated for change in resolution. * print.m: Modify fontsize property value to compensate for change in ghostscript resolution. * __gnuplot_drawnow__.m: Increase precision for specified canvas size. diff --git a/scripts/plot/__gnuplot_drawnow__.m b/scripts/plot/__gnuplot_drawnow__.m --- a/scripts/plot/__gnuplot_drawnow__.m +++ b/scripts/plot/__gnuplot_drawnow__.m @@ -205,7 +205,7 @@ endif switch (term) case terminals_with_size - size_str = sprintf ("size %g,%g", gnuplot_size); + size_str = sprintf ("size %.12g,%.12g", gnuplot_size); case "tikz" size_str = sprintf ("size %gin,%gin", gnuplot_size); case "dumb" diff --git a/scripts/plot/print.m b/scripts/plot/print.m --- a/scripts/plot/print.m +++ b/scripts/plot/print.m @@ -370,6 +370,10 @@ else fontsize = opts.fontsize; endif + if (! isempty (opts.scalefontsize) && ! opt.scalefontsize != 1) + ## This is done to work around the bbox being whole numbers. + fontsize = fontsize * opts.scalefontsize; + endif set (h(ishandle(h)), "fontsize", fontsize); endif endif diff --git a/scripts/plot/private/__print_parse_opts__.m b/scripts/plot/private/__print_parse_opts__.m --- a/scripts/plot/private/__print_parse_opts__.m +++ b/scripts/plot/private/__print_parse_opts__.m @@ -36,6 +36,7 @@ arg_st.fig2dev_binary = __quote_path__ (__find_binary__ ("fig2dev")); arg_st.fontsize = ""; arg_st.font = ""; + arg_st.scalefontsize = 1; arg_st.force_solid = 0; # 0=default, -1=dashed, +1=solid arg_st.formatted_for_printing = false; arg_st.ghostscript.binary = __quote_path__ (__ghostscript_binary__ ()); @@ -326,8 +327,12 @@ arg_st.ghostscript.pageoffset = paperposition(1:2); endif else - ## Convert canvas size to points from pixles. - arg_st.canvas_size = arg_st.canvas_size * 72 / arg_st.ghostscript.resolution; + ## Convert canvas size to points from pixels. + if (! isempty (arg_st.fontsize)) + ## Work around the eps bbox having whole numbers (both gnuplot & gl2ps). + arg_st.scalefontsize = arg_st.ghostscript.resolution / 72; + endif + arg_st.ghostscript.resolution = 72; arg_st.ghostscript.papersize = arg_st.canvas_size; arg_st.ghostscript.epscrop = true; arg_st.ghostscript.pageoffset = [0, 0];