Pango with a GtkDrawingArea? (what to use instead of GdkFont?)



Hi,
I am converting StarPlot ( http://www.princeton.edu/~kmccarty/starplot.html )
from GTK+ 1.2 to GTK+ 2.  This is going well, except that I want to add a 
font dialog so users can select the font displayed on the main display, 
which is a GtkDrawingArea.  The drawing code uses GDK.

In GTK+ 1.2, I could simply set the font with something like
  GdkFont *font = 
    gdk_font_load("-adobe-helvetica-medium-r-normal--10-100-*-*-*-*-*-*");

and then draw text on the drawing area with
  gdk_draw_text(pixmap, font, ...);

and everything was happy.  But it looks like in GTK+ 2, GdkFont is 
deprecated.  So my questions are:

- what should I use instead of GdkFont?
- how do I get it to use the output of a GtkFontSelectionDialog
  (looking like "Sans 12") instead of an XLFD ("-adobe-helvetica...")?
  The following just results in a segfault:
  GdkFont *font = 
    gdk_font_from_description(pango_font_description_from_string("Sans 12"));
  and I don't want to continue to use the deprecated GdkFont anyway.
- what should I use instead of gdk_draw_text() to replace the second
  GdkFont argument after switching to Pango?

I tried reading the Pango API documentation, but it was completely 
confusing and there was no good starting point or FAQ.  It would be nice 
if there was a friendly Pango tutorial like the GTK+ tutorial (or have I 
just not found it?)...

Please CC me as I'm not subscribed to the list.
Thanks very much,

-- 
Kevin McCarty                Physics Department
kmccarty princeton edu       Princeton University
www.princeton.edu/~kmccarty  Princeton, NJ 08544




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