+(define (draw-line thick x1 y1 x2 y2)
+ (ly:format "~4f ~4f ~4f ~4f ~4f draw_line"
+ (- x2 x1) (- y2 y1)
+ x1 y1 thick))
+
+(define (partial-ellipse x-radius y-radius start-angle end-angle thick connect fill)
+ (ly:format "~a ~a ~4f ~4f ~4f ~4f ~4f draw_partial_ellipse"
+ (if fill "true" "false")
+ (if connect "true" "false")
+ x-radius
+ y-radius
+ start-angle
+ end-angle
+ 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)
+
+(define (glyph-string pango-font
+ postscript-font-name
+ size
+ cid?
+ w-x-y-named-glyphs)
+ (define (glyph-spec w h x y g) ; h not used
+ (let ((prefix (if (string? g) "/" "")))
+ (ly:format "~4f ~4f ~4f ~a~a" w x y prefix g)))
+ (define (emglyph-spec w h x y g) ; h not used
+ (if (and (= x 0) (= y 0))
+ (ly:format "currentpoint ~a moveto ~4f 0 rmoveto" g w)
+ (ly:format "currentpoint ~4f ~4f rmoveto ~a moveto ~4f 0 rmoveto" x y g w)))
+ (if cid?
+ (ly:format
+ "/~a /CIDFont findresource ~a output-scale div scalefont setfont\n~a\n~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))
+ (if (and (ly:bigpdfs) (string-startswith postscript-font-name "Emmentaler"))
+ (ly:format "/~a-O ~a output-scale div selectfont\n~a"
+ postscript-font-name size
+ (string-join (map (lambda (x) (apply emglyph-spec x))
+ w-x-y-named-glyphs) "\n"))
+ (ly:format "/~a ~a output-scale div selectfont\n~a\n~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)
+ (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)))
+ (point-and-click (ly:get-option 'point-and-click)))
+ (if (and
+ (ly:input-location? music-origin)
+ (cond ((boolean? point-and-click) point-and-click)
+ ((symbol? point-and-click)
+ (ly:in-event-class? cause point-and-click))
+ (else (any (lambda (t)
+ (ly:in-event-class? cause t))
+ point-and-click))))
+ (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))
+
+ ;; Backslashes are not valid
+ ;; file URI path separators.
+ (ly:string-percent-encode
+ (ly:string-substitute "\\" "/" file))
+
+ (cadr location)
+ (caddr location)
+ (1+ (cadddr location)))
+ ""))
+ ""))
+ ""))
+
+(define (named-glyph font glyph)
+ (if (and (ly:bigpdfs) (string-startswith (ly:font-file-name font) "emmentaler"))
+ (if (string-endswith (ly:font-file-name font)"-brace")
+ (if (or (string-startswith glyph "brace1") (string-startswith glyph "brace2"))
+ (ly:format "~a ~a" (string-append (ps-font-command font) "-N" ) glyph)
+ (if (or (string-startswith glyph "brace3") (string-startswith glyph "brace4"))
+ (ly:format "~a ~a" (string-append (ps-font-command font) "-S" ) glyph)
+ (ly:format "~a ~a" (string-append (ps-font-command font) "-O" ) glyph)))
+ (if (string-startswith glyph "noteheads")
+ (ly:format "~a ~a" (string-append (ps-font-command font) "-N" ) glyph)
+ (if (or (string-startswith glyph "scripts") (string-startswith glyph "clefs"))
+ (ly:format "~a ~a" (string-append (ps-font-command font) "-S" ) glyph)
+ (ly:format "~a ~a" (string-append (ps-font-command font) "-O" ) glyph))))
+ (ly:format "~a /~a glyphshow" (ps-font-command font) glyph)))
+
+(define (no-origin)