blitzmann
blitzmann

Reputation: 7905

Font issues from 2.8 to >= 2.9

I am a developer for a program the uses wxPython 2.8. I am hoping that we can upgrade to 3.0 (and maintain backwards compatibility) however there seems to be an issue with font sizes with our custom widgets.

All the standard widgets (lists, static text, etc) seem to have the same font from 2.8 -> 2.9+, but our customs widgets (which uses wx.FontFromPixelSize() to set a font) all seem bigger on 2.9 than they do on 2.8. Here is a screenshot for comparison: https://i.sstatic.net/nG5nv.jpg

The custom widgets all use wx.FontFromPixelSize(). In the example above, that widget uses:

self.font = wx.FontFromPixelSize((0,14),wx.SWISS, wx.NORMAL, wx.NORMAL, False)

It just seems that 2.8 and 2.9 handle the pixel size differently, and I'm not sure why. I can't find much information on it online.

I can emulate the look of 2.8 by using (0,11) as the size, however then if you run it in 2.8 it is very teeny.

One thing I did notice, however, is that if I call Font.GetPixelSize() on the main window (of which a font is not explicitly set), it returns two different values depending on version:

2.8: (0,-11)

2.9+: (0,12)

I do not know if this is relevant or not, or if the issue has to do with a bad baseline size. Was hoping there was an easy fix to this - I could always store all sizes in a different module with some logic to pick based on wxPython version.

Also, this is all from Windows 7 x64. I have not been able to test on Linux/OSX yet.

Upvotes: 2

Views: 125

Answers (1)

RobinDunn
RobinDunn

Reputation: 6306

ISTR that this was changed because the way that the pixel --> point size was being calculated in 2.8 was incorrect, and it was fixed for 2.9/3.0. If you need to maintain compatibility then you can just conditionalize the value used for the pixel height based on wx.VERSION.

Upvotes: 1

Related Questions