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



On Fri, May 02, 2003 at 11:09:18AM -0400, Kevin B. McCarty wrote:

- what should I use instead of GdkFont?

Pango Layouts

- 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.

I'm not familiar with that dialog, but pango_layout_set_font_description
accepts its kind of output.

- what should I use instead of gdk_draw_text() to replace the second
  GdkFont argument after switching to Pango?

gtk_paint_layout (documentation in the Style chapter of the GTK+ API
reference - took me a while to find it there) or gdk_draw_layout for more
lowlevel stuff.

Basic order is:

  layout = gtk_widget_create_pango_layout (...)
  pango_layout_set_font_description (...) /* optional */
  gtk_paint_layout (...) /* or gdk_draw_layout */
  g_object_unref (layout)

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?)...

I agree. I found the bits & pieces from this mailinglist, and looking at
others people code. While the solution is (IMO) quite simple, all of the
function calls mentioned above are scattered over different parts of
multiple API references, sometimes non-obvious parts even. There is no
simple "where to start" or "how do I" for this particular problem AFAIK.
Just a short notice in the GdkFont documentation would suffice.


Regards,

Filip

-- 
I have not lost my mind, its backed up on tape somewhere



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