[plt-scheme] MrEd: get-text-extent in dc<%>

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Dec 4 10:49:11 EST 2002

At Wed, 4 Dec 2002 10:43:45 -0500 (EST), Doug Orleans wrote:
> I notice that get-text-extent is on dc<%>, not font%.  Is this
> guaranteed to return the same extent for a given string and font on
> a bitmap-dc% and the dc of a canvas?  More generally, will drawing to
> a bitmap and copying to a canvas always look the same as drawing
> directly to the canvas?

Yes. I'll make that guarantee explicit in the docs. (I certainly rely
on it often.)

> Also, why does get-text-extent on a bitmap-dc% complain if the bitmap
> is #f?  I have a chicken-and-egg problem-- I want to draw some text
> on a bitmap, but I don't know how big to make the bitmap, but I can't
> call get-text-extent until I make a bitmap.  It works if I make a 1x1
> bitmap and then replace it with the real one, but that seems like a
> hack...

That's what I do, too.

I suppose bitmap-dc% could do that for us internally.

Matthew



Posted on the users mailing list.