]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/framework-ps.scm
Add '-dcrop' option to ps and svg backends
[lilypond.git] / scm / framework-ps.scm
index 9498b2ac9dd24bff298a593707e53a9862b57609..a9c5de2823dfc32271cf484f0f4d2dcc40f073b6 100644 (file)
   (define (metadata-encode val)
     ;; First, call ly:encode-string-for-pdf to encode the string (latin1 or
     ;; utf-16be), then escape all parentheses and backslashes
-    ;; FIXME guile-2.0: use (string->utf16 str 'big) instead
-
+    ;;
+    ;; NOTE: with guile-2.0+ ly:encode-string-for-pdf is not really needed and
+    ;; could be replaced with the following code:
+    ;;
+    ;;    (let* ((utf16be-bom #vu8(#xFE #xFF)))
+    ;;      (string-append (bytevector->string utf16be-bom "ISO-8859-1")
+    ;;                     (bytevector->string (string->utf16 val 'big) "ISO-8859-1")))
+    ;;
     (ps-quote (ly:encode-string-for-pdf val)))
   (define (metadata-lookup-output overridevar fallbackvar field)
     (let* ((overrideval (ly:modules-lookup (list header) overridevar))
@@ -860,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)