Page 1 of 1

wxBufferedPaintDC GetTextExtent returns too large of a value

Posted: Thu Nov 03, 2016 2:10 pm
by coderrc
I am drawing some text inside a wxBufferedPaintDC. In order to get the placement of the text correct, I call GetTextExtent.

The problem is that I am getting values that are too large.
EG on a run of text that measures 30x9, GetTextExtent returns {31,15}. :shock: thats nearly double the actual height.
In other cases the height may be acceptable, but the width returned by GetTextExtent is as much as 150% the actual display value.
It seems to get worse as the fonts get larger.


I don't need pixel perfect precision, but it needs to be within a few pixels. What can I do to resolve this?

ETA: Ive found the solution. I have to call the long form of the function and subtract out the descent and the externalleading values from the width and height