changeset 14206:df695e37d404

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.
author Ben Abbott <bpabbott@mac.com>
date Tue, 17 Jan 2012 07:23:36 -0500
parents 969532305835
children 57e3490094e1
files scripts/plot/__gnuplot_drawnow__.m scripts/plot/print.m scripts/plot/private/__print_parse_opts__.m
diffstat 3 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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"
--- 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
--- 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];