file/convertible: add 'pfd-bytes+bounds8 and many more

The 'pfd-bytes+bounds8 format can add extra padding around the image,
and the result reports the amount of added padding. This padding can
be used to include image output that it outside of the conceptual
bounding box, such as an italic glyph that extends beyond its
character's width.
This commit is contained in:
Matthew Flatt 2014-06-27 16:48:19 +01:00
parent 970b040d17
commit 37af1c8ef0

View File

@ -22,18 +22,46 @@ should be considered standard:
@item{@racket['text] --- a string for human-readable text} @item{@racket['text] --- a string for human-readable text}
@item{@racket['gif-bytes] --- a byte string containing a GIF image encoding} @item{@racket['gif-bytes] --- a byte string containing a GIF image encoding}
@item{@racket['png-bytes] --- a byte string containing a PNG image encoding} @item{@racket['png-bytes] --- a byte string containing a PNG image encoding}
@item{@racket['png@2x-bytes] --- like @racket['png-bytes], but intended drawing at @racket[1/2] scale} @item{@racket['png-bytes+bounds] --- a list containing a byte string and four numbers;
the byte string contains a PNG document, and the four numbers
are sizing information for the image: the width, height,
descent (included in the height), and extra vertical top space
(included in the height), in that order}
@item{@racket['png-bytes+bounds8] --- a list containing a byte string
and eight numbers; like @racket['png-bytes+bounds], but where
the image encoded that is in the byte string can be padded in
each direction (to allow the drawn region to extend beyond
it's ``bounding box''), where the extra four numbers in the
list specify the amount of padding that was added to the
image: left, right, top, and bottom}
@item{@racket['png@2x-bytes] --- like @racket['png-bytes], but for an
image that is intended for drawing at @racket[1/2] scale}
@item{@racket['png@2x-bytes+bounds] --- like
@racket['png-bytes+bounds], but for an image that is intended
for drawing at @racket[1/2] scale, where the numbers in the result
list are already scaled (e.g, the byte string encodes an image that
is twice as wide as the first number in the resulting list)}
@item{@racket['png@2x-bytes+bounds8] --- like @racket['png-bytes+bounds8],
but but for an image that is intended for drawing at
@racket[1/2] scale, and where the numbers in the result
list are already scaled}
@item{@racket['svg-bytes] --- a byte string containing a SVG image encoding} @item{@racket['svg-bytes] --- a byte string containing a SVG image encoding}
@item{@racket['svg-bytes+bounds] --- like @racket['png-bytes+bounds], but
for an SVG image}
@item{@racket['svg-bytes+bounds8] --- like @racket['png-bytes+bounds8], but
for an SVG image}
@item{@racket['ps-bytes] --- a byte string containing a PostScript document} @item{@racket['ps-bytes] --- a byte string containing a PostScript document}
@item{@racket['eps-bytes] --- a byte string containing an Encapsulated PostScript document} @item{@racket['eps-bytes] --- a byte string containing an Encapsulated PostScript
@item{@racket['eps-bytes+bounds] --- a list containing a byte string and four numbers; document}
the byte string contains an Encapsulated PostScript document and the four numbers @item{@racket['eps-bytes+bounds] --- like @racket['png-bytes+bounds], but,
are sizing information for the PostScript document, namely the width, height, ascent but for an Encapsulated PostScript document}
and descent in that order} @item{@racket['eps-bytes+bounds8] --- like @racket['png-bytes+bounds8], but,
but for an Encapsulated PostScript document}
@item{@racket['pdf-bytes] --- a byte string containing a PDF document} @item{@racket['pdf-bytes] --- a byte string containing a PDF document}
@item{@racket['pdf-bytes+bounds] --- a list containing a byte string and four numbers; @item{@racket['pdf-bytes+bounds] --- like @racket['png-bytes+bounds], but,
the byte string contains a PDF document and the four numbers are sizing information but for an PDF document}
for the PDF document, namely the width, height, ascent and descent in that order} @item{@racket['pdf-bytes+bounds8] --- like @racket['png-bytes+bounds8], but,
but for an PDF document}
] ]
@defthing[prop:convertible struct-type-property?]{ @defthing[prop:convertible struct-type-property?]{
@ -57,13 +85,26 @@ Returns @racket[#t] if @racket[v] supports the conversion protocol,
[(gif-bytes png-bytes png@2x-bytes [(gif-bytes png-bytes png@2x-bytes
ps-bytes eps-bytes pdf-bytes svg-bytes) ps-bytes eps-bytes pdf-bytes svg-bytes)
(or/c bytes? (λ (x) (eq? x default)))] (or/c bytes? (λ (x) (eq? x default)))]
[(eps-bytes+bounds pdf-bytes+bounds) [(png-bytes+bounds png@2x-bytes+bounds
eps-bytes+bounds pdf-bytes+bounds)
(or/c (list/c bytes? (or/c (list/c bytes?
(and/c real? (not/c negative?)) (and/c real? (not/c negative?))
(and/c real? (not/c negative?)) (and/c real? (not/c negative?))
(and/c real? (not/c negative?)) (and/c real? (not/c negative?))
(and/c real? (not/c negative?))) (and/c real? (not/c negative?)))
(λ (x) (eq? x default)))] (λ (x) (eq? x default)))]
[(png-bytes+bounds8 png@2x-bytes+bounds8
eps-bytes+bounds8 pdf-bytes+bounds8)
(or/c (list/c bytes?
(and/c real? (not/c negative?))
(and/c real? (not/c negative?))
(and/c real? (not/c negative?))
(and/c real? (not/c negative?))
(and/c real? (not/c negative?))
(and/c real? (not/c negative?))
(and/c real? (not/c negative?))
(and/c real? (not/c negative?)))
(λ (x) (eq? x default)))]
[else any/c])]{ [else any/c])]{
Requests a data conversion from @racket[v], where @racket[request] Requests a data conversion from @racket[v], where @racket[request]