Re: Font changes

--- John K Luebs <jkluebs luebsphoto com> wrote:
On Sun, Dec 14, 2003 at 08:15:24PM -0800, Sheldon
Simms wrote:
Hi all,

I'm new to GTK+ programming and I'd like to know
if it
is possible to change the font used by standard
widgets such as GtkEntry.

My particular desire at the moment is for
GtkSpinButton to use a monospaced font, but I
mind knowing if it is generically possible to set
font, regardless of theme, etc., for individual

Sometimes, its best to use the themeing or, more
precisely, rcstyle
system for this purpose. First, make sure that you
name all your
customizable widgets with gtk_widget_set_name or
setting the name
property. Then you call gtk_rc_parse or
for any number of RC customization files with
documented path
locations. You might parse a site wide one, and then
a user
provided (located in the home directory). You can
ship a default file
along with your application that sets things to
reasonable defaults. The
advantage of this method is that you give the user
full customizability
without having to recompile.
The disadvantage is that you have to maintain
another data file.

You can override the RcStyle settings completely
gtk_widget_set_style, or you can override certain
settings with the
gtk_widget_modify_* functions. For example, to
ensure a monospace font,
you would create a PangoFontDescription, and call
pango_font_description_set_family(fd, 'monospace').
Then simply pass this
FontDescription to the widget with
gtk_widget_modify_font. Of course, it
will be impossible to override this setting from an
RC file. 

Thanks for the very helpful reply. In this case the
fixed monospace font is exactly what I wanted and it
was very easy to implement, but I also appreciate the
information about RC files. That's the kind of thing I
was looking for with my more generic question.


Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]