wx.Font.GetPointSize returning bogus value?

R

Roger Miller

The following program gets a TextCtrl's text attributes and sets them
back unchanged. However it reports that the font size is 124, and after
resetting the attributes the text becomes that size. That is, the
window displays a normal-size "foo" and a gigantic "bar". Anyone know
what's going on?

This is WxPython 2.6 on Python 2.5 on Windows XP.

----------------------------------

import sys
import wx

class MyApp (wx.App):

def __init__ (self):
wx.App.__init__(self, redirect=0)

def OnInit (self):
top = wx.Frame(None, size=(500, 300))
txt = wx.TextCtrl(top, -1, "foo\n", (-1, -1), (400, 200),
wx.TE_RICH|wx.TE_READONLY|wx.TE_MULTILINE)
top.Show()

attrs = wx.TextAttr()
txt.GetStyle(0, attrs)
font = attrs.GetFont()
print "font face", font.GetFaceName() # prints MS Shell Dlg 2
print "font family", font.GetFamily() # prints 74
print "font size", font.GetPointSize() # prints 124!
txt.SetDefaultStyle(attrs)
txt.AppendText("bar\n")
return True

app = MyApp()
app.MainLoop()
 
T

Tim Roberts

Roger Miller said:
The following program gets a TextCtrl's text attributes and sets them
back unchanged. However it reports that the font size is 124, and after
resetting the attributes the text becomes that size. That is, the
window displays a normal-size "foo" and a gigantic "bar". Anyone know
what's going on?
....
print "font face", font.GetFaceName() # prints MS Shell Dlg 2
print "font family", font.GetFamily() # prints 74
print "font size", font.GetPointSize() # prints 124!

Not sure. On my system, the console output is the same, but the "bar"
appears as a solid black box of the right size (that is, 124 points).

It is a strange set of results. "MS Shell Dlg 2" is a fake font name that
remaps to a real font depending on your operating system and locale. 74
(0x4A) indicates a vector TrueType font of the "script" family, which is
bizarre.

May I suggest that you set your own default font before beginning?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top