Re: Making a label text bold



Anjali Grover <anjali_grover yahoo com> writes:
> 
> In order to get a bold label text, I loaded the
> desired font into GtkFont boldfont;
> 
> Then I tried to get bold label text via:
>   label=gtk_label_new(text);
>   style = gtk_widget_get_style(label);
>   style->font = boldfont;
> 
> The result was everything bold, inlcuding the text in
> all buttons on my window.
> 
> Then, I made a copy of GdkStyle, so I tried:
> 
>   label=gtk_label_new(text);
>   style = gtk_widget_get_style(label);
>   bstyle = *style;
>   bstyle.font = boldfont;
>   gtk_widget_set_style(label, &bstyle);
> 
> The result was: nothing bold.


You want to use gtk_widget_modify_style() probably. 
See http://pobox.com/~hp/gtk-colors.html

In GTK 2 (1.3.15 is the most recent GTK 2 beta) you could use 
gtk_label_set_markup() or gtk_widget_modify_font() instead, which
would be a lot easier.

Havoc




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