How do I change the font of a GtkText widget?

GTK+ FAQ
<<< Previous | Development with GTK+: widget specific questions | Next >>>

# How do I change the font of a GtkText widget?

There are a couple of ways of doing this. As GTK+ allows the appearance of applications to be changed at run time using resources you can use something like the following in the appropriate file:

    style "text"
    {
      font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
    }

Another way to do this is to load a font within your program, and then use this in the functions for adding text to the text widget. You can load a font using, for example:

      GdkFont *font;
      font = gdk_font_load("-adobe-helvetica-medium-r-normal--*-140-*-*-*-*-*-*");

<<< Previous | Home | Next >>>
How do I use horizontal scrollbars with a GtkText widget? | Up | How do I set the cursor position in a GtkText object?