Skip to content

Commit

Permalink
Use the scale when rendering svg
Browse files Browse the repository at this point in the history
Thanks to Antonio Menezes Leitao for the change
  • Loading branch information
rfindler committed Oct 26, 2014
1 parent 8601799 commit 046a851
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 046a851

Please sign in to comment.