Lionel Ulmer wrote:

>Hi all,
>
>I want to add some customisation to the fonts I use in my TextWidgets (I
>mostly want to have a nice fixed-width font). The only way I found for now
>was to do the following :
>
>font = pango.FontDescription('Courier 12')
>
>This gives me a nice fixed width font... But it is plain ugly compared to
>the one I custom-tailored using real X font description
>('-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1' for the
>curious).
>
If you want a fixed width font, it is suggested that you use the font 
name "monospace".  This will allow the user to customise what their 
prefered monospace font is.  For the X pango backend, this can be 
customised in the pangox.aliases file, and for the Xft backend, it can 
be configured in the XftConfig file or fonts.conf file (depending on X 
version).  This way the user can make these settings global to all their 
applications.

>
>So my questions are :
>
>  1) is it possible to detect that one runs on X and then loads a font using
>     the X11 description (and do a fallback on the standard way when running
>     on, for example, Windows) ?
>
You really don't want to do this.  The X world is moving towards client 
side font handling with Xft (which in its newest versions can be 
compiled separately and works with servers that don't support the 
XRender extension).  Xft has many benefits, such as being able to go 
from a font name to a font file (which you can't do reliably with core 
fonts), and making the relationships between bold/italic/etc versions of 
a font more explicit.  XLFDs don't get used in any of the backend 
independent Pango APIs.

Of course, if you want nice fonts, I recommend setting the GDK_USE_XFT 
environment variable to 1 :)

>
>  2) I wanted to list the available 'families' (to maybe get something else
>     than Courier that would give me the same result as my X font). The C
>     documentation gives me the pango_font_map_list_families() API to do
>     what I want to do.
>
>     But when I try this on Python (pango.FontMap.list_families()) I get
>     told that this needs to have a 'pango.FontMap' argument. But how do I
>     create a pango.FontMap object as it always tells me that it is an
>     abstract widget ?
>
You can get the PangoFontMap from a PangoContext object, which you can 
in turn get from a widget.

>
>All in all, having more Pango / Atk examples in the Python-GTK source
>distribution would be nice :-)
>  
>
Yep.  I definitely need more examples ...

James.

-- 
Email: [EMAIL PROTECTED]              | Linux.conf.au 2003 Call for Papers out
WWW:   http://www.daa.com.au/~james/ |   http://conf.linux.org.au/cfp.html




_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to