CVSROOT:        /cvsroot/lilypond
Module name:    lilypond
Branch:         
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/06/19 14:52:33

Modified files:
        .              : ChangeLog 
        make           : lilypond-vars.make 
        scm            : backend-library.scm lily.scm ps-to-png.scm 

Log message:
        * scm/ps-to-png.scm (make-ps-images): cleanup multipage vs. single
        page switch.
        
        * make/lilypond-vars.make (LILYPOND_BOOK_FLAGS): set
        anti-alias-factor for lilypond-book runs.
        
        * scm/ps-to-png.scm (scale-down-image): new function.
        (my-system): new function.
        (make-ps-images): blow up GS resolution by anti-alias-factor,
        scale down image by anti-alias-factor.  This improves appearance
        of
        (make-ps-images): remove showpage. Fixes spurious empty png at end.
        
        * scm/lily.scm (lambda): default resolution 116 (8 pixels per
        space).

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3800&tr2=1.3801&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/make/lilypond-vars.make.diff?tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/backend-library.scm.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/lily.scm.diff?tr1=1.365&tr2=1.366&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/ps-to-png.scm.diff?tr1=1.10&tr2=1.11&r1=text&r2=text

Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3800 lilypond/ChangeLog:1.3801
--- lilypond/ChangeLog:1.3800   Sun Jun 19 13:50:23 2005
+++ lilypond/ChangeLog  Sun Jun 19 14:52:31 2005
@@ -1,5 +1,18 @@
 2005-06-19  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
+       * scm/ps-to-png.scm (make-ps-images): cleanup multipage vs. single
+       page switch.
+
+       * make/lilypond-vars.make (LILYPOND_BOOK_FLAGS): set
+       anti-alias-factor for lilypond-book runs.
+
+       * scm/ps-to-png.scm (scale-down-image): new function.
+       (my-system): new function.
+       (make-ps-images): blow up GS resolution by anti-alias-factor,
+       scale down image by anti-alias-factor.  This improves appearance
+       of
+       (make-ps-images): remove showpage. Fixes spurious empty png at end.
+
        * scm/framework-ps.scm (write-preamble): downcase filename before
        string-matching. Should fix .TTF files (as opposed to ttf files)  
 
Index: lilypond/make/lilypond-vars.make
diff -u lilypond/make/lilypond-vars.make:1.63 
lilypond/make/lilypond-vars.make:1.64
--- lilypond/make/lilypond-vars.make:1.63       Thu Jun  9 14:09:33 2005
+++ lilypond/make/lilypond-vars.make    Sun Jun 19 14:52:33 2005
@@ -18,7 +18,7 @@
 LILYPOND = $(builddir)/lily/$(outconfbase)/lilypond
 LILYPOND_BOOK = $(script-dir)/lilypond-book.py
 LILYPOND_BOOK_INCLUDES = -I $(pwd) -I $(outdir) -I$(input-dir) -I 
$(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/ -I 
$(builddir)/mf/$(outconfbase)/  -I $(builddir)/mf/out/
-LILYPOND_BOOK_FLAGS = --process="$(LILYPOND) --backend=eps --formats=ps,png 
--header=texidoc -I $(srcdir)/input/test -dinternal-type-checking"
+LILYPOND_BOOK_FLAGS = --process="$(LILYPOND) --backend=eps --formats=ps,png 
--header=texidoc -I $(srcdir)/input/test -dinternal-type-checking 
-danti-alias-factor=2 "
 
 
 #texi-html for www only:
Index: lilypond/scm/backend-library.scm
diff -u lilypond/scm/backend-library.scm:1.39 
lilypond/scm/backend-library.scm:1.40
--- lilypond/scm/backend-library.scm:1.39       Tue Jun 14 19:51:15 2005
+++ lilypond/scm/backend-library.scm    Sun Jun 19 14:52:33 2005
@@ -85,6 +85,7 @@
     ))
 
 (use-modules (scm ps-to-png))
