]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add '-dcrop' option to ps and svg backends master
authorÉtienne Beaulé <beauleetienne0@gmail.com>
Fri, 4 Aug 2017 05:21:44 +0000 (02:21 -0300)
committerJames Lowe <pkx166h@gmail.com>
Mon, 14 Aug 2017 21:10:18 +0000 (22:10 +0100)
This change allows the output of scores in the format provided by the
'-dpreview' option but including all systems, not just the first.

This would allow for easier SVG use in HTML, without the need for
cropping snippets. Further, SVG is an HTML standard, and its vector
nature makes its use unparalleled for the web. This change would allow
SVG use in 'lilypond-book' in the future.

Documentation/changes.tely
Documentation/usage/running.itely
lily/paper-book.cc
scm/framework-ps.scm
scm/framework-svg.scm
scm/lily.scm

index 482bbbdd659d598db0ef027dc0336ccce51bf063..3428a084944f3585bfbeef417e229c8ec3bdaa19 100644 (file)
@@ -61,6 +61,10 @@ which scares away people.
 
 @end ignore
 
+@item
+An argument, @code{-dcrop}, has been added, formatting @code{SVG} and
+@code{PDF} output without margins or page-breaks.
+
 @item
 It is now possible to move systems with reference to their current
 position using the @code{extra-offset} subproperty of
index 4eeabc80dc587e6c033cebe160b6d8e66ffe3bb5..1fe748d93a2f3099808810f395b5d46b615184c3 100644 (file)
@@ -505,6 +505,10 @@ in case an SVG viewer is unable to handle them.  When using
 block.  See @ruser{Extracting fragments of music}.  No fragments are
 extracted though if used with the @option{-dno-print-pages} option.
 
+@item @code{crop}
+@tab @code{#f}
+@tab Match the size of the normal output to the typeset image.
+
 @item @code{datadir}
 @tab
 @tab Prefix for data files (read-only).
@@ -672,7 +676,7 @@ To suppress the usual output, use the @option{-dprint-pages} or
 @item @code{print-pages}
 @tab @code{#t}
 @tab Generate full pages, the default.  @option{-dno-print-pages} is
-useful in combination with @option{-dpreview}.
+useful in combination with @option{-dpreview} or @option{-dcrop}.
 
 @item @code{profile-property-accesses}
 @tab @code{#f}
index c17ed576f1895c0a91febb29164ea9987dda1b0f..f1787e99550f2bb09eb001188b69384c69e5f004 100644 (file)
@@ -219,6 +219,25 @@ Paper_book::output (SCM output_channel)
         warning (_f ("program option -dpreview not supported by backend `%s'",
                      get_output_backend_name ()));
     }
+
+  if (get_program_option ("crop"))
+    {
+      SCM framework
+        = ly_module_lookup (mod, ly_symbol2scm ("output-crop-framework"));
+
+      if (scm_is_true (framework))
+        {
+          SCM func = scm_variable_ref (framework);
+          scm_call_4 (func,
+                      output_channel,
+                      self_scm (),
+                      scopes,
+                      dump_fields ());
+        }
+      else
+        warning (_f ("program option -dcrop not supported by backend `%s'",
+                     get_output_backend_name ()));
+    }
 }
 
 void
index 2cd9b5edc619bd6e067081cbbd521a30a65ef386..a9c5de2823dfc32271cf484f0f4d2dcc40f073b6 100644 (file)
@@ -866,6 +866,22 @@ mark {ly~a_stream} /CLOSE pdfmark
                         #t
                         )))
 
+(define-public (output-crop-framework basename book scopes fields)
+  (let* ((paper (ly:paper-book-paper book))
+         (systems (relevant-book-systems book)))
+    (dump-stencil-as-EPS paper
+                         (stack-stencils Y DOWN 0.0
+                                         (map paper-system-stencil
+                                              (reverse (reverse systems))))
+                         (format #f "~a.cropped" basename)
+                         #t)
+    (postprocess-output book framework-ps-module
+                        (cons "png" (ly:output-formats))
+                        (format #f "~a.cropped" basename)
+                        (format #f "~a.cropped.eps" basename)
+                        #t
+                        )))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define (output-width-height defs)
index a4cf2e996055305dbeb36730dc78247b0a1016a4..85cbe1c2c11bb52a4473a6757de4b150819a525b 100644 (file)
@@ -197,3 +197,11 @@ src: url('~a');
                                   (map paper-system-stencil
                                        (reverse to-dump-systems)))
                   (format #f "~a.preview.svg" basename))))
+
+(define (output-crop-framework basename book scopes fields)
+  (let* ((paper (ly:paper-book-paper book))
+         (systems (relevant-book-systems book))
+         (page-stencils (stack-stencils Y DOWN 0.0
+                                        (map paper-system-stencil
+                                             (reverse (reverse systems))))))
+    (dump-preview paper page-stencils (format #f "~a.cropped.svg" basename))))
index 4b3c9c7e1c4cad55c64a53fe611d1effcf692612..5e727f1a5892cbb4de4d067f53e719ab3e9fcaf8 100644 (file)
@@ -228,6 +228,9 @@ EPS backend.")
     (clip-systems
      #f
      "Generate cut-out snippets of a score.")
+    (crop
+     #f
+     "Match the size of the normal output to the typeset image.")
     (datadir
      #f
      "LilyPond prefix for data files (read-only).")