+ (svg-bezier second #t))))))
+
+(define (char font i)
+ (dispatch
+ `(fontify ,font ,(entity 'tspan (char->entity (integer->char i))))))
+
+(define (circle radius thick is-filled)
+ (entity
+ 'circle ""
+ '(stroke-linejoin . "round")
+ '(stroke-linecap . "round")
+ `(fill . ,(if is-filled "currentColor" "none"))
+ `(stroke . "currentColor")
+ `(stroke-width . ,thick)
+ `(r . ,radius)))
+
+(define (dashed-line thick on off dx dy phase)
+ (draw-line thick 0 0 dx dy
+ `(stroke-dasharray . ,(format "~a,~a" on off))))
+
+(define (draw-line thick x1 y1 x2 y2 . alist)
+ (apply entity 'line ""
+ (append
+ `((stroke-linejoin . "round")
+ (stroke-linecap . "round")
+ (stroke-width . ,thick)
+ (stroke . "currentColor")
+ (x1 . ,x1)
+ (y1 . ,(- y1))
+ (x2 . ,x2)
+ (y2 . ,(- y2)))
+ alist)))
+
+(define (ellipse x-radius y-radius thick is-filled)
+ (entity
+ 'ellipse ""
+ '(stroke-linejoin . "round")
+ '(stroke-linecap . "round")
+ `(fill . ,(if is-filled "currentColor" "none"))
+ `(stroke . "currentColor")
+ `(stroke-width . ,thick)
+ `(rx . ,x-radius)
+ `(ry . ,y-radius)))
+
+(define (partial-ellipse x-radius y-radius start-angle end-angle thick connect fill)
+ (define (make-ellipse-radius x-radius y-radius angle)
+ (/ (* x-radius y-radius)
+ (sqrt (+ (* (* y-radius y-radius)
+ (* (cos angle) (cos angle)))
+ (* (* x-radius x-radius)
+ (* (sin angle) (sin angle)))))))
+ (let*
+ ((new-start-angle (* PI-OVER-180 (angle-0-360 start-angle)))
+ (start-radius (make-ellipse-radius x-radius y-radius new-start-angle))
+ (new-end-angle (* PI-OVER-180 (angle-0-360 end-angle)))
+ (end-radius (make-ellipse-radius x-radius y-radius new-end-angle))
+ (epsilon 1.5e-3)
+ (x-end (- (* end-radius (cos new-end-angle))
+ (* start-radius (cos new-start-angle))))
+ (y-end (- (* end-radius (sin new-end-angle))
+ (* start-radius (sin new-start-angle)))))
+ (if (and (< (abs x-end) epsilon) (< (abs y-end) epsilon))
+ (entity
+ 'ellipse ""
+ `(fill . ,(if fill "currentColor" "none"))
+ `(stroke . "currentColor")
+ `(stroke-width . ,thick)
+ '(stroke-linejoin . "round")
+ '(stroke-linecap . "round")
+ '(cx . 0)
+ '(cy . 0)
+ `(rx . ,x-radius)
+ `(ry . ,y-radius))
+ (entity
+ 'path ""
+ `(fill . ,(if fill "currentColor" "none"))
+ `(stroke . "currentColor")
+ `(stroke-width . ,thick)
+ '(stroke-linejoin . "round")
+ '(stroke-linecap . "round")
+ (cons
+ 'd
+ (string-append
+ (ly:format
+ "M~4f ~4fA~4f ~4f 0 ~4f 0 ~4f ~4f"
+ (* start-radius (cos new-start-angle))
+ (- (* start-radius (sin new-start-angle)))
+ x-radius
+ y-radius
+ (if (> 0 (- new-start-angle new-end-angle)) 0 1)
+ (* end-radius (cos new-end-angle))
+ (- (* end-radius (sin new-end-angle))))
+ (if connect
+ (ly:format "L~4f,~4f"
+ (* start-radius (cos new-start-angle))
+ (- (* start-radius (sin new-start-angle))))
+ "")))))))
+
+(define (connected-shape pointlist thick x-scale y-scale connect fill)
+ (entity
+ 'path ""
+ `(fill . ,(if fill "currentColor" "none"))
+ `(stroke . "currentColor")
+ `(stroke-width . ,thick)
+ '(stroke-linejoin . "round")
+ '(stroke-linecap . "round")
+ (cons
+ 'd
+ (ly:format
+ "M0 0~a ~a"
+ (string-concatenate
+ (map (lambda (x)
+ (apply
+ (if (eq? (length x) 6)
+ (lambda (x1 x2 x3 x4 x5 x6)
+ (ly:format "C~4f ~4f ~4f ~4f ~4f ~4f"
+ (* x1 x-scale)
+ (- (* x2 y-scale))
+ (* x3 x-scale)
+ (- (* x4 y-scale))
+ (* x5 x-scale)
+ (- (* x6 y-scale))))
+ (lambda (x1 x2)
+ (ly:format "L~4f ~4f"
+ (* x-scale x1)
+ (- (* y-scale x2)))))
+ x))
+ pointlist))
+ (if connect "z " "")))))
+
+(define (embedded-svg string)
+ string)
+
+(define (embedded-glyph-string font size cid glyphs)
+ (define path "")
+ (if (= 1 (length glyphs))
+ (set! path (music-string-to-path font size (car glyphs)))
+ (begin
+ (set! path
+ (string-append (eo 'g)
+ (string-join
+ (map (lambda (x)
+ (music-string-to-path font size x))
+ glyphs)
+ "\n")
+ (ec 'g)))))
+ (set! next-horiz-adv 0.0)
+ path)
+
+(define (woff-glyph-string font-name size cid? w-x-y-named-glyphs)
+ (let* ((name-style (font-name-style font-name))
+ (family-designsize (regexp-exec (make-regexp "(.*)-([0-9]*)")
+ font-name))
+ (family (if (regexp-match? family-designsize)
+ (match:substring family-designsize 1)
+ font-name))
+ (design-size (if (regexp-match? family-designsize)
+ (match:substring family-designsize 2)
+ #f))
+ (scaled-size (/ size lily-unit-length))
+ (font (ly:paper-get-font paper `(((font-family . ,family)
+ ,(if design-size
+ `(design-size . design-size)))))))
+ (define (glyph-spec w x y g)
+ (let* ((charcode (ly:font-glyph-name-to-charcode font g))
+ (char-lookup (format #f "&#~S;" charcode))
+ (glyph-by-name (eoc 'altglyph `(glyphname . ,g)))
+ (apparently-broken
+ (comment "XFIXME: how to select glyph by name, altglyph is broken?")))
+ ;; what is W?
+ (ly:format
+ "<text~a font-family=\"~a\" font-size=\"~a\">~a</text>"
+ (if (or (> (abs x) 0.00001)
+ (> (abs y) 0.00001))
+ (ly:format " transform=\"translate(~4f,~4f)\"" x y)
+ " ")
+ name-style scaled-size
+ (string-regexp-substitute
+ "\n" ""
+ (string-append glyph-by-name apparently-broken char-lookup)))))
+
+ (string-join (map (lambda (x) (apply glyph-spec x))
+ (reverse w-x-y-named-glyphs)) "\n")))
+
+(define glyph-string
+ (if (not (ly:get-option 'svg-woff)) embedded-glyph-string woff-glyph-string))
+
+(define (grob-cause offset grob)
+ "")
+
+(define (named-glyph font name)
+ (dispatch `(fontify ,font ,name)))
+
+(define (no-origin)
+ "")
+
+(define (oval x-radius y-radius thick is-filled)
+ (let ((x-max x-radius)
+ (x-min (- x-radius))
+ (y-max y-radius)
+ (y-min (- y-radius)))
+ (entity
+ 'path ""
+ '(stroke-linejoin . "round")
+ '(stroke-linecap . "round")
+ `(fill . ,(if is-filled "currentColor" "none"))
+ `(stroke . "currentColor")
+ `(stroke-width . ,thick)
+ `(d . ,(ly:format "M~4f ~4fC~4f ~4f ~4f ~4f ~4f ~4fS~4f ~4f ~4f ~4fz"
+ x-max 0
+ x-max y-max
+ x-min y-max
+ x-min 0
+ x-max y-min
+ x-max 0)))))