Re: default font.



peter garrone wrote:

I am having trouble setting the font for my application, just having a different font for a GtkLabel. I can change the color using a resource file style, but not the font.

Get a look to the message I've posted some days ago, subject "Fonts: 5 ways to change the gtk+-2.0 text label font".
It contains an attach with example.



I am able to use the use the gtk font select widget to see a range of fonts, and to print their names using gtk_font_selection_get_font_name. But using these names does not set the font.

The actual font being used, "Sans 10", comes from the file gtksettings.c, which sets a property called "gtk-font-name". I have confirmed,
So you're probably using gtk+-2.0.

using ldd and strings on all the libraries that my application links to, that this is the place where the font is set, although I have
not been able to test any config files. Question is, whats a setting? How do I override this?

GtkSettings is GObject with "gtk-font-name" property, all you need is to set this property.
Use this code after gtk_init:
---
GValue value = {0,};

g_value_init(&value, G_TYPE_STRING); /* value type initilization, we need string value */ g_value_set_string(&value, "Fixed 14"); /* put font description here (value of the value:) */ g_object_set_property(G_OBJECT(gtk_settings_get_default()), "gtk-font-name", &value); /* setting the property */
   g_value_unset(&value);    /* cleaning up */
---

Olexiy





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