[wxPython] How to use wxFont()?

lec wrote:

I'm trying to use wxFont to set large fonts:
eg.

font = wxFont(60, wxSWISS, wxNORMAL, wxBOLD, false, "Arial")

but I get edgy (ugly) font.

Platform and version?

RedHat 7.3/python 1.5.2
wxPython/wxGTK 2.2.1

What did I do wrong?

If you are on wxGTK and don't have an "Arial" font installed, and/or don't have a scalable font server running, then the system will compensate by scaling up some other font, probably a bitmap font.

I've tried other fonts listed under 'xlsfonts' but no difference.
for eg.
font = wxFont(60, wxSWISS, wxNORMAL, wxBOLD, false, "Avantgarde")
or
font = wxFont(60, wxSWISS, wxNORMAL, wxBOLD, false, "urw-avantgarde")
but then, I don't if the above is correct to specify the font.

Thanks.
--thomas.

lec wrote:

Platform and version?

RedHat 7.3/python 1.5.2
wxPython/wxGTK 2.2.1

I've tried other fonts listed under 'xlsfonts' but no difference.
for eg.
font = wxFont(60, wxSWISS, wxNORMAL, wxBOLD, false, "Avantgarde")
or
font = wxFont(60, wxSWISS, wxNORMAL, wxBOLD, false, "urw-avantgarde")
but then, I don't if the above is correct to specify the font.

What happens if you leave off the face name?

You can also try this: Use a wxFontDialog to get the font you want, call font.GetNativeFontInfo().ToString() and save away the string. You can then later reconstruct the font like this:

  nfi = wxNativeFontInfo()
  nfi.FromString(st)
  font = wxFontFromNativeInfo(nfi)

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!