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

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat Jan 16 14:38:16 EST 2010

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.
>
> Geoff
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.