Sample Code 4: How to change the font and font size of GtkLabel?
Written by kksou
Tuesday, 12 September 2006
You want to change the font and font size of GtkLabel as shown below:
$label->modify_font(new PangoFontDescription('Eras Demi ITC 48'));
| 1 |
$window = new GtkWindow();
$label = new GtkLabel("hello world!");
$label->modify_font(new PangoFontDescription('Eras Demi ITC 48')); // set font style
- 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.
- The line with
modify_font() sets the font of the label to "Eras Demi ITC" and font size to 48.
- You can just change the font size, without specifying the font name, e.g.
- I'm using php-gtk2 on winXP. For windows, you can get the names of the fonts in the fonts directory (usually it's c:\windows\fonts). E.g. you can use 'Times New Roman', 'Times New Roman Italic', 'Tahoma', 'Trebuchet MS Bold', etc. Just use the font names as it appears in that folder.
- I think it should be quite similar for Linux and Mac. If you're on this platform, maybe you could let me know if it works.