tags:

views:

44

answers:

2

Is there a place where I can get a list of all fonts that are guaranteed to be present on any system with GTK? I need a way to set a sane default font for some plots, and of course the sane default font must be present.

Edit: If no specific fonts are guaranteed to be present, is there an easy way to just get some sane default scalable sans-serif font? I don't care about the details.

Edit # 2: If nothing can be guaranteed on GTK, can someone give me good platform-specific default scalable sans-serif fonts that are guaranteed to be present on any reasonable installation of Windows and *nix/X11?

+1  A: 

The default fonts you should use in GTK+ are "Sans", "Monospace" and "Serif". I don't believe that any specific fonts are guaranteed to exist.

goffrie
Are these scalable fonts? Can I assume any size I need is present? Also, are they case-sensitive?
dsimcha
I think it's safe to assume that Sans, Monospace, and Serif are scalable and have upper and lower case. They will just be the default fonts for a given platform. These are the correct default fonts to use in your app. If they're broken the fix would be to the platform, not the app.
Havoc P
+3  A: 

No fonts are guaranteed to be present on any system with GTK, since GTK is a cross-platform toolkit and doesn't install any of its own fonts.

Depending on how you are rendering your plots (Cairo?), any text should already be drawn in a default font. EDIT: Sounds like you are using gdk_draw_layout() to draw your text. This takes a PangoLayout argument. If you obtain that PangoLayout using gtk_widget_create_pango_layout(), then it should already have a sane default font set. You can even find out what font that is, by getting the PangoContext using pango_layout_get_context(), and then calling pango_context_get_font_description() on that.

If you are also using GNOME, then you can check the value of the /desktop/gnome/interface/font-name, /desktop/gnome/interface/monospace-font-name, and /desktop/gnome/interface/document-font-name keys with GConf.

ptomato
I'm using a DrawingArea and gdk's drawable API for now.
dsimcha
See updated answer.
ptomato