X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Foutput-ps.scm;h=ee1da5308e3be0a49254d3f108288b8f6ba6cd79;hb=553f6aa21a21d0ba7ae3ee48bce121154590bf8b;hp=b82c185e02caa7638dc0acd9a6628e4dc179cd65;hpb=f9214bac21e9926dc3248416f58190c98c4167a9;p=lilypond.git diff --git a/scm/output-ps.scm b/scm/output-ps.scm index b82c185e02..ee1da5308e 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -2,7 +2,7 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 1998--2006 Jan Nieuwenhuizen +;;;; (c) 1998--2009 Jan Nieuwenhuizen ;;;; Han-Wen Nienhuys ;;;; Note: currently misused as testbed for titles with markup, see @@ -14,32 +14,7 @@ ;;;; * document output-interface (define-module (scm output-ps) - #:re-export (quote) - - ;; JUNK this -- see lily.scm: ly:all-output-backend-commands - #:export (unknown - bezier-sandwich - char - circle - comment - dashed-line - dashed-slur - dot - draw-line - embedded-ps - named-glyph - no-origin - placebox - polygon - repeat-slash - resetcolor - resetrotation - round-filled-box - setcolor - setrotation - text - )) - + #:re-export (quote)) (use-modules (guile) (ice-9 regex) @@ -67,9 +42,6 @@ (define (number-pair->string4 numpair) (ly:format "~4l" numpair)) -(define (numbers->string4 numlist) - (string-join (map str4 numlist) " ")) - ;;; ;;; Lily output interface, PostScript implementation --- cleanup and docme ;;; @@ -119,6 +91,14 @@ (- x2 x1) (- y2 y1) x1 y1 thick)) +(define (ellipse x-radius y-radius thick fill) + (ly:format + "~a ~4f ~4f ~4f draw_ellipse" + (if fill + "true" + "false") + x-radius y-radius thick)) + (define (embedded-ps string) string) @@ -129,8 +109,8 @@ (define (glyph-spec w x y g) (let ((prefix (if (string? g) "/" ""))) - (ly:format "~4f ~4f ~a~a" - (+ w x) y + (ly:format "~4f ~4f ~4f ~a~a" + w x y prefix g))) (ly:format @@ -150,38 +130,39 @@ (define (grob-cause offset grob) - (let* ((cause (ly:grob-property grob 'cause)) - (music-origin (if (ly:stream-event? cause) - (ly:event-property cause 'origin)))) - (if (not (ly:input-location? music-origin)) - "" - (let* ((location (ly:input-file-line-char-column music-origin)) - (raw-file (car location)) - (file (if (is-absolute? raw-file) - raw-file - (string-append (ly-getcwd) "/" raw-file))) - (x-ext (ly:grob-extent grob grob X)) - (y-ext (ly:grob-extent grob grob Y))) - - (if (and (< 0 (interval-length x-ext)) - (< 0 (interval-length y-ext))) - (ly:format "~4f ~4f ~4f ~4f (textedit://~a:~a:~a:~a) mark_URI\n" - (+ (car offset) (car x-ext)) - (+ (cdr offset) (car y-ext)) - (+ (car offset) (cdr x-ext)) - (+ (cdr offset) (cdr y-ext)) - - ;; TODO - ;;full escaping. - - ;; backslash is interpreted by GS. - (ly:string-substitute "\\" "/" - (ly:string-substitute " " "%20" file)) - (cadr location) - (caddr location) - (cadddr location)) - ""))))) - + (if (ly:get-option 'point-and-click) + (let* ((cause (ly:grob-property grob 'cause)) + (music-origin (if (ly:stream-event? cause) + (ly:event-property cause 'origin)))) + (if (ly:input-location? music-origin) + (let* ((location (ly:input-file-line-char-column music-origin)) + (raw-file (car location)) + (file (if (is-absolute? raw-file) + raw-file + (string-append (ly-getcwd) "/" raw-file))) + (x-ext (ly:grob-extent grob grob X)) + (y-ext (ly:grob-extent grob grob Y))) + + (if (and (< 0 (interval-length x-ext)) + (< 0 (interval-length y-ext))) + (ly:format "~4f ~4f ~4f ~4f (textedit://~a:~a:~a:~a) mark_URI\n" + (+ (car offset) (car x-ext)) + (+ (cdr offset) (car y-ext)) + (+ (car offset) (cdr x-ext)) + (+ (cdr offset) (cdr y-ext)) + + ;; TODO + ;;full escaping. + + ;; backslash is interpreted by GS. + (ly:string-substitute "\\" "/" + (ly:string-substitute " " "%20" file)) + (cadr location) + (caddr location) + (cadddr location)) + "")) + "")) + "")) (define (named-glyph font glyph) (ly:format "~a /~a glyphshow " ;;Why is there a space at the end? @@ -191,10 +172,18 @@ (define (no-origin) "") -(define (placebox x y s) +(define (oval x-radius y-radius thick fill) (ly:format -"~4f ~4f moveto -~a\n" x y s)) + "~a ~4f ~4f ~4f draw_oval" + (if fill + "true" + "false") + x-radius y-radius thick)) + +(define (placebox x y s) + (if (not (string-null? s)) + (ly:format "~4f ~4f moveto ~a\n" x y s) + "")) (define (polygon points blot-diameter filled?) (ly:format "~a ~4l ~a ~4f draw_polygon" @@ -228,7 +217,7 @@ (list r g b))) ;; restore color from stack -(define (resetcolor) "grestore \n") +(define (resetcolor) "grestore\n") ;; rotation around given point (define (setrotation ang x y) @@ -267,16 +256,13 @@ "\n unknown\n") (define (url-link url x y) - (ly:format "~a ~a ~a ~a (~a) mark_URI" + (ly:format "~a ~a currentpoint vector_add ~a ~a currentpoint vector_add (~a) mark_URI" (car x) (car y) (cdr x) (cdr y) url)) -(define (utf-8-string pango-font-description string) - (ly:warning (_ "utf-8-string encountered in PS backend"))) - (define (path thickness exps) (define (convert-path-exps exps) (if (pair? exps) @@ -287,6 +273,7 @@ (cond ((memq head '(rmoveto rlineto lineto moveto)) 2) ((memq head '(rcurveto curveto)) 6) + ((eq? head 'closepath) 0) (else 1))) (args (take rest arity)) ) @@ -301,7 +288,7 @@ (ly:format - "1 setlinecap ~a setlinewidth\n~l stroke" + "gsave currentpoint translate 1 setlinecap ~a setlinewidth\n~l stroke grestore" thickness - (convert-path-exps exps) )) + (convert-path-exps exps)))