GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help me in font size of button and label

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
kingsz1
Familiar Face


Joined: 22 Nov 2006
Posts: 12

PostPosted: Sun Jan 07, 2007 2:12 pm    Post subject: Help me in font size of button and label Reply with quote

Hi, all.

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

Thanks in advance.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 480
Location: Portland, OR USA

PostPosted: Sun Jan 07, 2007 5:44 pm    Post subject: Reply with quote

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: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
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
Back to top
kingsz1
Familiar Face


Joined: 22 Nov 2006
Posts: 12

PostPosted: Mon Jan 08, 2007 5:23 am    Post subject: Thank you. Reply with quote

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.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 480
Location: Portland, OR USA

PostPosted: Mon Jan 08, 2007 5:44 pm    Post subject: Reply with quote

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: (Plaintext)
1
2
gtk_label_set_user_markup (label, TRUE);
gtk_label_set_markup (label, "<big>This is a larger font</big>");
Back to top
IckoPicko



Joined: 27 Mar 2007
Posts: 2

PostPosted: Tue Mar 27, 2007 6:54 pm    Post subject: Reply with quote

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: (Plaintext)
1
2
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!
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 386
Location: Fairfax, Virginia

PostPosted: Tue Mar 27, 2007 6:59 pm    Post subject: Reply with quote

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.
Back to top
Vene
Familiar Face


Joined: 31 Jan 2008
Posts: 5

PostPosted: Sat Mar 08, 2008 5:15 am    Post subject: Reply with quote

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP