Re: Pango and text drawing confusion
- From: Sven Neumann <sven gimp org>
- To: mark wheaton bigfoot com
- Cc: gtk-list gnome org
- Subject: Re: Pango and text drawing confusion
- Date: 15 Oct 2002 14:50:23 +0200
Hi,
Mark Wheaton <mark wheaton ntlworld com> writes:
> 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?
you should let the drawing area create the layout for you; like this:
layout = gtk_widget_create_pango_layout (drawing_area,
"Here is some text");
Also, you should only draw the layout in the drawing_area's expose
handler but you probably know that already as it has been discussed
here every so often.
Salut, Sven
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]