PHP-GTK2 Newsletter
PHP-GTK2 Tips & Techniques
FREE Newsletter
by kksou
Sample Code 223: How to change the font of GtkTextView? |
|
Written by kksou
|
|
Wednesday, 02 May 2007 |
|
Problem You would like to change the font or font size of a GtkTextView as shown below:

Solution Just use GtkWidget::modify_font() on the GtkTreeView.
Sample Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?php $window = new GtkWindow(); $window->set_size_request(400, 240); $window->connect_simple('destroy', array('Gtk','main_quit')); $window->add($vbox = new GtkVBox());
// display title
$title = new GtkLabel("Change the Font of GtkTextView"); $title->modify_font(new PangoFontDescription("Times New Roman Italic 10")); $title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff")); $title->set_size_request(-1, 40); $vbox->pack_start($title, 0, 0); $vbox->pack_start(new GtkLabel(), 0, 0);
// Create a new buffer and a new view to show the buffer.
$buffer = new GtkTextBuffer(); $view = new GtkTextView(); $view->set_buffer($buffer); $view->modify_font(new PangoFontDescription("Courier New 16")); // note 1
$view->set_wrap_mode(Gtk::WRAP_WORD);
|
- Note that this is only 70% of the sample code. You have to be a registered member to see the entire sample code. Please login or register.
- Registration is free and immediate.
- Have some doubt about the registration? Please read this forum article.
Explanation
- Set the font on the textview.
Related Links
User reviews Average user ratings: 3.5 (from 3 users) Note: You have to be a registered member to leave a comment. Free registration here. |
|
March 04, 2008 11:18am
June 27, 2008 12:42am
August 10, 2008 12:16pm