Re: How to set the font's size of the GtkLabel?



Dov Grobgeld wrote:
> Hi Lazy (great name),
> 
> The way to do it is to set the name of the label through:
> 
>     gtk_widget_set_name(label, "foo");
> 
> and then define a style for the name "foo", that includes a font
> specification:
> 
>     gtk_rc_parse_string("style \"foo\" {\n"
>                                   "    font = \"Serif 32\"\n"
>                                   "}\n"
>                                   );
> 

Ugh, that's complicated. An easier way is:

GtkLabel *label = gtk_label_new("");
gtk_label_set_markup(label, "<span font_desc=\"10.0\">This is a
label</span>");

See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
how to use the pango markup language.

> 
> 2008/8/28 Lazy Fox <lazy fox wu gmail com>
> 
>> I wrote the following statememts to set a GtkLabel's font size.
>> But it seems don't work?
>> I'm not good at Pango, can anybody help me?
>>
>> +-------------------------------------------------------------------------------------------
>> | PangoAttrList *pg_attr_list = pango_attr_list_new();
>> | PangoAttribute *pg_attr = pango_attr_size_new(10);
>> |
>> | label = gtk_label_new("This is a label");
>> | pango_attr_list_change(pg_attr_list, pg_attr);
>> | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
>>
>> +------------------------------------------------------------------------------------------
>>
>> _______________________________________________
>> gtk-list mailing list
>> gtk-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gtk-list
>>
>>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 



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