>From 090c1ebe8f4a8a637cc1d4039c45c454b4138ec4 Mon Sep 17 00:00:00 2001
From: Patrick McCarty
Date: Tue, 5 May 2009 12:21:52 -0700
Subject: [PATCH] SVG backend: In `placebox', do not group elements
* Avoid using ... 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
---
scm/output-svg.scm | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/scm/output-svg.scm b/scm/output-svg.scm
index 716f0f1..80199a1 100644
--- a/scm/output-svg.scm
+++ b/scm/output-svg.scm
@@ -107,6 +107,9 @@
(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.]+)$"))
@@ -280,12 +283,18 @@
(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
@@ -301,13 +310,13 @@
;; rotate around given point
(define (setrotation ang x y)
- (format ""
+ (format "\n"
(number->string (* -1 ang))
(number->string x)
(number->string (* -1 y))))
(define (resetrotation ang x y)
- "")
+ "\n")
(define (round-filled-box breapth width depth height blot-diameter)
(entity 'rect ""
@@ -376,9 +385,9 @@
(define (setcolor r g b)
- (format ""
+ (format "\n"
(* 100 r) (* 100 g) (* 100 b)
))
(define (resetcolor)
- "")
+ "\n")
--
1.6.2.4