Gettextextent And Font Size


Recommended Posts

I am using the Canvas component to center some text features among custom graphics.  I call Draw.SetFont() and Draw.GetTextExtent() to calculate text positions before drawing.  However, GetTextExtent() seems to report the same pixel size regardless of the font size chosen.

 

Since SetFont() does not use a DC argument, I tried a dummy TextOut() using the chosen font to see if that would set the DC before calling GetTextExtent.  It did not work either, so any help is appreciated.  Thanks.

(ver. 2203/2224/2229)

Link to comment
Share on other sites

We have that fixed.  Email us for a link to a prerelease build (or if you've already used a prerelease, its in the same spot as before).  You were on the right track trying to do a dummy TextOut().  The issue was that the system wasn't setting the font into the DC before calling GetTextExtent().  It does it now....

Link to comment
Share on other sites

I figured it might have been a simple SelectObject related thing.  The dummy TextOut was a stab in the dark, but if it had worked I would have probably questioned potential DC object leaks from not selecting it out.  Since the forum did not have much regarding GetTextExtent, I gather it is a seldom used/tested feature.  So, thanks again for a speedy fix with the 2230 update!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.