|
Post by u9 on Nov 25, 2006 7:52:29 GMT -5
It would be nice to be able to get the width and height of any text you want to render in pixels. It is useful for e.g. centering an arbitrary text on the screen or right-aligning text, or as in the case of my bubble-text class it can be used to calculate what size the background bubble should be.
width = graphics.getTextWidth( font, text ) height = graphics.getTextHeight( font, text )
The functions should return the width and height in pixels if one was to render the text with the given font.
|
|
|
Post by hartnell on Nov 25, 2006 7:58:43 GMT -5
I was going to request this one myself. It's available in Game Maker, which used Delphi and DirectX. -hartnell
|
|
|
Post by u9 on Nov 25, 2006 9:37:45 GMT -5
Afaik it is also available in Visual Basic, so I can imaging it would be easy to implement.
|
|
|
Post by OddChild on Nov 25, 2006 10:27:40 GMT -5
hehe remember to keep it to the right scale, so it is like graphics.getheight Via fontsize.
|
|
|
Post by u9 on Feb 18, 2007 20:49:44 GMT -5
Fonts cannot be scaled in the same sence as images so no worries there. Guilect did you forget about this, or was it not suitable to implement? If it is too complicated or too much work, then no problem
|
|
|
Post by Guilect on Feb 19, 2007 9:04:32 GMT -5
I did not forget. It is not so simple. I spent several hours on this. The problem is that B2D does not store the kind of font that you create. (it is a one way street, creates the font but does not care after that. It is called by an index that has no bearing on the size). So it has no way of calculating what size it takes up. B2D would have to have a change to it that would store all the parameters (font type, size, bold, italic, underline, etc.) for each font created. Then would have to take the exact string in that the user wanted to print and then somehow find out what size that was. It is still on the to do list.
|
|
|
Post by u9 on Feb 19, 2007 11:21:32 GMT -5
Ok, it is not so important. I posted some tips on how to center text anyway Also, if one uses fixed width text, there is basically no problem.
|
|