changeset 11027:a2bdd9180a3c

__print_parse_opts__.m: Properly crop eps image and fix tests.
author Ben Abbott <bpabbott@mac.com>
date Mon, 27 Sep 2010 19:38:16 -0400
parents 811d8f113423
children 7d0d28aff7a9
files scripts/ChangeLog scripts/plot/__print_parse_opts__.m
diffstat 2 files changed, 26 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2010-09-27  Ben Abbott <bpabbott@mac.com>
+
+	* plot/__print_parse_opts__.m: Properly crop eps image and fix tests.
+
 2010-09-26  Rik <octave@nomad.inbox5.com>
 
 	* testfun/runtests.m (has_tests): Recode to remove requirement for PCRE.
--- a/scripts/plot/__print_parse_opts__.m
+++ b/scripts/plot/__print_parse_opts__.m
@@ -90,10 +90,10 @@
         arg_st.orientation = "landscape";
       elseif (strcmp (arg, "-loose"))
         arg_st.loose = true;
+        arg_st.tight_flag = false;
       elseif (strcmp (arg, "-tight"))
+        arg_st.loose = false;
         arg_st.tight_flag = true;
-      elseif (strcmp (arg, "-loose"))
-        arg_st.tight_flag = false;
       elseif (strcmp (arg, "-textspecial"))
         arg_st.special_flag = "textspecial";
       elseif (any (strcmp (arg, {"-interchange", "-metafile", "-pict", "-tiff"})))
@@ -183,14 +183,6 @@
     endif
   endif
 
-  if (arg_st.tight_flag)
-    if (any (strcmpi (arg_st.devopt, {"ps", "ps2", "psc", "psc2", "pdf"})))
-      arg_st.tight_flag = false;
-      warning ("print.m: '-tight' is not supported for device '%s'",
-               arg_st.devopt)
-    endif
-  endif
-
   if (strcmp (arg_st.devopt, "tex"))
     arg_st.devopt = "epslatex";
   elseif (strcmp (arg_st.devopt, "ill"))
@@ -227,8 +219,14 @@
               "pdf", "png", "tex", ...
               "eps", "ps", "ps", "pdf"};
 
-  if (isfigure (arg_st.figure)
-      && strcmp (get (arg_st.figure, "__backend__"), "gnuplot")
+  if (isfigure (arg_st.figure))
+    __backend__ = get (arg_st.figure, "__backend__");
+  else
+    ## Allow tests when no figures are present.
+    __backend__ = get (0, "defaultfigure__backend__");
+  endif
+
+  if (strcmp (__backend__, "gnuplot")
       && __gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix"))
     suffixes(strncmp (dev_list, "epslatex", 8)) = {"eps"};
   endif
@@ -294,8 +292,12 @@
     arg_st.ghostscript.device = arg_st.devopt;
     arg_st.ghostscript.output = arg_st.name;
     arg_st.ghostscript.antialiasing = true;
-    ## pstoedit throws errors if the EPS file isn't cropped
-    arg_st.ghostscript.epscrop = true;
+    if (arg_st.formatted_for_printing)
+      arg_st.ghostscript.epscrop = ! arg_st.loose;
+    else
+      ## pstoedit throws errors if the EPS file isn't cropped
+      arg_st.ghostscript.epscrop = true;
+    endif
   elseif (all (! strcmp (arg_st.devopt, dev_list)))
     ## Assume we are formating output for a printer
     arg_st.formatted_for_printing = true;
@@ -315,7 +317,11 @@
       paperposition = [0.25, 2.50, 8.00, 6.00] * 72;
     endif
     arg_st.canvas_size = paperposition(3:4);
-    arg_st.ghostscript.pageoffset = paperposition(1:2);
+    if (strcmp (__backend__, "gnuplot") && ! arg_st.ghostscript.epscrop)
+      arg_st.ghostscript.pageoffset = paperposition(1:2) - 50;
+    else
+      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;
@@ -382,7 +388,7 @@
 %! assert (opts.devopt, "jpeg")
 %! assert (opts.name, "foobar.jpg")
 %! assert (opts.ghostscript.device, "jpeg")
-%! assert (opts.ghostscript.epscrop, true);
+%! assert (opts.ghostscript.epscrop, false);
 %! assert (opts.ghostscript.papersize, "");
 %! assert (opts.ghostscript.pageoffset, [0, 0]);
 %! assert (opts.send_to_printer, false);