summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pict.scm20
1 files changed, 10 insertions, 10 deletions
diff --git a/pict.scm b/pict.scm
index 3e3f11a..b853c47 100644
--- a/pict.scm
+++ b/pict.scm
@@ -121,15 +121,20 @@
pict?
(sxml pict-sxml))
+(define (pict->svg-sxml pict)
+ "Wrap the PICT's SXML data in a proper SVG wrapper with height,
+width, and SVG namespace."
+ `(svg (@ (width ,(pict-width pict))
+ (height ,(pict-height pict))
+ (xmlns "http://www.w3.org/2000/svg"))
+ ,(pict-sxml pict)))
+
(define (pict->file pict file-name)
"Write the PICT to a file with name FILE-NAME. If FILE-NAME is a
procedure, it is called with the XML that is supposed to be written to
the file to determine the file name. Return the file name."
(let* ((xml (with-output-to-string
- (lambda _ (sxml->xml `(svg (@ (width ,(pict-width pict))
- (height ,(pict-height pict))
- (xmlns "http://www.w3.org/2000/svg"))
- ,(pict-sxml pict))))))
+ (lambda _ (sxml->xml (pict->svg-sxml pict)))))
(name (if (procedure? file-name)
(file-name xml) file-name)))
(with-output-to-file name
@@ -154,14 +159,9 @@ the file to determine the file name. Return the file name."
(define* (pict->pdf pict out #:key page-height page-width)
"Read SVG from picture PICT and write a PDF file to OUT."
- (define svg
- `(svg (@ (width ,(pict-width pict))
- (height ,(pict-height pict))
- (xmlns "http://www.w3.org/2000/svg"))
- ,(pict-sxml pict)))
(let* ((port (mkstemp! (string-copy "/tmp/pictXXXXXXX")))
(name (port-filename port)))
- (sxml->xml svg port)
+ (sxml->xml (pict->svg-sxml pict) port)
(close-port port)
(let*-values (((d) (rsvg-set-default-dpi-x-y %dpi %dpi))
((handle) (rsvg-handle-new-from-file name))