[racket] Generating svg-images rather than png-images from Scribble

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Oct 13 11:15:41 EDT 2013

That sounds right to me. Thanks for looking into this!

How did you plan to have the parameter default? That is, does it make sense
to ever generate .png bytes when you are able to generate svg?

Robby


On Sun, Oct 13, 2013 at 10:11 AM, Jens Axel Søgaard
<jensaxel at soegaard.net>wrote:

> Hi All,
>
> Currently the html-renderer of Scribble converts picts into png-images.
> Is there an easy way to get svg-images instead?
>
> A first look at the code seems to indicate the answer is no, but maybe I
> have
> overlooked something?
>
> The html-renderer converts anything (including picts) convertible to
> png-bytes pngs.
>
> Line 1090-... in scribble/html-render.rkt  :
>
> (define/override (render-content e part ri)
>       (define (attribs [extras null]) (content-attribs e extras))
>       (cond
>         [(string? e) (super render-content e part ri)] ; short-cut for
> common case
>         [(list? e) (super render-content e part ri)] ; also a short-cut
>         [(and (convertible? e)
>               (convert e 'png-bytes))
>          => (lambda (bstr)
>               (let ([w (integer-bytes->integer (subbytes bstr 16 20) #f
> #t)]
>                     [h (integer-bytes->integer (subbytes bstr 20 24) #f
> #t)])
>                 `((img ([src ,(install-file "pict.png" bstr)]
>                         [alt "image"]
>                         [width ,(number->string w)]
>                         [height ,(number->string h)])))))]
>         [(image-element? e)
>            ...
>
> In mrlib/image-core.rkt at line 232 one sees that images currently can
> be converted to png-bytes only.
>
> Is the right way to proceed, to
>    1) add svg-bytes to mrlib/image-core.rkt.
>    2) introduce a parameter in Scribble that controls what picts
> should be converted to
>    3) change render-content in scribble/html-render.rkt accordingly
>
> ?
>
>
> https://github.com/plt/racket/blob/master/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt#L1090
>
> https://github.com/plt/racket/blob/4b8bd2260543dfe7d6da58e7529f330a1cf19d7b/pkgs/gui-pkgs/gui-lib/mrlib/image-core.rkt#L232
>
> --
> Jens Axel Søgaard
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131013/79844b22/attachment.html>

Posted on the users mailing list.