+(define (string->entities string)
+ (apply string-append
+ (map (lambda (x) (char->entity x)) (string->list string))))
+
+(define pango-description-regexp-comma
+ (make-regexp "([^,]+), ?([-a-zA-Z_]*) ([0-9.]+)$"))
+
+(define pango-description-regexp-nocomma
+ (make-regexp "([^ ]+) ([-a-zA-Z_]*) ?([0-9.]+)$"))
+
+(define (pango-description-to-svg-font str)
+ (let*
+ ((size 4.0)
+ (family "Helvetica")
+ (style #f)
+ (match-1 (regexp-exec pango-description-regexp-comma str))
+ (match-2 (regexp-exec pango-description-regexp-nocomma str))
+ (match (if match-1
+ match-1
+ match-2)))
+
+ (if (regexp-match? match)
+ (begin
+ (set! family (match:substring match 1))
+ (if (< 0 (string-length (match:substring match 2)))
+ (set! style (match:substring match 2)))
+ (set! size
+ (string->number (match:substring match 3))))
+
+ (ly:warning (_ "cannot decypher Pango description: ~a") str))
+
+ (set! style
+ (if (string? style)
+ (format "font-style:~a;" style)
+ ""))
+
+ (format "font-family:~a;~afont-size:~a;text-anchor:west"
+ family
+ style
+ (/ size lily-unit-length))
+ ))
+
+;;; FONT may be font smob, or pango font string
+(define (svg-font font)
+ (if (string? font)
+ (pango-description-to-svg-font font)
+ (let ((name-style (font-name-style font))
+ (size (modified-font-metric-font-scaling font))
+ (anchor "west"))