[wxPython-users] font.IsFixedWidth failure?

Raffaello Barella barbarossa.platz at gmail.com
Wed Mar 12 09:35:41 PDT 2008


This suggestion I received time ago from jonathan worked very well for me:

2007/12/23, jonhattan <jonhattan at faita.net>:- Nascondi testo tra virgolette
-

> Raffaello Barella escribi=F3:
> > 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 =3D wx.FontEnumerator ()
> >         e.EnumerateFacenames ()
> >         listA =3D e.GetFacenames()
> >
> >         e.EnumerateFacenames(wx.FONTENCODING_SYSTEM,  fixedWidthOnly =
=3D
> > True)
> >         listF =3D e.GetFacenames()
> >
> > but unfortunately all I get  is listA =3D=3D  listF, i.e. all the exist=
ing
> > 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 fontname
>
> fe =3D FE()
> fe.EnumerateFacenames(wx.FONTENCODING_SYSTEM ,  fixedWidthOnly =3D 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
> -- jonhattan



Ciao



2008/3/12, Bob Klahn <bobklahn at comcast.net>:
>
>  This code, on my Windows XP system, with wxPython 2.8.4.0, fails to
> identify fixed-width fonts:
>
>         import wx
>
>         app =3D wx.PySimpleApp()
>
>         face_names =3D wx.FontEnumerator_GetFacenames()
>
>         for face_name in face_names:
>               font =3D wx.Font(10, wx.MODERN, wx.NORMAL, wx.BOLD,
> underline=3DFalse, face=3Dface_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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200803=
12/b5f8e9bd/attachment.htm


More information about the wxpython-users mailing list