]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #268.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 4 Aug 2008 00:21:51 +0000 (21:21 -0300)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 4 Aug 2008 00:21:51 +0000 (21:21 -0300)
Undirected rounding caused slices of up to half a point (1/144 inch)
to go lost at image edges when creating EPS images.

scm/framework-ps.scm
scm/stencil.scm

index 44427dbd09e272f45f365199cba17bca31c5f724..56507ce0e3ae15351d810373c5a1b1d1c4b01431 100644 (file)
 (define-public (dump-stencil-as-EPS-with-bbox paper dump-me filename
                                              load-fonts
                                              bbox)
-  (define (to-bp-box mmbox)
+  "Create an EPS file from stencil DUMP-ME to FILENAME. BBOX has format
+   (left-x, lower-y, right x, up-y).  If LOAD-FONTS set, include fonts inline." 
+
+  (define (to-rounded-bp-box box)
+    "Convert box to 1/72 inch with rounding to enlarge the box."
     (let* ((scale (ly:output-def-lookup paper 'output-scale))
-          (box (map
-                (lambda (x)
-                  (if (or (nan? x) (inf? x))
-                      0
-                      (inexact->exact
-                       (round (/ (* x scale) (ly:bp 1)))))) mmbox)))
-      
-    (list (car box)
-         (cadr box)
-         (max (1+ (car box)) (caddr box))
-         (max (1+ (cadr box)) (cadddr box))
-         )))
+          (strip-non-number (lambda (x)
+                              (if (or (nan? x) (inf? x)) 0.0 x)))
+          (directed-round (lambda (x rounder)
+                            (inexact->exact
+                             (rounder (/ (* x scale) (ly:bp 1)))))))
+      (list (directed-round (car box) floor)
+           (directed-round (cadr box) floor)
+           (max (1+ (car box)) (directed-round (caddr box) ceiling)
+           (max (1+ (cadr box)) (directed-round (cadddr box) ceiling)
+         )))))
 
   (let* ((outputter (ly:make-paper-outputter
                     ;; FIXME: better wrap open/open-file,
                     'ps))
 
         (port (ly:outputter-port outputter))
-        (rounded-bbox (to-bp-box bbox))
+        (rounded-bbox (to-rounded-bp-box bbox))
         (port (ly:outputter-port outputter))
         (header (eps-header paper rounded-bbox load-fonts)))
 
           ((xext (car ext-system-pair))
            (paper-system (cdr ext-system-pair))
            (yext (paper-system-extent paper-system Y))
-           (bbox (list (car  xext) (car yext)
+           (bbox (list (car xext) (car yext)
                        (cdr xext) (cdr yext)))
            (filename (if (< 0 count)
                          (format "~a-~a" basename count)
index fb46ef7251cf7eef4733eeff09711ced4da1b44a..6a4b88d7b2c24a3f0d22e351cb277f2c68d4f2ec 100644 (file)
@@ -94,8 +94,8 @@ encloses the contents.
 "
   (let* ((xext (ly:grob-extent grob grob 0))
         (yext (ly:grob-extent grob grob 1))
-        (thick 0.1))
-    
+        (thick 0.01))
+
     (ly:stencil-add
      (make-filled-box-stencil xext (cons (- (car yext) thick) (car yext)))
      (make-filled-box-stencil xext (cons (cdr yext) (+ (cdr yext) thick)))