Hello,

This patch (mostly) addresses the third point for this issue:

http://code.google.com/p/lilypond/issues/detail?id=755

With this patch, the only grouping tags left in the SVG output are for

-- single pages for <page> and <pageSet> in multiple-page scores
-- single pages in order to scale them
-- rotated or colored grobs and text

I plan to address these issues, too (eventually).

If there is a simpler way to accomplish what this patch implements, I
would be happy to revise it.


Thanks,
Patrick
>From 730c0d995d25216ae5bdafb6c46a7a1da29cadd5 Mon Sep 17 00:00:00 2001
From: Patrick McCarty <pnor...@gmail.com>
Date: Tue, 5 May 2009 12:21:52 -0700
Subject: [PATCH] SVG backend: In `placebox', do not group elements

* 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 <pnor...@gmail.com>
---
 scm/output-svg.scm |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/scm/output-svg.scm b/scm/output-svg.scm
index 716f0f1..f68a517 100644
--- a/scm/output-svg.scm
+++ b/scm/output-svg.scm
@@ -280,12 +280,19 @@
                             (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*
+    ((regexp (make-regexp "^(<[a-z]+) (.*>)"))
+     (match (regexp-exec 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
@@ -301,13 +308,13 @@
 
 ;; 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 ""
@@ -376,9 +383,9 @@
 
 
 (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")
-- 
1.6.2.4

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to