]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/stencil.scm
(eps-file->stencil): fix EPS PS embedding code
[lilypond.git] / scm / stencil.scm
index 58b19346186c5654af29992d43c69d23b36a4254..cdac70fcc861d79bf2a81e6cc75fa6f9317e09c7 100644 (file)
@@ -19,7 +19,9 @@
    ((null? stils) empty-stencil)
    ((null? (cdr stils)) (car stils))
    (else (ly:stencil-combine-at-edge
-         (car stils) axis dir (stack-stencils-padding-list axis dir (cdr padding) (cdr stils))
+         (car stils)
+         axis dir
+         (stack-stencils-padding-list axis dir (cdr padding) (cdr stils))
          (car padding)))))
 
 (define-public (centered-stencil stencil)
@@ -178,47 +180,53 @@ encloses the contents.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define-public (annotate-y-interval layout name extent is-length)
-  ;; do something sensible for 0,0 intervals. 
-  (set! extent (interval-widen extent 0.001))
   (let*
       ((text-props (cons
                    '((font-size . -3)
                      (font-family . typewriter))
                    (layout-extract-page-properties layout)))
-       (annotation (interpret-markup
-                   layout text-props
-                   (make-column-markup
-                    (list
-                     (make-whiteout-markup (make-simple-markup name))
-                     (make-whiteout-markup
-                      (make-simple-markup
-                       (begin
-                         (display extent)
-                       (cond
-                        ((interval-empty? extent) "empty")
-                        ((not (interval-sane? extent)) "insane")
-                        (is-length (format "~$" (interval-length extent)))
-                        (else
-                         (format "(~$,~$)" (car extent)
-                                   (cdr extent)))))))))))
-       (arrows
-       (ly:stencil-translate-axis 
-        (dimension-arrows (cons 0 (interval-length extent)))
-        (interval-start extent) Y)))
+       (annotation #f)
+       )
 
-    (set! annotation
-         (ly:stencil-aligned-to annotation Y CENTER))
-    
-    (set! annotation (ly:stencil-translate annotation
-                         (cons 0 (interval-center extent))))
+    ;; do something sensible for 0,0 intervals. 
+    (set! extent (interval-widen extent 0.001))
+    (if (not (interval-sane? extent))
+       (set! annotation (interpret-markup layout text-props
+                                          (make-simple-markup (format "~a: NaN/inf" name))))
+       (let*
+           ((text-stencil (interpret-markup
+                           layout text-props
+                           (make-column-markup
+                            (list
+                             (make-whiteout-markup (make-simple-markup name))
+                             (make-whiteout-markup
+                              (make-simple-markup
+                               (cond
+                                ((interval-empty? extent) "empty")
+                                (is-length (format "~$" (interval-length extent)))
+                                (else
+                                 (format "(~$,~$)" (car extent)
+                                         (cdr extent))))))))))
+            (arrows
+             (ly:stencil-translate-axis 
+              (dimension-arrows (cons 0 (interval-length extent)))
+              (interval-start extent) Y)))
+         
+         (set! annotation
+               (ly:stencil-aligned-to text-stencil Y CENTER))
+         
+         (set! annotation (ly:stencil-translate
+                           annotation
+                           (cons 0 (interval-center extent))))
+         
 
-    (set! annotation
-         (ly:stencil-combine-at-edge arrows X RIGHT annotation 0.5 0))
+         (set! annotation
+               (ly:stencil-combine-at-edge arrows X RIGHT annotation 0.5 0))
 
-    (set! annotation
-         (ly:make-stencil (ly:stencil-expr annotation)
-                          (ly:stencil-extent annotation X)
-                          (cons 10000 -10000)))
+         (set! annotation
+               (ly:make-stencil (ly:stencil-expr annotation)
+                                (ly:stencil-extent annotation X)
+                                (cons 10000 -10000)))))
     annotation))
 
 
@@ -240,7 +248,10 @@ encloses the contents.
          'embedded-ps
          (string-append
           (format
-          "BeginEPSF
+          "
+gsave
+currentpoint translate
+BeginEPSF
 ~a ~a scale
 %%BeginDocument: ~a
 "         factor factor
@@ -248,7 +259,9 @@ encloses the contents.
           )
           contents
           "%%EndDocument
-EndEPSF"))
+EndEPSF
+grestore
+"))
        
         (cons (list-ref scaled-bbox 0) (list-ref scaled-bbox 2))
         (cons (list-ref scaled-bbox 1) (list-ref scaled-bbox 3)))