commit 990dc34ae32aa24b47816a68dc80b5fa5dfdd3f5
parent 81698b177c651c17f6fbd6fb01890e149540c154
Author: Robby Findler <robby@racket-lang.org>
Date: Sun, 26 Oct 2014 07:08:08 -0500
Use the scale when rendering svg
Thanks to Antonio Menezes Leitao for the change
original commit: 046a851d7090f35a5966a3020e29d40c59948567
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt b/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt
@@ -1237,6 +1237,19 @@
[svg? (regexp-match? #rx#"[.]svg$" (if (path? src) (path->bytes src) src))]
[sz (cond
[svg?
+ (define (to-scaled-num-from-str s)
+ (define parts
+ (regexp-match
+ #rx"^([+-]?[0-9]*\\.?([0-9]+)?)(em|ex|px|in|cm|mm|pt|pc|%|)$"
+ s))
+ (cond
+ [parts
+ (string-append
+ (number->string
+ (* scale
+ (string->number (list-ref parts 1))))
+ (list-ref parts 3))]
+ [else s]))
(call-with-input-file*
src
(lambda (in)
@@ -1257,7 +1270,8 @@
[w (ormap (check-name 'width) attribs)]
[h (ormap (check-name 'height) attribs)])
(if (and w h)
- `([width ,w][height ,h])
+ `([width ,(to-scaled-num-from-str w)]
+ [height ,(to-scaled-num-from-str h)])
null)))))]
[else
;; Try to extract file size: