Pango and text drawing confusion



Hi all,
	I'm trying to draw some text onto a drawing area in GTK+2.0.

Now, the docs say I can't use gdk_draw_text() because it's deprecated. I have looked around for other ways of drawing text and it looks like I have to use gdk_draw_layout() instead, which means I have to get involved with Pango.

As far as I can tell, in order to get a PangoLayout I first need to make a PangoContext and then create a PangoLayout from this context.

kinda like this:

#include <pango.h>
#include <gtk.h>
{
	PangoContext *pContext;
	PangoLayout *pDrawingAreaLayout;
	
	pContext = pango_context_new();	
	pDrawingAreaLayout = pango_layout_new(Context);
	pango_layout_set_text(pDrawingAreaLayout, "Here is some text", -1);
	
	gdk_draw_layout(widget->window, NULL, 0, 0, pDrawingAreaLayout);
}

The problem is that I can't call pango_context_new() because the compiler says it's an undeclared function. This seems to be because in pango-context.h there is this:

#ifdef PANGO_ENABLE_BACKEND
PangoContext *pango_context_new           (void);
void pango_context_set_font_map (PangoContext *context,
					   PangoFontMap                 *font_map);
#endif /* PANGO_ENABLE_BACKEND */

Can anyone explain to me what is going on here? Have I got it completely wrong or what?

Cheers in advance,

Mark Wheaton





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