Thanks, Raffaello (and Jonathan), that works for me as well.
But back to font.IsFixedWidth() : It doesn’t behave as documented,
at least not on Windows XP here.
Robin?
Bob
···
At 12:35 PM 3/12/2008, Raffaello Barella wrote:
This suggestion I received time
ago from jonathan worked very well for me:2007/12/23, jonhattan
jonhattan@faita.net:
- Nascondi testo tra virgolette -
Raffaello Barella escribió:Merry Xmas to everybody
I’m trying to build an application to sort out the
existing fonts
according to their properties .
Working in Windows XP Home, I tried with the following code:e =
wx.FontEnumerator ()
e.EnumerateFacenames ()
listA =
e.GetFacenames()
e.EnumerateFacenames(wx.FONTENCODING_SYSTEM, fixedWidthOnly =
True)
listF =
e.GetFacenames()but unfortunately all I get is listA == listF, i.e.
all the existing
fonts, no sorting.
Where is my mistake?Raffaello
You have to subclass wx.FontEnumerator and override
OnFacename:class FE(wx.FontEnumerator):
def OnFacename(self, fontname):
print fontnamefe = FE()
fe.EnumerateFacenames(wx.FONTENCODING_SYSTEM , fixedWidthOnly =
True)
Andale Mono
Bitstream Vera Sans Mono
Counterscraps
Courier
Courier 10 Pitch
Courier New
DejaVu Sans Mono
FreeMono
Larabiefont
Lucida Sans Typewriter
Mitra Mono
Monofonto
Monospace
Nimbus Mono L
TlwgMono
TlwgTypewriter
Unispace
– jonhattanCiao
2008/3/12, Bob Klahn
<bobklahn@comcast.net:
This code, on my Windows XP system, with wxPython
2.8.4.0, fails to identify fixed-width
fonts:` import wx
app =
wx.PySimpleApp()face_names =
wx.FontEnumerator_GetFacenames()for face_name in
face_names:
font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.BOLD, underline=False,
face=face_name)
print face_name.ljust(32), font.IsFixedWidth()`
I.e., font.IsFixedWidth() always returns False. But faces
such as ‘r_ansi’ are indeed fixed-width.Is this a wxPython bug, or am I missing something basic
here?Bob