[plt-scheme] get-text-extent problem

From: Stephen De Gabrielle (spdegabrielle at gmail.com)
Date: Mon Aug 4 04:41:24 EDT 2008

Hi,

I'm using get-text-extent to determine the width a string to be
included in a snip,

(define/override get-extent
      (lambda (dc x y w h descent space lspace rspace)
        ;(for-each (lambda (b) (when (box? b) (set-box! b 0)))
        ;           (list descent space lspace rspace))

        (let-values (((width height b s) (send dc get-text-extent
(format "~A" my-string))))
          (when (box? w) (set-box! w width))
          (when (box? h) (set-box! h height)))))

The problem is the width is wider when get-extent calls
get-text-extent than when get-text-extent is called by the (snip)draw
method.

The problem seems to be related to  spaces; I've attached a simple
example - use click-drag to select multiple snips.

Any advice appreciated,

Thanks,

Stephen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: my.ss
Type: application/octet-stream
Size: 2115 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20080804/415b4b0f/attachment.obj>

Posted on the users mailing list.