Re: fonts



i'm sorry, but i try but i haben't understand nothing!! ;-))
i have choose the 1 and 3 way that you have tell me, but i have this
problem:

this is the function where i want change the font. I open a dialog
window and i want change the text for "about_text"


void about_app(GtkWidget *widget, gpointer data) {
  GtkWidget *about_win;
  GtkWidget *about_text;
  gchar *title="About...";
  int nmesg;
  int cnt;

  nmesg=sizeof(about_mesg)/sizeof(about_mesg[0]);

  about_win=gtk_dialog_new_with_buttons(title,
                                        GTK_WINDOW (mainwindow),
                                        GTK_DIALOG_DESTROY_WITH_PARENT,
                                        GTK_STOCK_OK,
                                        GTK_RESPONSE_NONE,
                                        NULL);

  g_signal_connect_swapped(GTK_OBJECT(about_win),
                           "response",
                           G_CALLBACK(gtk_widget_destroy),
                           GTK_OBJECT(about_win));

/* Imposto la dimensione della finestra, ne blocco la ridimensionalita'
e blocco il
 * fuoco sulla stessa.
 */
  gtk_widget_set_size_request(GTK_WIDGET(about_win), 260, 90+(6*nmesg));
  gtk_window_set_resizable(GTK_WINDOW(about_win), 0);
  gtk_window_set_modal(GTK_WINDOW(about_win), 1);



/* Inserisco il testo all'interno della finestra e la visualizzo.
 */
  for(cnt=0; cnt<nmesg; cnt++) {
    about_text=gtk_label_new(about_mesg[cnt].message);
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(about_win)->vbox),
about_text);
  }
  gtk_widget_show_all(about_win);
}


in the first solution i can't call pango_layout_set_font_description
because the text is "char *" and not a "PangoLayout".

in the 3th solution (i think the better way) i need to manage the
PangoAttrList... for create is ok but for set the font or dimension i
need to use pango_attr_list_change?? and in which mode?

thank you ..... i hope don't disturb you! :-))
bye
Roberto

Ps. Excuse me for my poor english :-))




Il mar, 2002-08-20 alle 11:09, Olexiy Avramchenko ha scritto:
Pallucchini Roberto wrote:

i need to change the default font of gtk_label_text. what i need to do?

thanks

The stuff below is for gtk+-2.0.

1. You can use  pango_layout_set_font_description() function:
static void label_font_set(GtkLabel *label)
{
    g_return_if_fail(label!=NULL);
    g_return_if_fail(GTK_IS_LABEL(label));

    pango_layout_set_font_description(
                                                            
gtk_label_get_layout (label),
                                                            "fixed 14" 
/* put pango font description here */
    );
}

2. You can name your label with gtk_widget_set_name() and use 
"font_name" .rc file option.
3. You can use gtk_label_set_attributes() function to change font attribute.
4. You can use pango markup to specify font[s] in string passed to label.

Olexiy

-- 
/**********************
Pallucchini Roberto

e-mail: palluk infinito it
web: palluk.netfirms.com
**********************/

Powered by RedHat Linux 7.3 2.4.18-4




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