GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Apr 23, 2014 2:22 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Help me in font size of button and label
PostPosted: Sun Jan 07, 2007 2:12 pm 
Offline
Familiar Face

Joined: Wed Nov 22, 2006 10:22 pm
Posts: 12
Hi, all.

I wish to enlarge the text font size in the button and label widgets. How to do ?

Thanks in advance.

_________________
I am new in GTK+, help me in any way. THANKS!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 07, 2007 5:44 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Well, first of all, you are very, very strongly adviced not to do so. User's have theme and preference settings which they won't like losing. For example, 6 years ago I would make my screen resolution really high and use small fonts-- since then my eyesight has gotten worse and my font sizes have gone up.

GTK+ deals with the defaults of fonts, colors, and sizes through RC files.
Here it is in the tutorial: http://www.gtk.org/tutorial/c2118.html
And herer it is in the API: http://developer.gnome.org/doc/API/2.2/gtk/gtk-Resource-Files.html

However, if you must change the font and size, you do so with Pango

Code:
PangoFontDescription    *fd = NULL;
GtkWidget      *w = NULL;

/* code here to create widget or get it from glade */

/* change the widget's font */

fd = pango_font_description_from_string ("Monospace 12");
gtk_widget_modify_font (w, fd);

/* display the widget or do whatever else you gotta do */
http://developer.gnome.org/doc/API/2.4/pango/pango-Fonts.html

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject: Thank you.
PostPosted: Mon Jan 08, 2007 5:23 am 
Offline
Familiar Face

Joined: Wed Nov 22, 2006 10:22 pm
Posts: 12
Thank you so much.

I need to display some information clearly, such as the time, the amount of cash, etc. The large size of text is not in full screen, but just in certain label or button.

_________________
I am new in GTK+, help me in any way. THANKS!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 5:44 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
In that case, you may want to instead use pango markup to simply make the font larger relative to the rest of the text. That way it's still in-line with the user's preferences...

Code:
gtk_label_set_user_markup (label, TRUE);
gtk_label_set_markup (label, "<big>This is a larger font</big>");

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 6:54 pm 
Offline

Joined: Tue Mar 27, 2007 6:47 pm
Posts: 2
Is there any possibility to change only the font size? I want the font face to stay the same. I don't have the function gtk_label_set_markup. If i use
Code:
fd = pango_font_description_from_string ("Monospace 12");
gtk_widget_modify_font (w, fd);

I have to know what font face to use. Can I get the font face from another function?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 6:59 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
You can get the current font description from the widgets's style with GTK_WIDGET(widget)->style->font_desc. Then use pango_font_description_set_size() to set just the size.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 08, 2008 5:15 am 
Offline
Familiar Face

Joined: Thu Jan 31, 2008 11:34 pm
Posts: 5
my IDE don´t recognizes the pango_font_descripion. i use codeblocks in WindowsXP because i do an system for win and Linux, i know which windows sting but i don't choice. i don't wanna use markup. helps


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Alexa [Bot], Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group