]> git.donarmstrong.com Git - lilypond.git/commitdiff
SVG backend: In `placebox', do not group elements
authorPatrick McCarty <pnorcks@gmail.com>
Tue, 5 May 2009 19:21:52 +0000 (12:21 -0700)
committerNeil Puttock <n.puttock@gmail.com>
Wed, 13 May 2009 20:38:08 +0000 (21:38 +0100)
* Avoid using <g>...</g> around all grobs and Pango
  text except for rotated or colored objects.  This
  makes SVG editing easier (with Inkscape, etc.)

Signed-off-by: Patrick McCarty <pnorcks@gmail.com>
scm/output-svg.scm

index 716f0f13559aa794d6e96da97f93ca4c98dc3d57..80199a1f952871334a18b8dd595e38152c59ba9d 100644 (file)
   (apply string-append
         (map (lambda (x) (char->entity x)) (string->list string))))
 
+(define svg-element-regexp
+  (make-regexp "^(<[a-z]+) (.*>)"))
+
 (define pango-description-regexp-comma
   (make-regexp "([^,]+), ?([-a-zA-Z_]*) ([0-9.]+)$"))
 
                             (ly:font-glyph-name-to-charcode font name))))))
 
 (define (placebox x y expr)
-  (entity 'g
-         expr
-         ;; FIXME: Not using GNU coding standards [translate ()] here
-         ;; to work around a bug in Microsoft Internet Explorer 6.0
-         `(transform . ,(ly:format "translate(~f, ~f)"
-                                x (- y)))))
+  (let*
+    ((match (regexp-exec svg-element-regexp expr))
+     (tagname (match:substring match 1))
+     (attributes (match:substring match 2)))
+
+    (string-append tagname
+                  ;; FIXME: Not using GNU coding standards
+                  ;; [translate ()] here to work around a
+                  ;; bug in Microsoft Internet Explorer 6.0
+                  (ly:format " transform=\"translate(~f, ~f)\" " x (- y))
+                  attributes
+                  "\n")))
 
 (define (polygon coords blot-diameter is-filled)
   (entity
 
 ;; rotate around given point
 (define (setrotation ang x y)
-  (format "<g transform=\"rotate(~a,~a,~a)\">"
+  (format "<g transform=\"rotate(~a,~a,~a)\">\n"
     (number->string (* -1 ang))
     (number->string x)
     (number->string (* -1 y))))
 
 (define (resetrotation ang x y)
-  "</g>")
+  "</g>\n")
 
 (define (round-filled-box breapth width depth height blot-diameter)
   (entity 'rect ""
 
 
 (define (setcolor r g b)
-  (format "<g color=\"rgb(~a%,~a%,~a%)\">"
+  (format "<g color=\"rgb(~a%,~a%,~a%)\">\n"
          (* 100 r) (* 100 g) (* 100 b)
          ))
 
 (define (resetcolor)
-  "</g>")
+  "</g>\n")