Re: Fonts in GTK+ 1.2



Quoted by a swarm of funny agents
For `"Paulo R. Panhoto" <panhoto terra com br>' 
On Wednesday, 14 May 2003 (22:50):

 How can I  change the font of a single widget without affecting the font of
 the whole window?? 

        Try this (I didn't tested, may contain errors):

void gtkut_widget_set_font(GtkWidget *widget, GdkFont *new_font)
{
        GtkStyle *style;

        g_return_if_fail(new_font != NULL);
        g_return_if_fail(widget   != NULL);

        style = gtk_style_copy(gtk_widget_get_style(widget));
        style->font = new_font;
        gtk_widget_set_style(widget, style);

        gtk_style_unref(style);
}


foobar(...){
        GdkFont *font;
        GtkWidget *label;


        (...)


        font = gdk_font_load("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*");

        label = gtk_label_new("Hello world!");
        gtkut_widget_set_font(label, font);

        (...)
}


        Bye.

-- 
 Leandro Pereira              (oO)           <leandro linuxmag com br>
 www.mindcrisis.tk            /||\                 GPG key: 0x062E7976

        "O medo é uma coisa boa. Se você não tiver medo, pode
           acabar pulando pela janela" --Keith Richards  




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