Re: DrawingArea and Text display.



Hi,

"Neil Hodgson" <nhodgson bigpond net au> writes:

> Tony Denault:
> 
> >    Fixed_font = pango_font_description_from_string ("Fixed");
> >    GC = gdk_gc_new(base_window->window);
> > 
> >    <stuck on how to display string in Drawing area using pango>
> 
> PangoContext *pcontext = gtk_widget_create_pango_context(widget);
> PangoLayout *layout = pango_layout_new(pcontext);
> char *utfForm = "Some UTF-8 text";
> pango_layout_set_text(layout, utfForm, strlen(utfForm));
> pango_layout_set_font_description(layout, Fixed_font);
> PangoLayoutLine *pll = pango_layout_get_line(layout,0);
> gdk_draw_layout_line(drawable, gc, x, ybase, pll);

or slightly simpler and good for multi-line strings as well:

 PangoContext *context = gtk_widget_create_pango_context (widget);
 PangoLayout  *layout  = pango_layout_new (context);

 g_object_unref (context);

 pango_layout_set_font_description (layout, font_desc);
 pango_layout_set_text (layout, "Some UTF-8 text", -1);

 gdk_draw_layout (drawable, gc, x, y, layout);

 g_object_unref (layout);


however you probably want to save the context and the layout between
exposures to speed things up a bit.



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