+
 (define-public (postscript->png resolution paper-size-name name)
     ;; Do not try to guess the name of the png file,
     ;; GS produces PNG files like BASE-page%d.png.
@@ -94,7 +95,8 @@
        (verbose (ly:get-option 'verbose))
        (rename-page-1 #f))
     (ly:message (_ "Converting to ~a...") "PNG")
-    (make-ps-images name resolution paper-size rename-page-1 verbose)
+    (make-ps-images name resolution paper-size rename-page-1 verbose
+                   (ly:get-option 'anti-alias-factor))
     (ly:progress "\n")))
 
 (define-public (postprocess-output paper-book module filename formats)
Index: lilypond/scm/lily.scm
diff -u lilypond/scm/lily.scm:1.365 lilypond/scm/lily.scm:1.366
--- lilypond/scm/lily.scm:1.365 Sun Jun 19 11:21:07 2005
+++ lilypond/scm/lily.scm       Sun Jun 19 14:52:33 2005
@@ -22,7 +22,8 @@
            ;; at 101.178, a staff space is exactly 7 pixels.
            ;; 115.63 = 8 pixels
            ;; 86  = 6 pixels
-           (resolution 116 "resolution for generating bitmaps")
+           (resolution 90 "resolution for generating bitmaps")
+           (anti-alias-factor 1 "blow up resolution and scale to prevent 
jaggies in PNG")
            (preview-include-book-title #t "include book-titles in preview 
images.")
            (gs-font-load #f
                          "load fonts via Ghostscript.")
Index: lilypond/scm/ps-to-png.scm
diff -u lilypond/scm/ps-to-png.scm:1.10 lilypond/scm/ps-to-png.scm:1.11
--- lilypond/scm/ps-to-png.scm:1.10     Thu Jun 16 19:11:54 2005
+++ lilypond/scm/ps-to-png.scm  Sun Jun 19 14:52:33 2005
@@ -78,12 +78,48 @@
         (map (lambda (x) (string->number (car x))) (vector->list m)))
        #f)))
 
+
+;; copy of ly:system. ly:* not available via lilypond-ps2png.scm
+(define (my-system be-verbose exit-on-error cmd)
+  (define status 0)
+  (if be-verbose
+      (begin
+       (format (current-error-port) (_ "Invoking `~a'...") cmd)
+       (newline (current-error-port))))
+
+  
+  (set! status (system cmd))
+  
+  (if (not (= status 0))
+      (begin
+       (format (current-error-port)
+               (format #f (_ "~a exited with status: ~S") "GS" status))
+       (if exit-on-error
+           (exit 1))))
+
+  status)
+
+(define (scale-down-image be-verbose factor file)
+  (let* ((status 0)
+        (percentage (* 100 (/ 1.0 factor)))
+        (old (string-append file ".old")))
+  
+  (rename-file file old)
+  (my-system be-verbose
+            #t
+            (format #f "convert -scale '~a%' ~a ~a" percentage old file))
+  (delete-file old)
+  ))
+
 (define-public (make-ps-images ps-name . rest)
   (let-optional
    rest ((resolution 90)
         (paper-size "a4")
         (rename-page-1? #f)
-        (verbose? #f))
+        (verbose? #f)
+        (aa-factor 1) 
+        )
+   
    (let* ((base (basename (re-sub "[.]e?ps" "" ps-name)))
          (header (gulp-port (open-file ps-name "r") 10240))
          (png1 (string-append base ".png"))
@@ -94,29 +130,16 @@
          (output-file (if multi-page? pngn png1))
 
          ;;png16m is because Lily produces color nowadays.
-         (cmd (if multi-page?
-                  (format #f "~a\
+         (gs-variable-options
+           (if multi-page?
+               (format #f "-sPAPERSIZE=~a" paper-size)
+               "-dEPSCrop"))
+         (cmd (format #f "~a\
  ~a\
- -dGraphicsAlphaBits=4\
- -dNOPAUSE\
- -dTextAlphaBits=4\
- -sDEVICE=png16m\
- -sOutputFile=~S\
- -sPAPERSIZE=~a\
- -r~S\
- ~S\
- -c showpage\
- -c quit"
-                          (search-gs)
-                          (if verbose? "" "-q")
-                          output-file paper-size resolution ps-name)
-                  (format #f "~a\
  ~a\
- -s\
  -dGraphicsAlphaBits=4\
- -dEPSCrop\
- -dNOPAUSE\
  -dTextAlphaBits=4\
+ -dNOPAUSE\
  -sDEVICE=png16m\
  -sOutputFile=~S\
  -r~S\
@@ -124,28 +147,41 @@
  -c quit"
                           (search-gs)
                           (if verbose? "" "-q")
-                          output-file resolution ps-name)))
-         (foo (for-each delete-file (append (dir-re "." png1)
-                                            (dir-re "." pngn-re))))
-         (bar (if verbose?
-                  (begin
-                    (format (current-error-port) (_ "Invoking `~a'...") cmd)
-                    (newline (current-error-port)))))
-         (baz 
-          ;; The wrapper on windows cannot handle `=' signs,
-          ;; gs has a workaround with #.
-          (if (eq? PLATFORM 'windows)
-              (begin
-                (set! cmd (re-sub "=" "#" cmd))
-                (set! cmd (re-sub "-dSAFER " "" cmd)))))
-         (status (system cmd)))
-     (if (not (= status 0))
+                          gs-variable-options
+                          output-file 
+                          (* aa-factor resolution) ps-name))
+         (status 0)
+         (files '()))
+     
+     (for-each delete-file (append (dir-re "." png1)
+                                  (dir-re "." pngn-re)))
+     
+     ;; The wrapper on windows cannot handle `=' signs,
+     ;; gs has a workaround with #.
+     (if (eq? PLATFORM 'windows)
         (begin
-          (map delete-file
-               (append (dir-re "." png1) (dir-re "." pngn-re)))
-          (format (current-error-port)
-                  (format #f (_ "~a exited with status: ~S") "GS" status))
+          (set! cmd (re-sub "=" "#" cmd))
+          (set! cmd (re-sub "-dSAFER " "" cmd))))
+
+     (set! status (my-system verbose? #f cmd))
+
+     (set! files
+          (append (dir-re "." png1) (dir-re "." pngn-re)))
+
+     (if (not (= 0 status))
+        (begin
+          (map delete-file files)
           (exit 1)))
+     
      (if (and rename-page-1? multi-page?)
         (rename-file (re-sub "%d" "1" pngn) png1))
-     (append (dir-re "." png1) (dir-re "." pngn-re)))))
+     
+     (set! files
+          (append (dir-re "." png1) (dir-re "." pngn-re)))
+
+     
+     (if (not (= 1 aa-factor))
+        (for-each  (lambda (f) (scale-down-image verbose? aa-factor f))
+                   files))
+                           
+     files)))


_______________________________________________
Lilypond-cvs mailing list
Lilypond-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to