[pygtk] setting a filter for gtk.FontSelection

John Finlay finlay at moeraki.com
Mon May 5 16:53:35 WST 2008


Le Roux Bodenstein wrote:
>>  This feature was removed from gtk after 2.2. There should be a note similar
>> to the note in the description of the FontSelectionDialog documentation.
>>     
>
>
> Aah thanks. So it is a bug in the documentation? I don't mind just
> using a normal widget and populating it with the right fonts. Any idea
> how to list and filter fonts so that you get all the monospace fonts
> on the system? I can't find it in the documentation.
>   
Retrieve the pango context from the main widget and then get the list of 
the font families in the pango context and filter them for monospace 
fonts e.g.:

context = gtk.Window().get_pango_context()
monofonts = [fam for fam in context.list_families() if fam.is_monospace()]

John


More information about the pygtk mailing list