slideshow-text-style: a small library to improve text formatting in slideshow
(require slideshow-text-style) | |
package: slideshow-text-style |
This module provides a single macro that’s intended for use with Scribble’s at-expression reader in a Slideshow document. It makes it easier to use fancy text formatting in code for slides.
syntax
(with-text-style maybe-defaults (style-spec ...) body ...)
maybe-defaults =
| #:defaults (style-spec-item ...) style-spec = (name style-spec-item ...) | ((name parent) spec-item ...) style-spec-item = #:face expr | #:bold? expr | #:italic? expr | #:color expr | #:size expr | #:line-sep expr | #:left-pad expr | #:transform expr
If the second form with parent is used, the name function uses the style of the parent function but with optionally overriden styles.
If provided, maybe-defaults specifies the default style specifications that are shared by all of the styling functions.
The specifications have the following effects:
#:face: use the specified font face (e.g., "Times New Roman").
#:bold?: a boolean argument to turn bolding on or off
#:italic?: a boolean argument to turn italics on or off
#:color: colorize the text with the given color string
#:size: use the given size for the text
#:line-sep: a numeric argument specifying the sepration between lines in the text in pict units
#:left-pad: pad the produced pict on the left by the specified numeric amount in pict units
#:transform: apply the given pict to pict function to the result
#:h-append: the given function is used to append picts that are formatted in the same line. Defaults to hbl-append.
#:v-append: the given function is used to append each line of the formatted pict. Defaults to vl-append.
> (with-text-style ([t] [b #:color "blue"]) ; This uses at-exps, though you can't tell in the rendered docs ; It's supposed to look like @t{Hello @b{World}} (t "Hello "(b "World")))
> (define (do-fishy p) (hc-append 10 (standard-fish 30 20 #:color "PaleGreen") p (standard-fish 30 20 #:direction 'right #:color "PaleGreen")))
> (with-text-style ([t] [fishy #:transform do-fishy]) ; @t{@fishy{One}, @fishy{Two}, @fishy{Three}} (t (fishy "One")", "(fishy "Two")", "(fishy "Three")))
> (with-text-style ([t] [ti #:transform (lambda (p) (t #:h-append hc-append #:left-pad 30 "• " p))]) (ti "Like a bulleted list"))
Here is a more interesting example that you can try out:
#lang at-exp slideshow (require slideshow-text-style) (with-text-style #:defaults [#:face "Bitstream Vera Sans, Bold" #:size 27 #:line-sep 7] ([a #:face "Bistream Vera Sans" #:color "DimGray"] [b #:color "CornflowerBlue"] [c #:color "Tomato"] ;; a kind of inheritance [(d c) #:face "Bitstream Vera Sans"]) (slide @a{Whereas recognition of the @b{inherent dignity} and of the @b{equal} and @b{inalienable rights} of all members of the human family is the foundation of @c{freedom}, @c{justice} and @c{peace} in the world}))