Re: insert text in a drawing area (gdk_draw_text deprecated)



Marco Mussini wrote:

Hi all,
I must insert a text in a drawing area but API documentation say that
gdk_draw_text is deprecated;
I suppose that pango must be used for this purpose. What function could I
use? (or have you an example of code?)

Consider gdk_draw_layout(), gdk_draw_layout_with_colors():
http://developer.gnome.org/doc/API/2.0/gdk/gdk-Drawing-Primitives.html#gdk-draw-layout

You can look at gtk+-2.0 sources ("gtklabel.c", for example) or use smth like this:

void draw_text(GtkWidget *widget, gchar *s_utf8)
{
PangoLayout *layout;

   layout = pango_layout_new(gdk_pango_context_get());
   pango_layout_set_text(layout, s_utf8, -1);

   gdk_draw_layout(widget->window, widget->style->white_gc, 16,16, layout);

   g_object_unref(layout);
}

Olexiy





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