How to change font of GTK textview?



Here is my attempt:

void changefont ( GtkWidget * widget , PangoFontDescription * tofd )
   {
   PangoContext * context = gtk_widget_get_pango_context ( widget );
   PangoLayout * layout = pango_layout_new ( context );
   pango_layout_set_font_description ( layout, tofd );
   }

Then at start of textview:

   GtkWidget * e = gtk_text_view_new ( ) ;
   GtkTextBuffer * buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (e));
   changefont ( e , fixedfontfd ) ; // fixed font previously defined in my code
   gtk_text_buffer_set_text (buf, inittext, -1);

The font does not change. Is the above wrong?
How to do this?

I have very little experience with GTK fonts. Help would be very much appreciated.



Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.

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