- (string-append
- "1 setlinecap 1 setlinejoin "
- (ly:number->string thick) " setlinewidth "
- (ly:number->string x1) " "
- (ly:number->string y1) " moveto "
- (ly:number->string x2) " "
- (ly:number->string y2) " lineto stroke"))
-
-(define (ez-ball ch letter-col ball-col)
- (string-append
- " (" ch ") "
- (ly:numbers->string (list letter-col ball-col))
- " /Helvetica-Bold " ;; ugh
- " draw_ez_ball"))
-
-(define (filledbox breapth width depth height) ; FIXME : use draw_round_box
- (string-append (ly:numbers->string (list breapth width depth height))
- " draw_box"))
-
-;; WTF is this in every backend?
-(define (horizontal-line x1 x2 th)
- (draw-line th x1 0 x2 0))
+ (format #f "~a ~a ~a ~a ~a draw_line"
+ (str4 (- x2 x1))
+ (str4 (- y2 y1))
+ (str4 x1)
+ (str4 y1)
+ (str4 thick)))
+
+(define (embedded-ps string)
+ string)
+
+(define (glyph-string postscript-font-name
+ size
+ cid?
+ w-x-y-named-glyphs)
+
+ (define (glyph-spec w x y g)
+ (let ((prefix (if (string? g) "/" "")))
+ (format #f "~f ~f ~a~a"
+ (round2 (+ w x))
+ (round2 y)
+ prefix g)))
+
+ (format #f
+ (if cid?
+"/~a /CIDFont findresource ~a output-scale div scalefont setfont
+~a
+~a print_glyphs"
+
+"/~a ~a output-scale div selectfont
+~a
+~a print_glyphs")
+ postscript-font-name
+ size
+ (string-join (map (lambda (x) (apply glyph-spec x))
+ (reverse w-x-y-named-glyphs)) "\n")
+ (length w-x-y-named-glyphs)))
+
+
+(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)))
+ (format #f "~$ ~$ ~$ ~$ (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.
+ (string-regexp-substitute "\\\\" "/"
+ (string-regexp-substitute " " "%20" file))
+ (cadr location)
+ (caddr location)
+ (cadddr location))
+ "")))))