Re: [DirectPython] Calculating Text Sizes
Status: Inactive
Brought to you by:
hsalo
From: Heikki S. <ho...@gm...> - 2007-08-28 16:02:31
|
> -----Original Message----- > From: dir...@li... > [mailto:dir...@li...] > On Behalf Of David > Sent: 27. elokuuta 2007 1:03 > To: Direct Python > Subject: [DirectPython] Calculating Text Sizes > > Hello, > > I am making a program which uses direct python to scroll > messages across the screen. > > I need to calculate how many pixels the message is in height. > I have tried many ways, but it seems that the > font.getTextSize function does not return the actual size. > > I am using "font.getTextSize" to get the size, and > "d3d.DrawTexts" to display the text. > > Any help on this would be much great, thanks. > > David Mack > Hi, The height which font.getTextSize() returns is always the same and line breaks don't actually increase that value. The common thing to do is to split the message into words and then calculate line- and wordsizes so that it fits into the wanted area. In short, draw many rows instead of big text blocks. This also makes sure that the message is always properly formatted and fits into the screen. For example d3dgui.EditBox and tooltip creation use this method. For trivial uses it only takes few lines of code to do this. -- Heikki Salo |