Re: How to set font to BOLD in label widget




Joel Wijngaarde <vasquez@xs4all.nl> writes:

> Sascha Ziemann wrote:
> > 
> > Joel Wijngaarde <vasquez@xs4all.nl> writes:
> > 
> > | i want for my installer app to write some labels in bold font. How can i
> > | do this with GTK (1.0)...
> > 
> > Check the rc files of Gtk. It should be possible to change the font
> > without changing the source code.
> 
> Ok, but i'm programming the app right now and i really think that some
> labels should be in the BOLD font. I want to achieve something like
> this:
> 
> Package name:		<bold font>
> 	Gimp		<ittalic font>
> Version:		<bold font>
> 	0.99.27		<ittalic font>

There are various ways of doing this. One way is to
give the widgets in bold one name, and the widgets in
italic another name (using gtk_widget_set_name). Then
you can create two different styles in your RC file,
using lines like:

style "package_label"
{
  font = '-adobe-helvetica-medium-o-*-*-*-120-*-*-*-*-*-*'
}

widget "*package_label" style "package_label"

Which will allow your users, if they so desire to change all
packages to display in red, instead of in italic.

[ There is some information about this in the tutorial ]

The other method is to make a copy of the style and modify
it:

 gtk_widget_ensure_style (label);
 new_style = gtk_style_copy (label->style);
 gdk_font_unref (new_style->font);
 new_style->font = gdk_font_load ("....");
 gtk_widget_set_style (label->new_style);

(Untested, but approximately right)

Regards,
                                        Owen



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