[plt-scheme] slideshow, draw letters in a word in different colors

From: Geoffrey S. Knauth (geoff at knauth.org)
Date: Sat Jan 16 14:52:59 EST 2010

That's just perfect!  Thanks, Robby!  --Geoff

On Jan 16, 2010, at 14:38, Robby Findler wrote:

> There are two ways to draw letters, at the low-level GUI: drawing a
> string with kerning and ligatures, or drawing each letter
> individually, next to each other. So if you're not really concerned
> with that low-level detail, then you can break up the string and use
> hbl-append. It will look fine for "ABCD". But it won't be the same for
> "fish". It probably won't matter, tho.
> #lang scheme
> (require slideshow)
> ;; separate : string -> (listof pict)
> (define (separate str)
>  (for/list ((c (in-string str))
>             (i (in-naturals)))
>    (colorize (t (string (string-ref str i)))
>              (if (odd? i)
>                  "red"
>                  "black"))))
> (slide
> (apply hbl-append (separate "ABCD"))
> (vl-append (apply hbl-append (separate "fish"))
>            (colorize (t "fish") "purple")))
> Robby
> On Sat, Jan 16, 2010 at 1:31 PM, Geoffrey S. Knauth <geoff at knauth.org> wrote:
>> Is there a way to do kerning in slideshow?  I have a string, say, "ABCD".  I want each letter to be in a different color, and I'm not using a monospace font.  It's easy to do if I wanted spaces in between the letters A B C D, but I want ABCD.  I've tried using cbl-superimpose and prepending some arbitrary number of spaces ("A" " B" " C" "   D"), but that's pure guesswork and I'd rather do this precisely and predictably.  I think I can make a pict out of each letter and get its pict-width, but then I still have to figure out how to do the kerning.

Posted on the users mailing list.