wx.Font: PointSize 70 set to 8

130 views
Skip to first unread message

Manfred Theissen

unread,
Aug 2, 2010, 8:38:52 PM8/2/10
to wxpytho...@googlegroups.com
Hi all,

there is a strange behavior of wx.Font: When I try to make a wx.Font of size 70, I get one with a size of 8. This small test (see att.)

import wx
app = wx.App(False)

for face in ('Arial', 'Times NewRoman', 'Symbol'):
print face
for size in range(4, 200):
font = wx.Font(
pointSize=size,
family=wx.FONTFAMILY_DEFAULT,
style=wx.FONTSTYLE_NORMAL,
weight=wx.FONTWEIGHT_NORMAL,
underline=False,
faceName=face)
if size != font.PointSize:
print size, font.PointSize

produces

Arial
70 8
Times NewRoman
70 8
Symbol
70 8

I am using Python 2.6.5 (32) and wxPython 2.8.11.0 unicode on Windows 7. Let me know if you need more information; I suppose this is a problem specific to my system as so far no one has experienced something similar (except perhaps http://programming.itags.org/python/101470 ) . Some time ago on Win XP, this problem did not occur, but then I used other Python and wxPython versions.

Best regards

point_size.py

Tim Roberts

unread,
Aug 3, 2010, 1:21:27 PM8/3/10
to wxPython-users
Fascinating. I see the same result on my XP SP3 machine with Python
2.6.2 and wxPython 2.8.10.1. OK, that's just too weird to let go. I
will have to dig in and let you know what I find.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Tim Roberts

unread,
Aug 3, 2010, 1:44:12 PM8/3/10
to wxPython-users
This is essentially a design flaw in wxWidgets (below wxPython). You
are allowed to specify wx.DEFAULT as the value for font size. When
you do so, wx substitutes the point size of its default font. It just
so happens that wx.DEFAULT has the value 70, and the default font is
11 pixels tall, which is 8 points on a 96 dpi monitor. One could
argue that there are many choices for wx.DEFAULT that would have been
preferable to 70.

You will have to work around this yourself. Instead of a point size
of 70, you can compute the pixel size yourself. On a 96 DPI monitor,
70 points is 93 pixels.
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

Robin Dunn

unread,
Aug 3, 2010, 1:46:42 PM8/3/10
to wxpytho...@googlegroups.com
On 8/2/10 5:38 PM, Manfred Theissen wrote:
> Hi all,
>
> there is a strange behavior of wx.Font: When I try to make a wx.Font of size 70, I get one with a size of 8. This small test (see att.)

>


> I am using Python 2.6.5 (32) and wxPython 2.8.11.0 unicode on Windows 7. Let me know if you need more information; I suppose this is a problem specific to my system as so far no one has experienced something similar (except perhaps http://programming.itags.org/python/101470 ) . Some time ago on Win XP, this problem did not occur, but then I used other Python and wxPython versions.


It's doing it for me on XP too. Please create a ticket for this bug at
trac.wxwidgets.org.


--
Robin Dunn
Software Craftsman
http://wxPython.org

Robin Dunn

unread,
Aug 3, 2010, 1:50:42 PM8/3/10
to wxpytho...@googlegroups.com
On 8/3/10 10:44 AM, Tim Roberts wrote:
> This is essentially a design flaw in wxWidgets (below wxPython). You
> are allowed to specify wx.DEFAULT as the value for font size. When
> you do so, wx substitutes the point size of its default font. It just
> so happens that wx.DEFAULT has the value 70, and the default font is
> 11 pixels tall, which is 8 points on a 96 dpi monitor. One could
> argue that there are many choices for wx.DEFAULT that would have been
> preferable to 70.

Well, that is certainly a DSM (dumb, stupid mistake). A bug report will
certainly get this fixed.

Robin Dunn

unread,
Aug 3, 2010, 2:23:53 PM8/3/10
to wxpytho...@googlegroups.com


Well the code in question has been there at least 10 years, so maybe it
won't be changed. Doesn't hurt to try though. wxGTK has the same
issue, but wxMac does not.

Christopher Barker

unread,
Aug 3, 2010, 3:18:34 PM8/3/10
to wxpytho...@googlegroups.com
Tim Roberts wrote:
> It just
> so happens that wx.DEFAULT has the value 70,

Wow! enumerations and integer constants sure suck!

Long live Python!

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov

Tim Roberts

unread,
Aug 4, 2010, 1:35:12 PM8/4/10
to wxPython-users
OK, I created ticket 12315 for this issue.

On Aug 3, 11:23 am, Robin Dunn <ro...@alldunn.com> wrote:
>
> Well, that is certainly a DSM (dumb, stupid mistake). A bug report will
> certainly get this fixed.
>
> Well the code in question has been there at least 10 years, so maybe it
> won't be changed.  Doesn't hurt to try though.  wxGTK has the same
> issue, but wxMac does not.

Yes, this code was specifically added 10 years ago because someone
complained that specifying wx.DEFAULT as the point size resulted in a
70-point font. The choice of 70 is a real mystery to me.

pymt

unread,
Aug 4, 2010, 7:42:29 PM8/4/10
to wxPython-users
Thanks for your replies. Until this is fixed, I'll reset the size via
SetPointSize which seems to work correctly.
Reply all
Reply to author
Forward
0 new messages