Gtk-WARNING Default font does not have a positive size

As “Gtk-WARNING Default font does not have a positive size” suggests, this arises from a font size specified incorrectly, or not at all in some cases. This problem annoyed me for a while after using a few different window managers with Linux (Ubuntu in particular). I believe it came about after changing some font settings and changing themes a few times, particularly with LXappearance. I’m guessing if you are looking at this you have also made a few changes and are now also being annoyed by this message!

The Problem

You will see this annoying message, repeated numerous times in the terminal, when launching applications from a terminal:

Gtk-WARNING **: Default font does not have a positive size

 I *narrowed* it down to my ~/.gtkrc-2.0 file. I had been messing around with my themes and the apps I was using (gtk-chtheme and lxappearance) didn’t set the font properly.

The Fix

Open up your ~/.gtkrc-2.0 file, from terminal:

gedit ~/.gtkrc-2.0

and locate the line:

gtk-font-name=" **your font** "

This line failed to include the font size, so add a size, in my case I changed it to this:

gtk-font-name="Ubuntu 10"

……. and the errors disappeared.

NOTE (GTK3 fix)

If this does not fix the problem you can do the same in this file:

gedit ~/.config/gtk-3.0/settings.ini

I have noticed settings in this file are temperamental about quotes (“”), so if it doesn’t work with them, give it a go without.

One of the issues you may have is in some cases theme managers change these files. If the manager fails to update them correctly, then the issue will come back. Not a solid fix but the problem is a bit deeper than this post. Good luck!