1
votes

I've got an inherited project that was made with glade. I've managed to get it compiled against gtk+1.2 after debugging some automake and gettext issues. (It's old code that keeps being adapted for similar purposes.) Unfortunately, I have never used GTK before. The code is in C and being developed on CentOS 6.

When compiled, it's supposed to look something like this (a screenshot of an old version I've managed to dig up):

good gui

Instead, it looks like this when I compile it on my system:

bad gui

Ie, all the buttons, windows, and such are present, but it looks like the fonts have gone super-sized. I'm guessing that this is just an issue of pointing the code toward a better set of fonts, but maybe not. Has anyone encountered this sort of thing before? And if so, does anyone have some ideas about where to start looking on how to fix things?

UPDATE:

So I've found in the XML file where the labels are set. For example, the top-left GUNN On button is defined thusly:

<child>
  <widget class="GtkToggleButton" id="gunn2_on_tog">
    <property name="can_focus">yes</property>
    <property name="label" translatable="yes">GUNN On</property>
    <property name="relief">GTK_RELIEF_NORMAL</property>
    <property name="active">no</property>
    <property name="width-request">72</property>
    <property name="height-request">24</property>
    <property name="visible">yes</property>
    <signal name="toggled" handler="on_gunn2_on_tog_toggled" />
  </widget>
  <packing>
    <property name="x">8</property>
    <property name="y">16</property>
  </packing>
</child>

It seems that I need to do some sort of Pango markup: https://developer.gnome.org/pango/stable/PangoMarkupFormat.html, but I'm still in the process of digging.

UPDATE 2:

I managed to convert the glade file to a version recent enough that the glade installed on the computer would open it. The fonts interface fonts in the glade app look fine. It's not until I compile and run the program that the fonts get out of whack. I've also tried changing my system font preference via the preferences menu to no avail.

UPDATE 3:

I've been able to change the font. Finally. I edited /etc/gtk/gtkrc and added the lines

style "default-text" {
fontset = "-adobe-helvetica-medium-o-normal--10-100-75-75-p-57-iso10646-1,-*-r-*-iso10646-1,*"
}
widget "*" style "default-text"

at the end. It's still not perfect and I don't fully understand it. But progress.

1
nice pictures, but what about the source code, maybe something that you have missed will be noticedTerryG
A fair point, it's a vague question. I was hoping the answer would be an obvious one something along the lines of "text is written by the gtk_something_method" and I could start to dig there. I'll try to pare it down with code examples later today.chgreer

1 Answers

1
votes

So, finally I was able to find an answer.

As a gtk 1.2 app, the program will eventually respect the system (or local) .gtkrc file.

The long string next to fontset is an X Logical Font Description (wikipedia).

The program xfontsel (provided for CentOS in the xorg-x11-apps yum package) allows one to pick which string they want. My final selection for my gtkrc file is:

style "default-text" {
fontset = "-adobe-helvetica-medium-r-normal--*-80-*-*-*-*-*-*"
}
widget "*" style "default-text"

Which gives me the following result:

fixed gui.

I'm sure that, since the earliest references to GTK+ 1.2.10 start around 2001 this will be a super useful post in the future of Stack Exchange. Hopefully anyone else who has this problem will at least find this useful.

Not every example of this kind of style definition I found on nearly 15-year-old forum posts worked in my gtkrc. I'm guessing it has to do with certain fonts being on my system.