Can Baran wrote:
> Hi,
> 
> I believe I have not satisfied to quench your curiosity with my answers. 
> Since this has become more private than my original post, I am sending 
> this e-mail to this account of yours.

Feel free to keep this kind if thing on the list -- I like to have it 
archived there.

> Originally, what I wanted to do 
> was to translate the following code from Tkinter to wxpython:
>    def textExtent(self, text, font):
>         return font.measure(text), font.metrics('linespace')
> 
>     def textLineSpacing(self, font):
>         return font.metrics('linespace')
> Now, I believe I need to use getFullextent function to do the 
> translation. I hope it is clear now.

I see, you need stuff you can use for a bit of typesetting.

OK, using DC.GetFullTextExtent(text) will get you what you need, in 
pixel coordinates. If you are using a FloatCanvas.ScaledText object, 
then you'll need to translate that to world coords. This is not quite 
trivial, unfortunately.

I suggest you pick a font size, say 14, then call 
DC.GetFullTextExtent(text), and use that to scale the result, so that if 
the LineSpacing is , say 17, then you know that line spacing is 17/14 
times the font size. Now when you specify a size for your ScaledText 
Object, you can multiply it by that factor the get the line spacing.

You might want to take a look at the FloatCanvas.ScaledTextBox code to 
get some ideas. In that, I used:

TextHeight = dc.GetTextExtent("X")[1]
LineHeight = TextHeight * self.LineSpacing

Where LineSpacing was specified by the user, and defaults to 1.0. I 
think GetTextExtent does pad a bit.

-Chris








-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[EMAIL PROTECTED]
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to