wx.lib.graphics and GetPartialTextExtents

Hi,

The width return by <wx.lib.graphics>.GetTextExtent(text) is not same
if you calculate the width of individual characters and sum it.

Note:
For char (" "), the width returned by GetTextExtent is only 1 unit.

The demo app is attached.

Prashant
Python 2.6.2
wxPython 2.8.10.1
Xp 32

demo_app_cairo_GetTextExtent.py (4.25 KB)

The width in GetTextExtent is calculated using the GDI+ method MeasureString. (See Graphics.MeasureString(const WCHAR*, INT, const Font*, const RectF, const StringFormat*, RectF*, INT*, INT*) method (Windows) | Microsoft Learn) I don't see anything in the wx code that would make any difference if it's a single character or the whole string, so it may be an issue with MeasureString. In any case, opening a ticket for this on wxTrac will get it in front of the person who knows more about this, perhaps he knows something about it.

···

On 1/17/10 9:53 PM, Prashant Saxena wrote:

Hi,

The width return by<wx.lib.graphics>.GetTextExtent(text) is not same
if you calculate the width of individual characters and sum it.

Note:
For char (" "), the width returned by GetTextExtent is only 1 unit.

The demo app is attached.

--
Robin Dunn
Software Craftsman